diff --git a/.github/ci-hpc-config.yml b/.github/ci-hpc-config.yml index 801481f83..3ae75ea37 100644 --- a/.github/ci-hpc-config.yml +++ b/.github/ci-hpc-config.yml @@ -3,7 +3,7 @@ build: - ecbuild - ninja - aec - - netcdf4/new + - netcdf4 parallel: 64 cmake_options: - -DENABLE_EXTRA_TESTS=1 diff --git a/.github/ci-nightly-test.sh b/.github/ci-nightly-test.sh index d0b206c7c..4eb4a54a9 100644 --- a/.github/ci-nightly-test.sh +++ b/.github/ci-nightly-test.sh @@ -8,7 +8,7 @@ module unload ecmwf-toolbox module load cdo/new module load numdiff module load nccmp -module load netcdf4/new +module load netcdf4 module load gnuparallel/new module load python3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f11896b00..16c400bec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,7 @@ jobs: uses: ecmwf-actions/downstream-ci/.github/workflows/downstream-ci.yml@main with: eccodes: ecmwf/eccodes@${{ github.event.pull_request.head.sha || github.sha }} + codecov_upload: true secrets: inherit # Run CI of private downstream packages on self-hosted runners @@ -74,15 +75,6 @@ jobs: event_type: downstream-ci-hpc payload: '{"eccodes": "ecmwf/eccodes@${{ github.event.pull_request.head.sha || github.sha }}"}' - codecov: - name: code-coverage - if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} - uses: ./.github/workflows/reusable-ci.yml - with: - eccodes: ecmwf/eccodes@${{ github.event.pull_request.head.sha || github.sha }} - codecov: true - secrets: inherit - notify: runs-on: ubuntu-latest needs: @@ -90,7 +82,6 @@ jobs: - private-downstream-ci - downstream-ci-hpc - private-downstream-ci-hpc - - codecov if: always() && ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} steps: - name: Trigger Teams notification diff --git a/.github/workflows/reusable-ci-hpc.yml b/.github/workflows/reusable-ci-hpc.yml index 793f26ebe..1176afc9d 100644 --- a/.github/workflows/reusable-ci-hpc.yml +++ b/.github/workflows/reusable-ci-hpc.yml @@ -23,7 +23,7 @@ jobs: ecbuild ninja aec - netcdf4/new + netcdf4 --parallel: 64 --cmake-options: | -DENABLE_EXTRA_TESTS=1 diff --git a/.gitignore b/.gitignore index bfdfd9434..8791994fc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ grib_api.pc grib_api_f90.pc *.analyzerinfo *.snalyzerinfo +tags +src/convert_*.sh # compiled source # ################### @@ -72,3 +74,4 @@ data/bufr/*test build/ *.back +trash diff --git a/AUTHORS b/AUTHORS index f21f35fcf..c0f36b955 100755 --- a/AUTHORS +++ b/AUTHORS @@ -1,6 +1,7 @@ -Enrico Fucile Shahram Najm Eugen Betke +Enrico Fucile +Pedro Maciel Sandor Kertesz Sebastien Villaume Florian Rathgeber diff --git a/CMakeLists.txt b/CMakeLists.txt index f60682739..2da7bf145 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,17 +73,11 @@ endif() ############################################################################### # some variables/options of this project -if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) - ecbuild_add_cxx_flags("-Wno-write-strings") - ecbuild_add_cxx_flags("-Wno-deprecated") -elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) - ecbuild_add_cxx_flags("-Wno-write-strings") - ecbuild_add_cxx_flags("-Wno-deprecated") - else() - ecbuild_add_cxx_flags("-Wno-writable-strings") - endif() -elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Cray" ) +# ecbuild_add_cxx_flags("-Wno-write-strings" NO_FAIL) +# ecbuild_add_cxx_flags("-Wno-writable-strings" NO_FAIL) +# ecbuild_add_cxx_flags("-Wno-deprecated" NO_FAIL) + +if( CMAKE_CXX_COMPILER_ID STREQUAL "Cray" ) set(CMAKE_CXX_FLAGS "-hstd=c++11 ${CMAKE_CXX_FLAGS}") endif() @@ -201,8 +195,8 @@ ecbuild_add_option( FEATURE INSTALL_ECCODES_SAMPLES ecbuild_add_option( FEATURE MEMORY_MANAGEMENT DESCRIPTION "Enable memory management" DEFAULT OFF ADVANCED ) ecbuild_add_option( FEATURE ALIGN_MEMORY DESCRIPTION "Enable memory alignment" DEFAULT OFF ADVANCED ) ecbuild_add_option( FEATURE TIMER DESCRIPTION "Enable timer" DEFAULT OFF ADVANCED ) -ecbuild_add_option( FEATURE ECCODES_THREADS DESCRIPTION "Enable POSIX threads" DEFAULT OFF ADVANCED ) -ecbuild_add_option( FEATURE ECCODES_OMP_THREADS DESCRIPTION "Enable OpenMP threads" DEFAULT OFF ADVANCED ) +ecbuild_add_option( FEATURE ECCODES_THREADS DESCRIPTION "Enable thread-safety using POSIX threads" DEFAULT OFF ADVANCED ) +ecbuild_add_option( FEATURE ECCODES_OMP_THREADS DESCRIPTION "Enable thread-safety using OpenMP threads" DEFAULT OFF ADVANCED ) ecbuild_add_option( FEATURE EXTRA_TESTS DESCRIPTION "Enable extended regression testing" DEFAULT OFF ADVANCED ) ############################################################################### diff --git a/INSTALL b/INSTALL index b75d5b2b5..bccdbc3fb 100644 --- a/INSTALL +++ b/INSTALL @@ -33,8 +33,6 @@ However it requires that cmake be installed on your system. To add the Python3 bindings, use pip3 install from PyPI as follows: > pip3 install eccodes - or - > pip3 install --install-option="--prefix=/path/to/where/you/install/eccodes" eccodes You can also pass options to the cmake command above. Some typical examples are: diff --git a/README.md b/README.md index f63d65384..05d59c9f1 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ INSTALLATION ``` cmake ../eccodes-x.y.z-Source -DCMAKE_INSTALL_PREFIX=/path/to/where/you/install/eccodes ``` - + It is strongly recommended that you install into a clean directory 5. Compile, test and install: @@ -60,11 +60,6 @@ To add the Python3 bindings, use pip3 install from PyPI as follows: ``` pip3 install eccodes ``` - or - ``` - pip3 install --install-option="--prefix=/path/to/where/you/install/eccodes" eccodes - ``` - For more details, please see: https://confluence.ecmwf.int/display/ECC/ecCodes+installation diff --git a/VERSION b/VERSION index aa5388f63..3a05135cd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.35.0 +2.36.0 diff --git a/bamboo/flags.cmake b/bamboo/flags.cmake index 2c5a809e2..b434036aa 100644 --- a/bamboo/flags.cmake +++ b/bamboo/flags.cmake @@ -1,3 +1,5 @@ -SET(ENABLE_EXTRA_TESTS ON CACHE BOOL "Enable extra tests") -SET(ENABLE_ECCODES_THREADS ON CACHE BOOL "Enable POSIX threads") -SET(ENABLE_MEMFS ON CACHE BOOL "Enable MEMFS") +SET(ENABLE_EXTRA_TESTS ON CACHE BOOL "Enable extra tests") +SET(ECCODES_INSTALL_EXTRA_TOOLS ON CACHE BOOL "Install extra tools") +SET(ENABLE_ECCODES_THREADS ON CACHE BOOL "Enable POSIX threads") +SET(ENABLE_MEMFS ON CACHE BOOL "Enable MEMFS") +# SET(ENABLE_JPG_LIBOPENJPEG OFF CACHE BOOL "Disable OpenJPEG") diff --git a/data/julian.out.good b/data/julian.out.good index c1321285c..c897c9476 100644 --- a/data/julian.out.good +++ b/data/julian.out.good @@ -62,4 +62,6 @@ Test2... - -47120001 -> 6 Test3... +Test4... +Test5... All OK diff --git a/definitions/bufr/section.3.def b/definitions/bufr/section.3.def index 1d9d8c7f9..d223bbbb2 100644 --- a/definitions/bufr/section.3.def +++ b/definitions/bufr/section.3.def @@ -51,7 +51,7 @@ unsigned[2] numberOfSubsets : dump; alias ls.numberOfSubsets=numberOfSubsets; if (section2Present && bufrHeaderCentre==98 && section2Length==52) { - if ( rdbType == 2 || rdbType == 3 || rdbType == 8 || rdbType == 12 ) { + if ( rdbType == 2 || rdbType == 3 || rdbType == 8 || rdbType == 12 || rdbType == 30 ) { transient isSatelliteType=1; } else { transient isSatelliteType=0; diff --git a/definitions/check_grib_defs.pl b/definitions/check_grib_defs.pl index dba8c0e27..d011680f3 100755 --- a/definitions/check_grib_defs.pl +++ b/definitions/check_grib_defs.pl @@ -204,6 +204,7 @@ sub process { } elsif ($this =~ /'(.*)' *= *{/) { $concept = $1; + die "File: $filename, line: $lineNum: Value is empty." if ($concept eq ''); die "File: $filename, line: $lineNum: Value contains invalid characters." if (non_printable($concept)); if ($filename eq 'cfVarName.def') { #if ($concept =~ /^[0-9]/) { diff --git a/definitions/common/c-11.table b/definitions/common/c-11.table index 6c52dbf48..6750fda58 100644 --- a/definitions/common/c-11.table +++ b/definitions/common/c-11.table @@ -2,20 +2,28 @@ 0 0 WMO Secretariat 1 ammc Melbourne (WMC) 2 2 Melbourne (WMC) +3 3 Melbourne (WMC) 4 rums Moscow (WMC) 5 5 Moscow (WMC) +6 6 Moscow (WMC) 7 kwbc US National Weather Service - NCEP (WMC) 8 8 US National Weather Service - NWSTG (WMC) 9 9 US National Weather Service - Other (WMC) 10 10 Cairo (RSMC/RAFC) +11 11 Cairo (RSMC/RAFC) 12 12 Dakar (RSMC/RAFC) +13 13 Dakar (RSMC/RAFC) 14 14 Nairobi (RSMC/RAFC) -16 16 Atananarivo (RSMC) +15 15 Nairobi (RSMC/RAFC) +16 16 Casablanca (RSMC) +17 17 Tunis (RSMC) 18 18 Tunis-Casablanca (RSMC) 20 20 Las Palmas (RAFC) 21 21 Algiers (RSMC) -22 22 Lagos (RSMC) +22 22 ACMAD +23 23 Mozambique (NMC) 24 fapr Pretoria (RSMC) +25 25 La Reunion (RSMC) 26 26 Khabarovsk (RSMC) 28 vabb New Delhi (IMD) 29 dems New Delhi (NCMRWF) @@ -23,29 +31,42 @@ 32 32 Tashkent (RSMC) 33 33 Jeddah (RSMC) 34 rjtd Japanese Meteorological Agency - Tokyo (RSMC) -36 36 Bankok -37 37 Ulan Bator +36 36 Bangkok +37 37 Ulaanbaatar 38 babj Beijing (RSMC) 40 rksl Seoul 41 sabm Buenos Aires (RSMC/RAFC) 43 43 Brasilia (RSMC/RAFC) 45 45 Santiago 46 sbsj Brasilian Space Agency - INPE +47 47 Colombia (NMC) +48 48 Ecuador (NMC) +49 49 Peru (NMC) +50 50 Venezuela (Bolivarian Republic of) (NMC) 51 51 Miami (RSMC/RAFC) 52 52 National Hurricane Center, Miami 53 53 Canadian Meteorological Service - Montreal (RSMC) 54 cwao Canadian Meteorological Service - Montreal (RSMC) 55 55 San Francisco +56 56 ARINC Centre 57 57 U.S. Air Force - Global Weather Center 58 fnmo US Navy - Fleet Numerical Oceanography Center 59 59 NOAA Forecast Systems Lab, Boulder CO 60 60 National Center for Atmospheric Research (NCAR), Boulder, CO +61 61 Service ARGOS - Landover +62 62 US Naval Oceanographic Office +63 63 International Research Institute for Climate and Society (IRI) 64 64 Honolulu 65 65 Darwin (RSMC) 67 67 Melbourne (RSMC) +# 68 Reserved 69 nzkl Wellington (RSMC/RAFC) +71 71 Nadi (RSMC) +72 72 Singapore +73 73 Malaysia (NMC) 74 egrr U.K. Met Office - Exeter 76 76 Moscow (RSMC/RAFC) +# 77 Reserved 78 edzw Offenbach (RSMC) 80 cnmc Rome (RSMC) 82 eswi Norrkoping @@ -65,11 +86,103 @@ 97 97 European Space Agency (ESA) 98 ecmf European Centre for Medium-Range Weather Forecasts 99 99 DeBilt, Netherlands -110 110 Hong-Kong +100 100 Brazzaville +101 101 Abidjan +102 102 Libya (NMC) +103 103 Madagascar (NMC) +104 104 Mauritius (NMC) +105 105 Niger (NMC) +106 106 Seychelles (NMC) +107 107 Uganda (NMC) +108 108 United Republic of Tanzania (NMC) +109 109 Zimbabwe (NMC) +110 110 Hong Kong +111 111 Afghanistan (NMC) +112 112 Bahrain (NMC) +113 113 Bangladesh (NMC) +114 114 Bhutan (NMC) +115 115 Cambodia (NMC) +116 116 Democratic People's Republic of Korea (NMC) +117 117 Islamic Republic of Iran (NMC) +118 118 Iraq (NMC) +119 119 Kazakhstan (NMC) +120 120 Kuwait (NMC) +121 121 Kyrgyzstan (NMC) +122 122 Lao People's Democratic Republic (NMC) +123 123 "Macao China" +124 124 Maldives (NMC) +125 125 Myanmar (NMC) +126 126 Nepal (NMC) +127 127 Oman (NMC) +128 128 Pakistan (NMC) +129 129 Qatar (NMC) +130 130 Yemen (NMC) +131 131 Sri Lanka (NMC) +132 132 Tajikistan (NMC) +133 133 Turkmenistan (NMC) +134 134 United Arab Emirates (NMC) +135 135 Uzbekistan (NMC) +136 136 Viet Nam (NMC) +# 137-139 Reserved for other centres +140 140 Bolivia (Plurinational State of) (NMC) +141 141 Guyana (NMC) +142 142 Paraguay (NMC) +143 143 Suriname (NMC) +144 144 Uruguay (NMC) +145 145 French Guiana +146 146 Brazilian Navy Hydrographic Centre +147 147 National Commission on Space Activities (CONAE) - Argentina +148 148 Brazilian Department of Airspace Control - DECEA +# 149 Reserved for other centres +150 150 Antigua and Barbuda (NMC) +151 151 Bahamas (NMC) +152 152 Barbados (NMC) +153 153 Belize (NMC) +154 154 British Caribbean Territories Centre +155 155 San Jose +156 156 Cuba (NMC) +157 157 Dominica (NMC) +158 158 Dominican Republic (NMC) +159 159 El Salvador (NMC) 160 160 US NOAA/NESDIS +161 161 US NOAA Office of Oceanic and Atmospheric Research +162 162 Guatemala (NMC) +163 163 Haiti (NMC) +164 164 Honduras (NMC) +165 165 Jamaica (NMC) +166 166 Mexico +167 167 Curacao and Sint Maarten (NMC) +168 168 Nicaragua (NMC) +169 169 Panama (NMC) +170 170 Saint Lucia (NMC) +171 171 Trinidad and Tobago (NMC) +172 172 French Departments in RA IV 173 nasa US National Aeronautics and Space Administration (NASA) +174 174 Integrated Science Data Management/Marine Environmental Data Service (ISDM/MEDS - Canada) +175 175 University Corporation for Atmospheric Research (UCAR) - United States +176 176 Cooperative Institute for Meteorological Satellite Studies (CIMSS) - United States +177 177 NOAA National Ocean Service - United States +178 178 Spire Global, Inc. +179 179 GeoOptics, Inc. +180 180 PlanetiQ +181 181 Atmospheric and Environmental Research (AER) +# 182-189 Reserved for other centres +190 190 Cook Islands (NMC) +191 191 French Polynesia (NMC) +192 192 Tonga (NMC) +193 193 Vanuatu (NMC) +194 194 Brunei Darussalam (NMC) 195 wiix Indonesia (NMC) +196 196 Kiribati (NMC) +197 197 Federated States of Micronesia (NMC) +198 198 New Caledonia (NMC) +199 199 Niue +200 200 Papua New Guinea (NMC) +201 201 Philippines (NMC) +202 202 Samoa (NMC) +203 203 Solomon Islands (NMC) 204 niwa National Institute of Water and Atmospheric Research (NIWA - New Zealand) +# 205-209 Reserved for other centres 210 210 Frascati (ESA/ESRIN) 211 211 Lannion 212 212 Lisboa @@ -85,6 +198,8 @@ 222 222 Albania (NMC) 223 223 Armenia (NMC) 224 lowm Austria +225 225 Azerbaijan (NMC) +226 226 Belarus (NMC) 227 ebum Belgium (NMC) 228 228 Bosnia and Herzegovina (NMC) 229 229 Bulgaria (NMC) @@ -94,17 +209,24 @@ 233 eidb Dublin 234 234 Israel (NMC) 235 ingv INGV +236 236 Latvia (NMC) +237 237 Lebanon (NMC) +238 238 Lithuania (NMC) 239 crfc CERFAX 240 240 Malta (NMC) 241 241 Monaco 242 242 Romania (NMC) +243 243 Syrian Arab Republic (NMC) 244 vuwien VUWien 245 knmi KNMI 246 ifmk IfM-Kiel 247 hadc Hadley Centre +248 248 Montenegro (NMC) +249 249 Barcelona Dust Forecast Center 250 cosmo COnsortium for Small scale MOdelling (COSMO) 251 251 Meteorological Cooperation on Operational NWP (MetCoOp) 252 mpim Max Planck Institute for Meteorology (MPI-M) +253 253 Alfred Wegener Institute (AWI) 254 eums EUMETSAT Operation Centre 255 consensus Consensus 256 256 Angola (NMC) @@ -138,9 +260,10 @@ 284 284 Sierra Leone (NMC) 285 285 Somalia (NMC) 286 286 Sudan (NMC) -287 287 Swaziland (NMC) +287 287 Eswatini (NMC) 288 288 Togo (NMC) 289 289 Zambia (NMC) +290 290 EUMETNET E-Profile 291 anso Alliance of International Science Organizations (Beijing, China) 292 ufz Helmholtz Centre for Environmental Research 293 293 University of Bremen @@ -150,4 +273,28 @@ 297 297 The Nanjing Institute of Environmental Sciences (NIES) 298 298 Dynamic Meteorology Laboratory (LMD) 299 299 The Rutherford Appleton Laboratory (RAL) +300 300 Greek Atomic Energy Commission (Greece) +301 301 United Stated Environmental Protection Agency (USA) +302 302 Autralian Radiation Protection and Nuclear Safety (Australia) +303 303 Authority for Nuclear Safety and Radiation Protection (The Netherlands) +304 304 Autorite de Surete Nucleaire (France) +305 305 Bundesamt für Strahlenschutz (Germany) +306 306 National Commission for Nuclear Activities Control (Romania) +307 307 Consejo de Seguridad Nuclear (Spain) +308 308 Danish Emergency Management Agency (Denmark) +309 309 Norwegian Radiation Protection Agency (Norway) +310 310 Federal Agency for Nuclear Control (Belgium) +311 311 Institute of Radiation Protection and Dosimetry (Brazil) +312 312 National Inspectorate for Nuclear Safety and Radiation Protection (Italy) +313 313 Nuclear Regulatory Authority (Turkiye) +314 314 Nuclear Regulation Authority (Japan) +315 315 Nuclear Regulatory Agency (Bulgaria) +316 316 Ukrainian Radiation Protection Institute (Ukriane) +317 317 Health Canada Radio Protection Bureau (Canada) +318 318 Portuguese Society for Radiation Protection (Portugal) +319 319 Swedish Radiation Safety Authority (Sweden) +320 320 Radiation and Nuclear Safety Authority (Finland) +321 321 State Office for Nuclear Safety (Czechia) +322 322 Nuclear Regulation Authority (Slovakia) +# 323-65534 Reserved for other centres 65535 65535 Missing value diff --git a/definitions/grib1/cfVarName.def b/definitions/grib1/cfVarName.def index 50489e1a6..94c685c22 100644 --- a/definitions/grib1/cfVarName.def +++ b/definitions/grib1/cfVarName.def @@ -1148,36 +1148,6 @@ table2Version = 1 ; indicatorOfParameter = 48 ; } -#U-component of current -'ucurr' = { - table2Version = 3 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'ucurr' = { - table2Version = 2 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'ucurr' = { - table2Version = 1 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'vcurr' = { - table2Version = 3 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'vcurr' = { - table2Version = 2 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'vcurr' = { - table2Version = 1 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio 'mixr' = { table2Version = 3 ; diff --git a/definitions/grib1/localConcepts/ecmf/cfName.def b/definitions/grib1/localConcepts/ecmf/cfName.def index 48b023899..f1377da79 100644 --- a/definitions/grib1/localConcepts/ecmf/cfName.def +++ b/definitions/grib1/localConcepts/ecmf/cfName.def @@ -909,12 +909,12 @@ table2Version = 151 ; indicatorOfParameter = 130 ; } -#Eastward sea water velocity +#Eastward surface sea water velocity 'eastward_sea_water_velocity' = { table2Version = 151 ; indicatorOfParameter = 131 ; } -#Northward sea water velocity +#Northward surface sea water velocity 'northward_sea_water_velocity' = { table2Version = 151 ; indicatorOfParameter = 132 ; diff --git a/definitions/grib1/localConcepts/ecmf/cfVarName.def b/definitions/grib1/localConcepts/ecmf/cfVarName.def index 6e19617e2..e3d757597 100644 --- a/definitions/grib1/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib1/localConcepts/ecmf/cfVarName.def @@ -12659,7 +12659,7 @@ table2Version = 140 ; indicatorOfParameter = 217 ; } -#Maximum individual wave height +#Envelop-maximum individual wave height 'hmax' = { table2Version = 140 ; indicatorOfParameter = 218 ; @@ -13024,12 +13024,12 @@ table2Version = 151 ; indicatorOfParameter = 130 ; } -#Eastward sea water velocity +#Eastward surface sea water velocity 'uoe' = { table2Version = 151 ; indicatorOfParameter = 131 ; } -#Northward sea water velocity +#Northward surface sea water velocity 'von' = { table2Version = 151 ; indicatorOfParameter = 132 ; @@ -13244,7 +13244,7 @@ table2Version = 151 ; indicatorOfParameter = 174 ; } -#Average salinity in the upper 300m +#Average sea water practical salinity in the upper 300m 'sav300' = { table2Version = 151 ; indicatorOfParameter = 175 ; diff --git a/definitions/grib1/localConcepts/ecmf/name.def b/definitions/grib1/localConcepts/ecmf/name.def index bee6eddab..77d5535a7 100644 --- a/definitions/grib1/localConcepts/ecmf/name.def +++ b/definitions/grib1/localConcepts/ecmf/name.def @@ -12659,8 +12659,8 @@ table2Version = 140 ; indicatorOfParameter = 217 ; } -#Maximum individual wave height -'Maximum individual wave height' = { +#Envelop-maximum individual wave height +'Envelop-maximum individual wave height' = { table2Version = 140 ; indicatorOfParameter = 218 ; } @@ -13024,13 +13024,13 @@ table2Version = 151 ; indicatorOfParameter = 130 ; } -#Eastward sea water velocity -'Eastward sea water velocity' = { +#Eastward surface sea water velocity +'Eastward surface sea water velocity' = { table2Version = 151 ; indicatorOfParameter = 131 ; } -#Northward sea water velocity -'Northward sea water velocity' = { +#Northward surface sea water velocity +'Northward surface sea water velocity' = { table2Version = 151 ; indicatorOfParameter = 132 ; } @@ -13244,8 +13244,8 @@ table2Version = 151 ; indicatorOfParameter = 174 ; } -#Average salinity in the upper 300m -'Average salinity in the upper 300m' = { +#Average sea water practical salinity in the upper 300m +'Average sea water practical salinity in the upper 300m' = { table2Version = 151 ; indicatorOfParameter = 175 ; } diff --git a/definitions/grib1/localConcepts/ecmf/paramId.def b/definitions/grib1/localConcepts/ecmf/paramId.def index bd07cf762..0ea5b7ea3 100644 --- a/definitions/grib1/localConcepts/ecmf/paramId.def +++ b/definitions/grib1/localConcepts/ecmf/paramId.def @@ -12659,7 +12659,7 @@ table2Version = 140 ; indicatorOfParameter = 217 ; } -#Maximum individual wave height +#Envelop-maximum individual wave height '140218' = { table2Version = 140 ; indicatorOfParameter = 218 ; @@ -13024,12 +13024,12 @@ table2Version = 151 ; indicatorOfParameter = 130 ; } -#Eastward sea water velocity +#Eastward surface sea water velocity '151131' = { table2Version = 151 ; indicatorOfParameter = 131 ; } -#Northward sea water velocity +#Northward surface sea water velocity '151132' = { table2Version = 151 ; indicatorOfParameter = 132 ; @@ -13244,7 +13244,7 @@ table2Version = 151 ; indicatorOfParameter = 174 ; } -#Average salinity in the upper 300m +#Average sea water practical salinity in the upper 300m '151175' = { table2Version = 151 ; indicatorOfParameter = 175 ; diff --git a/definitions/grib1/localConcepts/ecmf/paramIdForConversion.def b/definitions/grib1/localConcepts/ecmf/paramIdForConversion.def new file mode 100644 index 000000000..07b7d5a83 --- /dev/null +++ b/definitions/grib1/localConcepts/ecmf/paramIdForConversion.def @@ -0,0 +1,37 @@ +# Concept paramIdForConversion for ECMWF +# See ECC-1806 + +# 55 +228004 = {gribTablesVersionNo=128; indicatorOfParameter=55; centre=98;} +# 56 +235168 = {gribTablesVersionNo=128; indicatorOfParameter=56; centre=98;} +# 130232 +235135 = {gribTablesVersionNo=130; indicatorOfParameter=232; centre=98;} +# 151163 +262104 = {gribTablesVersionNo=151; indicatorOfParameter=163; centre=98;} +# 151145 +262124 = {gribTablesVersionNo=151; indicatorOfParameter=145; centre=98;} +# 172146 +235033 = {gribTablesVersionNo=172; indicatorOfParameter=146; centre=98;} +# 172147 +235034 = {gribTablesVersionNo=172; indicatorOfParameter=147; centre=98;} +# 172169 +235035 = {gribTablesVersionNo=172; indicatorOfParameter=169; centre=98;} +# 172175 +235036 = {gribTablesVersionNo=172; indicatorOfParameter=175; centre=98;} +# 172176 +235037 = {gribTablesVersionNo=172; indicatorOfParameter=176; centre=98;} +# 172177 +235038 = {gribTablesVersionNo=172; indicatorOfParameter=177; centre=98;} +# 172178 +235039 = {gribTablesVersionNo=172; indicatorOfParameter=178; centre=98;} +# 172179 +235040 = {gribTablesVersionNo=172; indicatorOfParameter=179; centre=98;} +# 174098 +262000 = {gribTablesVersionNo=174; indicatorOfParameter=98; centre=98;} +# 151175 +262118 = {gribTablesVersionNo=151; indicatorOfParameter=175; centre=98;} +# 151132 +262139 = {gribTablesVersionNo=151; indicatorOfParameter=132; centre=98;} +# 151131 +262140 = {gribTablesVersionNo=151; indicatorOfParameter=131; centre=98;} diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index 54ef51c2b..4eb5e6f67 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -12659,7 +12659,7 @@ table2Version = 140 ; indicatorOfParameter = 217 ; } -#Maximum individual wave height +#Envelop-maximum individual wave height 'hmax' = { table2Version = 140 ; indicatorOfParameter = 218 ; @@ -13024,12 +13024,12 @@ table2Version = 151 ; indicatorOfParameter = 130 ; } -#Eastward sea water velocity +#Eastward surface sea water velocity 'ocu' = { table2Version = 151 ; indicatorOfParameter = 131 ; } -#Northward sea water velocity +#Northward surface sea water velocity 'ocv' = { table2Version = 151 ; indicatorOfParameter = 132 ; @@ -13244,7 +13244,7 @@ table2Version = 151 ; indicatorOfParameter = 174 ; } -#Average salinity in the upper 300m +#Average sea water practical salinity in the upper 300m 'sav300' = { table2Version = 151 ; indicatorOfParameter = 175 ; diff --git a/definitions/grib1/localConcepts/ecmf/stepTypeForConversion.def b/definitions/grib1/localConcepts/ecmf/stepTypeForConversion.def index c649d29a6..25aae31d8 100644 --- a/definitions/grib1/localConcepts/ecmf/stepTypeForConversion.def +++ b/definitions/grib1/localConcepts/ecmf/stepTypeForConversion.def @@ -1,37 +1,220 @@ # Concept stepTypeForConversion for ECMWF -# set uses the FIRST one -# get returns the LAST match -# ECC-457: ECMWF Total Precipitation -"accum" = {timeRangeIndicator=0;indicatorOfParameter=228;gribTablesVersionNo=128;centre=98;} -"accum" = {timeRangeIndicator=1;indicatorOfParameter=228;gribTablesVersionNo=128;centre=98;} -"accum" = {timeRangeIndicator=10;indicatorOfParameter=228;gribTablesVersionNo=128;centre=98;} +# ECC-457: total precipitation +"accum"={timeRangeIndicator=0;indicatorOfParameter=228;gribTablesVersionNo=128;centre=98;} +"accum"={timeRangeIndicator=1;indicatorOfParameter=228;gribTablesVersionNo=128;centre=98;} +"accum"={timeRangeIndicator=10;indicatorOfParameter=228;gribTablesVersionNo=128;centre=98;} -# sshf -"accum" = {indicatorOfParameter=146;gribTablesVersionNo=128;centre=98;} -# slhf -"accum" = {indicatorOfParameter=147;gribTablesVersionNo=128;centre=98;} -# ssrd -"accum" = {indicatorOfParameter=169;gribTablesVersionNo=128;centre=98;} -# strd -"accum" = {indicatorOfParameter=175;gribTablesVersionNo=128;centre=98;} -# ssr -"accum" = {indicatorOfParameter=176;gribTablesVersionNo=128;centre=98;} -# str -"accum" = {indicatorOfParameter=177;gribTablesVersionNo=128;centre=98;} -# ttr -"accum" = {indicatorOfParameter=179;gribTablesVersionNo=128;centre=98;} -# sund -"accum" = {indicatorOfParameter=189;gribTablesVersionNo=128;centre=98;} -# runoff -"accum" = {indicatorOfParameter=205;gribTablesVersionNo=128;centre=98;} # sro -"accum" = {indicatorOfParameter=8;gribTablesVersionNo=128;centre=98;} -# e -"accum" = {indicatorOfParameter=182;gribTablesVersionNo=128;centre=98;} -# lsp -"accum" = {indicatorOfParameter=142;gribTablesVersionNo=128;centre=98;} -# pev -"accum" = {indicatorOfParameter=251;gribTablesVersionNo=228;centre=98;} +"accum"={gribTablesVersionNo=128;indicatorOfParameter=8;centre=98;} +# ssro +"accum"={gribTablesVersionNo=128;indicatorOfParameter=9;centre=98;} +# parcs +"accum"={gribTablesVersionNo=128;indicatorOfParameter=20;centre=98;} +# es +"accum"={gribTablesVersionNo=128;indicatorOfParameter=44;centre=98;} +# smlt +"accum"={gribTablesVersionNo=128;indicatorOfParameter=45;centre=98;} +# dsrp +"accum"={gribTablesVersionNo=128;indicatorOfParameter=47;centre=98;} +# 10fg +"max"={gribTablesVersionNo=128;indicatorOfParameter=49;centre=98;} +# lspf +"accum"={gribTablesVersionNo=128;indicatorOfParameter=50;centre=98;} +# mx2t24 +"max"={gribTablesVersionNo=128;indicatorOfParameter=51;centre=98;} +# mn2t24 +"min"={gribTablesVersionNo=128;indicatorOfParameter=52;centre=98;} # uvb -"accum" = {indicatorOfParameter=57;gribTablesVersionNo=128;centre=98;} +"accum"={gribTablesVersionNo=128;indicatorOfParameter=57;centre=98;} +# par +"accum"={gribTablesVersionNo=128;indicatorOfParameter=58;centre=98;} +# mx2t6 +"max"={gribTablesVersionNo=128;indicatorOfParameter=121;centre=98;} +# mn2t6 +"min"={gribTablesVersionNo=128;indicatorOfParameter=122;centre=98;} +# lsp +"accum"={gribTablesVersionNo=128;indicatorOfParameter=142;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=142;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=142;centre=98;} +# cp +"accum"={gribTablesVersionNo=128;indicatorOfParameter=143;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=143;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=143;centre=98;} +# sf +"accum"={gribTablesVersionNo=128;indicatorOfParameter=144;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=144;centre=98;} +# bld +"accum"={gribTablesVersionNo=128;indicatorOfParameter=145;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=145;centre=98;} +# sshf +"accum"={gribTablesVersionNo=128;indicatorOfParameter=146;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=146;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=146;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=146;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=146;centre=98;} +# slhf +"accum"={gribTablesVersionNo=128;indicatorOfParameter=147;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=147;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=147;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=147;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=147;centre=98;} +# snr +"accum"={gribTablesVersionNo=128;indicatorOfParameter=149;centre=98;} +# tnr +"accum"={gribTablesVersionNo=128;indicatorOfParameter=150;centre=98;} +# ssrd +"accum"={gribTablesVersionNo=128;indicatorOfParameter=169;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=169;centre=98;} +# strd +"accum"={gribTablesVersionNo=128;indicatorOfParameter=175;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=175;centre=98;} +# ssr +"accum"={gribTablesVersionNo=128;indicatorOfParameter=176;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=176;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=176;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=176;centre=98;} +# str +"accum"={gribTablesVersionNo=128;indicatorOfParameter=177;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=177;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=177;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=177;centre=98;} +# tsr +"accum"={gribTablesVersionNo=128;indicatorOfParameter=178;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=178;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=178;centre=98;} +# ttr +"accum"={gribTablesVersionNo=128;indicatorOfParameter=179;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=179;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=179;centre=98;} +# ewss +"accum"={gribTablesVersionNo=128;indicatorOfParameter=180;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=180;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=180;centre=98;} +# nsss +"accum"={gribTablesVersionNo=128;indicatorOfParameter=181;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=181;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=181;centre=98;} +# e +"accum"={gribTablesVersionNo=128;indicatorOfParameter=182;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=182;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=182;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=182;centre=98;} +# sund +"accum"={gribTablesVersionNo=128;indicatorOfParameter=189;centre=98;} +# lgws +"accum"={gribTablesVersionNo=128;indicatorOfParameter=195;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=195;centre=98;} +# mgws +"accum"={gribTablesVersionNo=128;indicatorOfParameter=196;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=196;centre=98;} +# gwd +"accum"={gribTablesVersionNo=128;indicatorOfParameter=197;centre=98;} +"accum"={gribTablesVersionNo=160;indicatorOfParameter=197;centre=98;} +# mx2t +"max"={gribTablesVersionNo=128;indicatorOfParameter=201;centre=98;} +"max"={gribTablesVersionNo=170;indicatorOfParameter=201;centre=98;} +"max"={gribTablesVersionNo=190;indicatorOfParameter=201;centre=98;} +# mn2t +"min"={gribTablesVersionNo=128;indicatorOfParameter=202;centre=98;} +"min"={gribTablesVersionNo=170;indicatorOfParameter=202;centre=98;} +"min"={gribTablesVersionNo=190;indicatorOfParameter=202;centre=98;} +# ro +"accum"={gribTablesVersionNo=128;indicatorOfParameter=205;centre=98;} +"accum"={gribTablesVersionNo=180;indicatorOfParameter=205;centre=98;} +# tsrc +"accum"={gribTablesVersionNo=128;indicatorOfParameter=208;centre=98;} +# ttrc +"accum"={gribTablesVersionNo=128;indicatorOfParameter=209;centre=98;} +# ssrc +"accum"={gribTablesVersionNo=128;indicatorOfParameter=210;centre=98;} +# strc +"accum"={gribTablesVersionNo=128;indicatorOfParameter=211;centre=98;} +# tisr +"accum"={gribTablesVersionNo=128;indicatorOfParameter=212;centre=98;} +# vimd +"accum"={gribTablesVersionNo=128;indicatorOfParameter=213;centre=98;} +# tp +"accum"={gribTablesVersionNo=160;indicatorOfParameter=228;centre=98;} +"accum"={gribTablesVersionNo=170;indicatorOfParameter=228;centre=98;} +"accum"={gribTablesVersionNo=190;indicatorOfParameter=228;centre=98;} +# csf +"accum"={gribTablesVersionNo=128;indicatorOfParameter=239;centre=98;} +# lsf +"accum"={gribTablesVersionNo=128;indicatorOfParameter=240;centre=98;} +# fdir +"accum"={gribTablesVersionNo=228;indicatorOfParameter=21;centre=98;} +# cdir +"accum"={gribTablesVersionNo=228;indicatorOfParameter=22;centre=98;} +# mx2t3 +"max"={gribTablesVersionNo=228;indicatorOfParameter=26;centre=98;} +# mn2t3 +"min"={gribTablesVersionNo=228;indicatorOfParameter=27;centre=98;} +# 10fg3 +"max"={gribTablesVersionNo=228;indicatorOfParameter=28;centre=98;} +# litota1 +"avg"={gribTablesVersionNo=228;indicatorOfParameter=51;centre=98;} +# licga1 +"avg"={gribTablesVersionNo=228;indicatorOfParameter=53;centre=98;} +# ssrdc +"accum"={gribTablesVersionNo=228;indicatorOfParameter=129;centre=98;} +# strdc +"accum"={gribTablesVersionNo=228;indicatorOfParameter=130;centre=98;} +# fzra +"accum"={gribTablesVersionNo=228;indicatorOfParameter=216;centre=98;} +# mxtpr +"max"={gribTablesVersionNo=228;indicatorOfParameter=226;centre=98;} +# mntpr +"min"={gribTablesVersionNo=228;indicatorOfParameter=227;centre=98;} +# pev +"accum"={gribTablesVersionNo=228;indicatorOfParameter=251;centre=98;} +# srta +"accum"={gribTablesVersionNo=162;indicatorOfParameter=100;centre=98;} +# trta +"accum"={gribTablesVersionNo=162;indicatorOfParameter=101;centre=98;} +# srtca +"accum"={gribTablesVersionNo=162;indicatorOfParameter=102;centre=98;} +# trtca +"accum"={gribTablesVersionNo=162;indicatorOfParameter=103;centre=98;} +# umfa +"accum"={gribTablesVersionNo=162;indicatorOfParameter=104;centre=98;} +# dmfa +"accum"={gribTablesVersionNo=162;indicatorOfParameter=105;centre=98;} +# udra +"accum"={gribTablesVersionNo=162;indicatorOfParameter=106;centre=98;} +# ddra +"accum"={gribTablesVersionNo=162;indicatorOfParameter=107;centre=98;} +# tpfa +"accum"={gribTablesVersionNo=162;indicatorOfParameter=108;centre=98;} +# tdcha +"accum"={gribTablesVersionNo=162;indicatorOfParameter=109;centre=98;} +# ttpha +"accum"={gribTablesVersionNo=162;indicatorOfParameter=110;centre=98;} +# qtpha +"accum"={gribTablesVersionNo=162;indicatorOfParameter=111;centre=98;} +# utpha +"accum"={gribTablesVersionNo=162;indicatorOfParameter=112;centre=98;} +# vtpha +"accum"={gribTablesVersionNo=162;indicatorOfParameter=113;centre=98;} +# mvv +"avg"={gribTablesVersionNo=130;indicatorOfParameter=232;centre=98;} +# msshfl +"avg"={gribTablesVersionNo=172;indicatorOfParameter=146;centre=98;} +# mslhfl +"avg"={gribTablesVersionNo=172;indicatorOfParameter=147;centre=98;} +# mean2t24 +"avg"={gribTablesVersionNo=128;indicatorOfParameter=55;centre=98;} +# mn2d24 +"avg"={gribTablesVersionNo=128;indicatorOfParameter=56;centre=98;} +# msdsrf +"avg"={gribTablesVersionNo=172;indicatorOfParameter=169;centre=98;} +# msdtrf +"avg"={gribTablesVersionNo=172;indicatorOfParameter=175;centre=98;} +# msnsrf +"avg"={gribTablesVersionNo=172;indicatorOfParameter=176;centre=98;} +# msntrf +"avg"={gribTablesVersionNo=172;indicatorOfParameter=177;centre=98;} +# mtnsrf +"avg"={gribTablesVersionNo=172;indicatorOfParameter=178;centre=98;} +# mtntrf +"avg"={gribTablesVersionNo=172;indicatorOfParameter=179;centre=98;} diff --git a/definitions/grib1/localConcepts/ecmf/units.def b/definitions/grib1/localConcepts/ecmf/units.def index c2c79b985..193a0e3c6 100644 --- a/definitions/grib1/localConcepts/ecmf/units.def +++ b/definitions/grib1/localConcepts/ecmf/units.def @@ -12659,7 +12659,7 @@ table2Version = 140 ; indicatorOfParameter = 217 ; } -#Maximum individual wave height +#Envelop-maximum individual wave height 'm' = { table2Version = 140 ; indicatorOfParameter = 218 ; @@ -13024,12 +13024,12 @@ table2Version = 151 ; indicatorOfParameter = 130 ; } -#Eastward sea water velocity +#Eastward surface sea water velocity 'm s**-1' = { table2Version = 151 ; indicatorOfParameter = 131 ; } -#Northward sea water velocity +#Northward surface sea water velocity 'm s**-1' = { table2Version = 151 ; indicatorOfParameter = 132 ; @@ -13244,7 +13244,7 @@ table2Version = 151 ; indicatorOfParameter = 174 ; } -#Average salinity in the upper 300m +#Average sea water practical salinity in the upper 300m 'psu' = { table2Version = 151 ; indicatorOfParameter = 175 ; diff --git a/definitions/grib1/localConcepts/rjtd/cfVarName.def b/definitions/grib1/localConcepts/rjtd/cfVarName.def index 5b95ee846..a41399122 100644 --- a/definitions/grib1/localConcepts/rjtd/cfVarName.def +++ b/definitions/grib1/localConcepts/rjtd/cfVarName.def @@ -665,16 +665,6 @@ table2Version = 200 ; indicatorOfParameter = 48 ; } -#U-component of current -'ucurr' = { - table2Version = 200 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'vcurr' = { - table2Version = 200 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio 'mixr' = { table2Version = 200 ; diff --git a/definitions/grib1/localConcepts/rjtd/name.def b/definitions/grib1/localConcepts/rjtd/name.def index 50010a10d..d23af9d8e 100644 --- a/definitions/grib1/localConcepts/rjtd/name.def +++ b/definitions/grib1/localConcepts/rjtd/name.def @@ -665,16 +665,6 @@ table2Version = 200 ; indicatorOfParameter = 48 ; } -#U-component of current -'U-component of current' = { - table2Version = 200 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'V-component of current' = { - table2Version = 200 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio 'Humidity mixing ratio' = { table2Version = 200 ; diff --git a/definitions/grib1/localConcepts/rjtd/paramId.def b/definitions/grib1/localConcepts/rjtd/paramId.def index 589e86e05..d08f41247 100644 --- a/definitions/grib1/localConcepts/rjtd/paramId.def +++ b/definitions/grib1/localConcepts/rjtd/paramId.def @@ -665,16 +665,6 @@ table2Version = 200 ; indicatorOfParameter = 48 ; } -#U-component of current -'3049' = { - table2Version = 200 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'3050' = { - table2Version = 200 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio '3053' = { table2Version = 200 ; diff --git a/definitions/grib1/localConcepts/rjtd/shortName.def b/definitions/grib1/localConcepts/rjtd/shortName.def index 109414b94..10b57b914 100644 --- a/definitions/grib1/localConcepts/rjtd/shortName.def +++ b/definitions/grib1/localConcepts/rjtd/shortName.def @@ -665,16 +665,6 @@ table2Version = 200 ; indicatorOfParameter = 48 ; } -#U-component of current -'ucurr' = { - table2Version = 200 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'vcurr' = { - table2Version = 200 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio 'mixr' = { table2Version = 200 ; diff --git a/definitions/grib1/localConcepts/rjtd/units.def b/definitions/grib1/localConcepts/rjtd/units.def index 93e7b0e56..05a2a7758 100644 --- a/definitions/grib1/localConcepts/rjtd/units.def +++ b/definitions/grib1/localConcepts/rjtd/units.def @@ -665,16 +665,6 @@ table2Version = 200 ; indicatorOfParameter = 48 ; } -#U-component of current -'m s**-1' = { - table2Version = 200 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'m s**-1' = { - table2Version = 200 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio 'kg kg**-1' = { table2Version = 200 ; diff --git a/definitions/grib1/name.def b/definitions/grib1/name.def index 7d9a3f84b..e7352f034 100644 --- a/definitions/grib1/name.def +++ b/definitions/grib1/name.def @@ -1148,36 +1148,6 @@ table2Version = 1 ; indicatorOfParameter = 48 ; } -#U-component of current -'U-component of current' = { - table2Version = 3 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'U-component of current' = { - table2Version = 2 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'U-component of current' = { - table2Version = 1 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'V-component of current' = { - table2Version = 3 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'V-component of current' = { - table2Version = 2 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'V-component of current' = { - table2Version = 1 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio 'Humidity mixing ratio' = { table2Version = 3 ; diff --git a/definitions/grib1/paramId.def b/definitions/grib1/paramId.def index f3031f392..425fa489d 100644 --- a/definitions/grib1/paramId.def +++ b/definitions/grib1/paramId.def @@ -1148,36 +1148,6 @@ table2Version = 1 ; indicatorOfParameter = 48 ; } -#U-component of current -'3049' = { - table2Version = 3 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'3049' = { - table2Version = 2 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'3049' = { - table2Version = 1 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'3050' = { - table2Version = 3 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'3050' = { - table2Version = 2 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'3050' = { - table2Version = 1 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio '3053' = { table2Version = 3 ; diff --git a/definitions/grib1/paramIdForConversion.def b/definitions/grib1/paramIdForConversion.def new file mode 100644 index 000000000..8cd3ea212 --- /dev/null +++ b/definitions/grib1/paramIdForConversion.def @@ -0,0 +1,3 @@ +# Concept paramIdForConversion +# See ECC-1806 +0 = {dummy=0;} diff --git a/definitions/grib1/scanning_mode.def b/definitions/grib1/scanning_mode.def index 31a56e27d..19a7f8167 100644 --- a/definitions/grib1/scanning_mode.def +++ b/definitions/grib1/scanning_mode.def @@ -9,8 +9,8 @@ flagbit jScansPositively(scanningMode,6) : dump; flagbit jPointsAreConsecutive(scanningMode,5) : dump; constant alternativeRowScanning=0 : dump; -transient iScansPositively = !iScansNegatively : constraint; -transient jScansNegatively = !jScansPositively : constraint; +transient iScansPositively = !iScansNegatively : constraint, read_only; +transient jScansNegatively = !jScansPositively : constraint, read_only; alias geography.iScansNegatively=iScansNegatively; alias geography.jScansPositively=jScansPositively; diff --git a/definitions/grib1/section.1.def b/definitions/grib1/section.1.def index 500b7de8f..d62300f27 100644 --- a/definitions/grib1/section.1.def +++ b/definitions/grib1/section.1.def @@ -313,7 +313,7 @@ alias time.stepType=stepType; # ECC-457: GRIB1 to GRIB2 conversion concept_nofail stepTypeForConversion (unknown, "stepTypeForConversion.def", conceptsDir2, conceptsDir1); -if (stepTypeForConversion is "accum" ) { +if (stepTypeForConversion is "accum" || stepTypeForConversion is "max" || stepTypeForConversion is "min" || stepTypeForConversion is "avg") { if (productDefinitionTemplateNumber == 1) { alias productDefinitionTemplateNumber=eleven; } @@ -325,3 +325,6 @@ if (stepTypeForConversion is "accum" ) { meta md5Section1 md5(offsetSection1,section1Length); # md5(start,length,blacklisted1,blacklisted2,...); meta md5Product md5(offsetSection1,section1Length,gridDefinition,section1Flags,decimalScaleFactor); + +# ECC-1806 +concept_nofail paramIdForConversion(zero, "paramIdForConversion.def", conceptsDir2, conceptsDir1) : long_type,read_only; diff --git a/definitions/grib1/shortName.def b/definitions/grib1/shortName.def index d78bf0d39..e2153ff94 100644 --- a/definitions/grib1/shortName.def +++ b/definitions/grib1/shortName.def @@ -1148,36 +1148,6 @@ table2Version = 1 ; indicatorOfParameter = 48 ; } -#U-component of current -'ucurr' = { - table2Version = 3 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'ucurr' = { - table2Version = 2 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'ucurr' = { - table2Version = 1 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'vcurr' = { - table2Version = 3 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'vcurr' = { - table2Version = 2 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'vcurr' = { - table2Version = 1 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio 'mixr' = { table2Version = 3 ; diff --git a/definitions/grib1/units.def b/definitions/grib1/units.def index a8a949696..4ad5faeaa 100644 --- a/definitions/grib1/units.def +++ b/definitions/grib1/units.def @@ -1148,36 +1148,6 @@ table2Version = 1 ; indicatorOfParameter = 48 ; } -#U-component of current -'m s**-1' = { - table2Version = 3 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'m s**-1' = { - table2Version = 2 ; - indicatorOfParameter = 49 ; - } -#U-component of current -'m s**-1' = { - table2Version = 1 ; - indicatorOfParameter = 49 ; - } -#V-component of current -'m s**-1' = { - table2Version = 3 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'m s**-1' = { - table2Version = 2 ; - indicatorOfParameter = 50 ; - } -#V-component of current -'m s**-1' = { - table2Version = 1 ; - indicatorOfParameter = 50 ; - } #Humidity mixing ratio 'kg kg**-1' = { table2Version = 3 ; diff --git a/definitions/grib2/boot.def b/definitions/grib2/boot.def index 4ed94b503..b92116397 100644 --- a/definitions/grib2/boot.def +++ b/definitions/grib2/boot.def @@ -11,7 +11,7 @@ # See https://community.wmo.int/activity-areas/wmo-codes/manual-codes/latest-version constant tablesVersionLatestOfficial = 32 : edition_specific; # If this is different from the official version, then it is the pre-operational version -constant tablesVersionLatest = 32 : edition_specific; +constant tablesVersionLatest = 33 : edition_specific; constant false = 0 : hidden; constant true = 1 : hidden; @@ -43,3 +43,16 @@ template core "grib2/sections.def"; #} template section_8 "grib2/section.8.def"; + +# ECC-1779: Add keys to identify experimental and deprecated templates +# The low-level transient keys template_is_XXX +# are set inside the template definition files +concept isTemplateDeprecated(false) { + 1 = { template_is_deprecated = 1; } +} +concept isTemplateExperimental(false) { + 1 = { template_is_experimental = 1; } +} + +# ECC-1806 +transient paramIdForConversion = 0; diff --git a/definitions/grib2/cfName.def b/definitions/grib2/cfName.def index 3ff5e57ac..a3105477e 100644 --- a/definitions/grib2/cfName.def +++ b/definitions/grib2/cfName.def @@ -343,20 +343,6 @@ parameterCategory = 1 ; parameterNumber = 10 ; } -#Eastward sea water velocity -'eastward_sea_water_velocity' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 2 ; - typeOfFirstFixedSurface = 160 ; - } -#Northward sea water velocity -'northward_sea_water_velocity' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 3 ; - typeOfFirstFixedSurface = 160 ; - } #Nitrogen dioxide mass mixing ratio 'mass_fraction_of_nitrogen_dioxide_in_air' = { discipline = 0 ; diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 889c839e3..d72793b3b 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -1239,12 +1239,6 @@ parameterCategory = 0 ; parameterNumber = 52 ; } -#Envelope-maximum individual wave height -'envhmax' = { - discipline = 10 ; - parameterCategory = 0 ; - parameterNumber = 93 ; - } #Time domain maximum individual crest height 'tdcmax' = { discipline = 10 ; @@ -1305,6 +1299,34 @@ parameterCategory = 0 ; parameterNumber = 84 ; } +#Time-mean mean zero-crossing wave period +'avg_mp2' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 28 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean significant height of combined wind waves and swell +'avg_swh' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 3 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean peak wave period +'avg_pp1d' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 34 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean mean wave period +'avg_mwp' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 15 ; + typeOfStatisticalProcessing = 0 ; + } #Mean sea water temperature in the upper 300 m 'mswt300m' = { discipline = 10 ; @@ -3786,6 +3808,71 @@ typeOfFirstFixedSurface = 187 ; typeOfSecondFixedSurface = 185 ; } +#Convective snowfall water equivalent +'csfwe' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 55 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Large-scale snowfall water equivalent +'lsfwe' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 56 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Lake surface temperature +'lslt' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + } +#Surface bulk Richardson number +'sbrn' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 16 ; + typeOfFirstFixedSurface = 1 ; + } +#Time-maximum 2 metre relative humidity +'mx2r' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 2 ; + } +#Time-minimum 2 metre relative humidity +'mn2r' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 3 ; + } +#Surface roughness for heat +'srhe' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 47 ; + typeOfFirstFixedSurface = 1 ; + } +#Surface roughness for moisture +'srmo' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 48 ; + typeOfFirstFixedSurface = 1 ; + } #Burned area 'fba' = { discipline = 2 ; @@ -4707,6 +4794,285 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean snow density +'avg_rsn' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 61 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low vegetation cover +'avg_cvl' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 53 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high vegetation cover +'avg_cvh' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 54 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean sea ice area fraction +'avg_ci' = { + discipline = 10 ; + parameterCategory = 2 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean sea surface temperature +'avg_sst' = { + discipline = 10 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean leaf area index, low vegetation +'avg_lai_lv' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 55 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean leaf area index, high vegetation +'avg_lai_hv' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 56 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total column liquid water +'avg_tclw' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 69 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total column cloud ice water +'avg_tciw' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 70 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 2 metre specific humidity +'avg_2sh' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean lake mix-layer temperature +'avg_lmlt' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 166 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean lake mix-layer depth +'avg_lmld' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 166 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 2 metre relative humidity +'avg_2r' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of snow cover +'avg_fscov' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 121 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil temperature +'avg_sot' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow depth +'avg_sde' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow cover +'avg_snowc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean geopotential +'avg_z' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean temperature +'avg_t' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean U component of wind +'avg_u' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean V component of wind +'avg_v' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific humidity +'avg_q' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean surface pressure +'avg_sp' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean vertical velocity +'avg_w' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total column water +'avg_tcw' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 51 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total column vertically-integrated water vapour +'avg_tcwv' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 64 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean mean sea level pressure +'avg_msl' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 101 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean relative humidity +'avg_r' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean boundary layer height +'avg_blh' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 10 metre U wind component +'avg_10u' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 10 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 10 metre V wind component +'avg_10v' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 10 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 2 metre dewpoint temperature +'avg_2d' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean temperature of snow layer +'avg_tsn' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 28 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast surface roughness +'avg_fsr' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast logarithm of surface roughness for heat +'avg_flsr' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 54 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'chcross' = { discipline = 1 ; @@ -6442,6 +6808,13 @@ parameterCategory = 3 ; parameterNumber = 19 ; } +#Leaf Area Index +'lai' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 28 ; + typeOfFirstFixedSurface = 1 ; + } #Accumulated surface upward short-wave radiation flux, clear sky 'auswrf_cs' = { discipline = 0 ; @@ -6795,6 +7168,48 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Standardised Precipitation Index (SPI) +'spi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 0 ; + } +#Standardised Precipitation Evapotranspiration Index (SPEI) +'spei' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 1 ; + } +#Standardised Streamflow Index (SSFI) +'ssfi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 2 ; + } +#Standardised Reservoir Supply Index (SRSI) +'srsi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 3 ; + } +#Standardised Water-level Index (SWI) +'swi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 4 ; + } +#Standardised Snowmelt and Rain Index (SMRI) +'smri' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 5 ; + } +#Streamflow Drought Index (SDI) +'sdi' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 6 ; + } #Universal thermal climate index 'utci' = { discipline = 20 ; @@ -9821,18 +10236,6 @@ parameterCategory = 2 ; parameterNumber = 16 ; } -#U-component of current -'ucurr' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 2 ; - } -#V-component of current -'vcurr' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 3 ; - } #Precipitable water 'pwat' = { discipline = 0 ; @@ -10007,11 +10410,11 @@ parameterCategory = 0 ; parameterNumber = 23 ; } -#Maximum individual wave height +#Envelop-maximum individual wave height 'hmax' = { discipline = 10 ; parameterCategory = 0 ; - parameterNumber = 24 ; + parameterNumber = 93 ; } #Model bathymetry 'wmb' = { @@ -10199,20 +10602,6 @@ parameterCategory = 0 ; parameterNumber = 44 ; } -#Eastward sea water velocity -'uoe' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 2 ; - typeOfFirstFixedSurface = 160 ; - } -#Northward sea water velocity -'von' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 3 ; - typeOfFirstFixedSurface = 160 ; - } #Skin reservoir content 'srcrea' = { discipline = 2 ; @@ -10518,6 +10907,16 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Mean of 10 metre wind speed +'mean10ws' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 10 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } #Lake total depth 'dl' = { discipline = 1 ; diff --git a/definitions/grib2/cfVarName.legacy.def b/definitions/grib2/cfVarName.legacy.def index 38c2868e6..40909c342 100644 --- a/definitions/grib2/cfVarName.legacy.def +++ b/definitions/grib2/cfVarName.legacy.def @@ -174,3 +174,9 @@ typeOfSecondFixedSurface = 168 ; typeOfStatisticalProcessing = 0 ; } +#Maximum individual wave height +'hmax' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 24 ; +} diff --git a/definitions/grib2/destine_activity.table b/definitions/grib2/destine_activity.table index 8217458fd..b7c3e8d86 100644 --- a/definitions/grib2/destine_activity.table +++ b/definitions/grib2/destine_activity.table @@ -2,4 +2,5 @@ 1 CMIP6 Coupled Model Intercomparison Project Phase 6 2 ScenarioMIP Scenario Model Intercomparison Project 3 HighResMIP High Resolution Model Intercomparison Project +4 story-nudging Climate storylines by nudging to reanalysis 65535 65535 Missing diff --git a/definitions/grib2/destine_experiment.table b/definitions/grib2/destine_experiment.table index d98a8dd70..864ef9260 100644 --- a/definitions/grib2/destine_experiment.table +++ b/definitions/grib2/destine_experiment.table @@ -7,4 +7,8 @@ 6 SSP2-4.5 Shared Socio-economic Pathways 2-4.5 7 SSP3-7.0 Shared Socio-economic Pathways 3-7.0 8 SSP5-8.5 Shared Socio-economic Pathways 5-8.5 +9 Tplus1.5K Warmer world at 1.5 degrees K above pre-industrial temperatures +10 Tplus2.0K Warmer world at 2.0 degrees K above pre-industrial temperatures +11 Tplus3.0K Warmer world at 3.0 degrees K above pre-industrial temperatures +12 Tplus4.0K Warmer world at 4.0 degrees K above pre-industrial temperatures 65535 65535 Missing diff --git a/definitions/grib2/grib2LocalSectionNumber.98.table b/definitions/grib2/grib2LocalSectionNumber.98.table index dcb8e84cd..26d0b1ec0 100644 --- a/definitions/grib2/grib2LocalSectionNumber.98.table +++ b/definitions/grib2/grib2LocalSectionNumber.98.table @@ -21,6 +21,7 @@ 39 39 4DVar model errors for long window 4Dvar system 41 41 The Flood Awareness System 42 42 Lead Centre for Wave Forecast Verification +43 43 EERIE project MARS labelling 60 60 Ocean data analysis date and analysis time 192 192 Multiple ECMWF local definitions 300 300 Multi-dimensional parameters (deprecated) diff --git a/definitions/grib2/local.98.28.def b/definitions/grib2/local.98.28.def index eeb30d063..cf801b6fc 100644 --- a/definitions/grib2/local.98.28.def +++ b/definitions/grib2/local.98.28.def @@ -1,4 +1,6 @@ -# Local Definition 28 - COSMO local area EPS +# (C) Copyright 2005- ECMWF. + +# Local definition 28 - COSMO local area EPS unsigned[4] baseDateEPS : dump; unsigned[2] baseTimeEPS : dump; diff --git a/definitions/grib2/local.98.42.def b/definitions/grib2/local.98.42.def index 1bb73af47..48b891ed9 100644 --- a/definitions/grib2/local.98.42.def +++ b/definitions/grib2/local.98.42.def @@ -1,6 +1,6 @@ # (C) Copyright 2005- ECMWF. -# Definition 42 - WMO Lead Centre for Wave Forecast Verification (LC-WFV) +# Local definition 42 - WMO Lead Centre for Wave Forecast Verification (LC-WFV) codetable[2] lcwfvSuiteName "grib2/lcwfv_suiteName.table" : dump; alias mars.origin = lcwfvSuiteName; diff --git a/definitions/grib2/local.98.43.def b/definitions/grib2/local.98.43.def new file mode 100644 index 000000000..3728cd185 --- /dev/null +++ b/definitions/grib2/local.98.43.def @@ -0,0 +1,21 @@ +# (C) Copyright 2005- ECMWF. + +# Local definition 43 - Class ed EERIE project climate keywords + +# CMIP related activity keyword +codetable[2] activity "grib2/destine_activity.table" ; +alias mars.activity = activity; + +# CMIP related experiment keyword +codetable[2] experiment "grib2/destine_experiment.table" ; +alias mars.experiment = experiment; + +# Climate run realization keyword, which relates to an initial condition perturbation +unsigned[1] realization = 255 ; +alias mars.realization = realization; + +# Remove mars domain from this data +unalias mars.domain; + +# Add some padding just in case we want more keys in the future +pad padding_loc43(30); diff --git a/definitions/grib2/localConcepts/cerise/cfName.def b/definitions/grib2/localConcepts/cerise/cfName.def new file mode 100644 index 000000000..741709b44 --- /dev/null +++ b/definitions/grib2/localConcepts/cerise/cfName.def @@ -0,0 +1,53 @@ +# Automatically generated by ./create_def.pl, do not edit +#Snow depth +'lwe_thickness_of_surface_snow_amount' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + } +#Large-scale precipitation +'lwe_thickness_of_stratiform_precipitation_amount' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Convective precipitation +'lwe_thickness_of_convective_precipitation_amount' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Snowfall +'lwe_thickness_of_snowfall_amount' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Total cloud cover +'cloud_area_fraction' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Evaporation +'lwe_thickness_of_water_evaporation_amount' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; +} diff --git a/definitions/grib2/localConcepts/cerise/cfVarName.def b/definitions/grib2/localConcepts/cerise/cfVarName.def index 7861181b1..dfb69cc17 100644 --- a/definitions/grib2/localConcepts/cerise/cfVarName.def +++ b/definitions/grib2/localConcepts/cerise/cfVarName.def @@ -1,4 +1,130 @@ # Automatically generated by ./create_def.pl, do not edit +#Surface runoff +'sro' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Sub-surface runoff +'ssro' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Maximum temperature at 2 metres in the last 24 hours +'mx2t24' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 2 ; + lengthOfTimeRange = 24 ; + } +#Minimum temperature at 2 metres in the last 24 hours +'mn2t24' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 3 ; + lengthOfTimeRange = 24 ; + } +#Snow depth +'sd' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + } +#Large-scale precipitation +'lsp' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Convective precipitation +'cp' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Snowfall +'sf' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Total cloud cover +'tcc' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Evaporation +'e' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Low cloud cover +'lcc' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + } +#Runoff +'ro' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfStatisticalProcessing = 1 ; + } +#Total precipitation +'tp' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Forecast albedo +'fal' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + } #Mean surface runoff rate 'msror' = { localTablesVersion = 1 ; @@ -17,6 +143,73 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Potential evaporation +'pev' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Time-mean snow depth +'avg_sd_m' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'avg_lcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'avg_mcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'avg_hcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'avg_fal_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean large-scale precipitation rate +'mlsprt' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean convective precipitation rate +'cprate' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total snowfall rate 'mtsfr' = { localTablesVersion = 1 ; @@ -35,6 +228,15 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Mean runoff rate +'mrort' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total precipitation rate 'tprate' = { localTablesVersion = 1 ; @@ -43,4 +245,14 @@ parameterNumber = 193 ; typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; + } +#Mean total cloud cover +'meantcc' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/cerise/name.def b/definitions/grib2/localConcepts/cerise/name.def index 7fb9dff6c..cac36cdea 100644 --- a/definitions/grib2/localConcepts/cerise/name.def +++ b/definitions/grib2/localConcepts/cerise/name.def @@ -1,4 +1,130 @@ # Automatically generated by ./create_def.pl, do not edit +#Surface runoff +'Surface runoff' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Sub-surface runoff +'Sub-surface runoff' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Maximum temperature at 2 metres in the last 24 hours +'Maximum temperature at 2 metres in the last 24 hours' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 2 ; + lengthOfTimeRange = 24 ; + } +#Minimum temperature at 2 metres in the last 24 hours +'Minimum temperature at 2 metres in the last 24 hours' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 3 ; + lengthOfTimeRange = 24 ; + } +#Snow depth +'Snow depth' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + } +#Large-scale precipitation +'Large-scale precipitation' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Convective precipitation +'Convective precipitation' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Snowfall +'Snowfall' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Total cloud cover +'Total cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Evaporation +'Evaporation' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Low cloud cover +'Low cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + } +#Runoff +'Runoff' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfStatisticalProcessing = 1 ; + } +#Total precipitation +'Total precipitation' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Forecast albedo +'Forecast albedo' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + } #Mean surface runoff rate 'Mean surface runoff rate' = { localTablesVersion = 1 ; @@ -17,6 +143,73 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Potential evaporation +'Potential evaporation' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Time-mean snow depth +'Time-mean snow depth' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'Time-mean low cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'Time-mean medium cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'Time-mean high cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'Time-mean forecast albedo' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean large-scale precipitation rate +'Mean large-scale precipitation rate' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean convective precipitation rate +'Mean convective precipitation rate' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total snowfall rate 'Mean total snowfall rate' = { localTablesVersion = 1 ; @@ -35,6 +228,15 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Mean runoff rate +'Mean runoff rate' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total precipitation rate 'Mean total precipitation rate' = { localTablesVersion = 1 ; @@ -43,4 +245,14 @@ parameterNumber = 193 ; typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; + } +#Mean total cloud cover +'Mean total cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/cerise/paramId.def b/definitions/grib2/localConcepts/cerise/paramId.def index f905e10e0..c4af1e971 100644 --- a/definitions/grib2/localConcepts/cerise/paramId.def +++ b/definitions/grib2/localConcepts/cerise/paramId.def @@ -1,4 +1,130 @@ # Automatically generated by ./create_def.pl, do not edit +#Surface runoff +'8' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Sub-surface runoff +'9' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Maximum temperature at 2 metres in the last 24 hours +'51' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 2 ; + lengthOfTimeRange = 24 ; + } +#Minimum temperature at 2 metres in the last 24 hours +'52' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 3 ; + lengthOfTimeRange = 24 ; + } +#Snow depth +'141' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + } +#Large-scale precipitation +'142' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Convective precipitation +'143' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Snowfall +'144' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Total cloud cover +'164' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Evaporation +'182' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Low cloud cover +'186' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + } +#Runoff +'205' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfStatisticalProcessing = 1 ; + } +#Total precipitation +'228' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Forecast albedo +'243' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + } #Mean surface runoff rate '172008' = { localTablesVersion = 1 ; @@ -17,6 +143,73 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Potential evaporation +'228251' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Time-mean snow depth +'235141' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'235186' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'235187' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'235188' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'235243' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean large-scale precipitation rate +'172142' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean convective precipitation rate +'172143' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total snowfall rate '172144' = { localTablesVersion = 1 ; @@ -35,6 +228,15 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Mean runoff rate +'172205' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total precipitation rate '172228' = { localTablesVersion = 1 ; @@ -43,4 +245,14 @@ parameterNumber = 193 ; typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; + } +#Mean total cloud cover +'228006' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/cerise/shortName.def b/definitions/grib2/localConcepts/cerise/shortName.def index 7861181b1..dfb69cc17 100644 --- a/definitions/grib2/localConcepts/cerise/shortName.def +++ b/definitions/grib2/localConcepts/cerise/shortName.def @@ -1,4 +1,130 @@ # Automatically generated by ./create_def.pl, do not edit +#Surface runoff +'sro' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Sub-surface runoff +'ssro' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Maximum temperature at 2 metres in the last 24 hours +'mx2t24' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 2 ; + lengthOfTimeRange = 24 ; + } +#Minimum temperature at 2 metres in the last 24 hours +'mn2t24' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 3 ; + lengthOfTimeRange = 24 ; + } +#Snow depth +'sd' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + } +#Large-scale precipitation +'lsp' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Convective precipitation +'cp' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Snowfall +'sf' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Total cloud cover +'tcc' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Evaporation +'e' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Low cloud cover +'lcc' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + } +#Runoff +'ro' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfStatisticalProcessing = 1 ; + } +#Total precipitation +'tp' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Forecast albedo +'fal' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + } #Mean surface runoff rate 'msror' = { localTablesVersion = 1 ; @@ -17,6 +143,73 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Potential evaporation +'pev' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Time-mean snow depth +'avg_sd_m' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'avg_lcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'avg_mcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'avg_hcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'avg_fal_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean large-scale precipitation rate +'mlsprt' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean convective precipitation rate +'cprate' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total snowfall rate 'mtsfr' = { localTablesVersion = 1 ; @@ -35,6 +228,15 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Mean runoff rate +'mrort' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total precipitation rate 'tprate' = { localTablesVersion = 1 ; @@ -43,4 +245,14 @@ parameterNumber = 193 ; typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; + } +#Mean total cloud cover +'meantcc' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/cerise/units.def b/definitions/grib2/localConcepts/cerise/units.def index 36ab79310..afc663307 100644 --- a/definitions/grib2/localConcepts/cerise/units.def +++ b/definitions/grib2/localConcepts/cerise/units.def @@ -1,4 +1,130 @@ # Automatically generated by ./create_def.pl, do not edit +#Surface runoff +'m' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Sub-surface runoff +'m' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Maximum temperature at 2 metres in the last 24 hours +'K' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 2 ; + lengthOfTimeRange = 24 ; + } +#Minimum temperature at 2 metres in the last 24 hours +'K' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + indicatorOfUnitForTimeRange = 1 ; + typeOfStatisticalProcessing = 3 ; + lengthOfTimeRange = 24 ; + } +#Snow depth +'m of water equivalent' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + } +#Large-scale precipitation +'m' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Convective precipitation +'m' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Snowfall +'m of water equivalent' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Total cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + } +#Evaporation +'m of water equivalent' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Low cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + } +#Runoff +'m' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfStatisticalProcessing = 1 ; + } +#Total precipitation +'m' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 1 ; + } +#Forecast albedo +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + } #Mean surface runoff rate 'm s**-1' = { localTablesVersion = 1 ; @@ -17,6 +143,73 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Potential evaporation +'m' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 200 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Time-mean snow depth +'m of water equivalent' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean large-scale precipitation rate +'m s**-1' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean convective precipitation rate +'m s**-1' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total snowfall rate 'm of water equivalent s**-1' = { localTablesVersion = 1 ; @@ -35,6 +228,15 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Mean runoff rate +'m s**-1' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Mean total precipitation rate 'm s**-1' = { localTablesVersion = 1 ; @@ -43,4 +245,14 @@ parameterNumber = 193 ; typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; + } +#Mean total cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } diff --git a/definitions/grib2/localConcepts/ecmf/cfName.def b/definitions/grib2/localConcepts/ecmf/cfName.def index f32ddc9a7..2ef70fa76 100644 --- a/definitions/grib2/localConcepts/ecmf/cfName.def +++ b/definitions/grib2/localConcepts/ecmf/cfName.def @@ -476,48 +476,12 @@ parameterCategory = 218 ; parameterNumber = 200 ; } -#Sea water potential temperature -'sea_water_potential_temperature' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 129 ; - } -#Sea water practical salinity -'sea_water_practical_salinity' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 130 ; - } -#Upward sea water velocity -'upward_sea_water_velocity' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 133 ; - } -#Sea water sigma theta -'sea_water_sigma_theta' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 138 ; - } #Ocean barotropic stream function 'ocean_barotropic_streamfunction' = { discipline = 192 ; parameterCategory = 151 ; parameterNumber = 147 ; } -#Surface downward eastward stress -'surface_downward_eastward_stress' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 153 ; - } -#Surface downward northward stress -'surface_downward_northward_stress' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 154 ; - } #Carbon dioxide mass mixing ratio 'mass_fraction_of_carbon_dioxide_in_air' = { discipline = 192 ; diff --git a/definitions/grib2/localConcepts/ecmf/cfName.legacy.def b/definitions/grib2/localConcepts/ecmf/cfName.legacy.def index e3b2b9750..b343a5b2c 100644 --- a/definitions/grib2/localConcepts/ecmf/cfName.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/cfName.legacy.def @@ -148,3 +148,39 @@ parameterCategory = 128 ; parameterNumber = 206 ; } +#Sea water potential temperature +'sea_water_potential_temperature' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; +} +#Sea water practical salinity +'sea_water_practical_salinity' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; +} +#Upward sea water velocity +'upward_sea_water_velocity' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; +} +#Sea water sigma theta +'sea_water_sigma_theta' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; +} +#Surface downward eastward stress +'surface_downward_eastward_stress' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; +} +#Surface downward northward stress +'surface_downward_northward_stress' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.def b/definitions/grib2/localConcepts/ecmf/cfVarName.def index 9e62226b7..7efe686a0 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.def @@ -224,18 +224,6 @@ typeOfStatisticalProcessing = 3 ; lengthOfTimeRange = 24 ; } -#Mean temperature at 2 metres in the last 24 hours -'mean2t24' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours -'mn2d24' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 56 ; - } #Observation count 'obct' = { discipline = 192 ; @@ -2579,6 +2567,24 @@ parameterCategory = 171 ; parameterNumber = 122 ; } +#Mean surface runoff rate +'msror' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean sub-surface runoff rate +'mssror' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Volcanic ash aerosol mixing ratio 'aermr13' = { discipline = 192 ; @@ -13825,6 +13831,46 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Time-mean snow depth +'avg_sd_m' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'avg_lcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'avg_mcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'avg_hcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'avg_fal_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } #Covariance between 2-metre temperature and volumetric soil water layer 1 'covar_t2m_swvl1' = { localTablesVersion = 1 ; @@ -14385,18 +14431,6 @@ parameterCategory = 129 ; parameterNumber = 54 ; } -#Mean 2 metre temperature in the last 24 hours gradient -'mean2t24grd' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours gradient -'mn2d24grd' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 56 ; - } #Downward UV radiation at the surface gradient 'uvbgrd' = { discipline = 192 ; @@ -15669,12 +15703,6 @@ parameterCategory = 130 ; parameterNumber = 231 ; } -#Mean vertical velocity -'mvv' = { - discipline = 192 ; - parameterCategory = 130 ; - parameterNumber = 232 ; - } #2m temperature anomaly of at least +2K 't2ag2' = { discipline = 192 ; @@ -16573,30 +16601,6 @@ parameterCategory = 140 ; parameterNumber = 200 ; } -#Standard deviation wave height -'sdhs' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 240 ; - } -#Mean of 10 metre wind speed -'mu10' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 241 ; - } -#Mean wind direction -'mdwi' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 242 ; - } -#Standard deviation of 10 metre wind speed -'sdu' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 243 ; - } #2D wave spectra (multiple) 'd2sp' = { discipline = 192 ; @@ -16813,24 +16817,6 @@ parameterCategory = 151 ; parameterNumber = 128 ; } -#Sea water potential temperature -'thetao' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 129 ; - } -#Sea water practical salinity -'so' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 130 ; - } -#Upward sea water velocity -'wo' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 133 ; - } #Modulus of strain rate tensor 'mst' = { discipline = 192 ; @@ -16855,12 +16841,6 @@ parameterCategory = 151 ; parameterNumber = 137 ; } -#Sea water sigma theta -'sigmat' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 138 ; - } #Richardson number 'rn' = { discipline = 192 ; @@ -16933,18 +16913,6 @@ parameterCategory = 151 ; parameterNumber = 152 ; } -#Surface downward eastward stress -'taueo' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 153 ; - } -#Surface downward northward stress -'tauno' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 154 ; - } #Turbulent kinetic energy input 'tki' = { discipline = 192 ; @@ -17545,198 +17513,6 @@ parameterCategory = 160 ; parameterNumber = 254 ; } -#Surface geopotential -'p51.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 51 ; - } -#Vertical integral of temperature -'vit' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 54 ; - } -#Vertical integral of cloud liquid water -'vilw' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 56 ; - } -#Vertical integral of cloud frozen water -'viiw' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 57 ; - } -#Vertical integral of ozone -'vioz' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 58 ; - } -#Vertical integral of energy conversion -'viec' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 64 ; - } -#Vertical integral of eastward mass flux -'vimae' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 65 ; - } -#Vertical integral of northward mass flux -'viman' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 66 ; - } -#Vertical integral of eastward kinetic energy flux -'vikee' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 67 ; - } -#Vertical integral of northward kinetic energy flux -'viken' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 68 ; - } -#Vertical integral of eastward geopotential flux -'vige' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 73 ; - } -#Vertical integral of northward geopotential flux -'vign' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 74 ; - } -#Vertical integral of eastward total energy flux -'vitoee' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 75 ; - } -#Vertical integral of northward total energy flux -'vitoen' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 76 ; - } -#Vertical integral of eastward ozone flux -'vioze' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 77 ; - } -#Vertical integral of northward ozone flux -'viozn' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 78 ; - } -#Vertical integral of divergence of mass flux -'vimad' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 81 ; - } -#Vertical integral of divergence of kinetic energy flux -'viked' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 82 ; - } -#Vertical integral of divergence of thermal energy flux -'vithed' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 83 ; - } -#Vertical integral of divergence of geopotential flux -'vigd' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 85 ; - } -#Vertical integral of divergence of total energy flux -'vitoed' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 86 ; - } -#Vertical integral of divergence of ozone flux -'viozd' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 87 ; - } -#Variance of geopotential -'p206.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 206 ; - } -#Covariance of geopotential/temperature -'p207.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 207 ; - } -#Variance of temperature -'p208.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 208 ; - } -#Covariance of geopotential/specific humidity -'p209.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 209 ; - } -#Covariance of temperature/specific humidity -'p210.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 210 ; - } -#Variance of specific humidity -'p211.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 211 ; - } -#Covariance of u component/geopotential -'p212.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 212 ; - } -#Covariance of u component/temperature -'p213.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 213 ; - } -#Covariance of u component/specific humidity -'p214.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 214 ; - } -#Variance of u component -'p215.162' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 215 ; - } #Covariance of v component/geopotential 'p216.162' = { discipline = 192 ; @@ -18987,21 +18763,30 @@ } #Mean large-scale precipitation rate 'mlsprt' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 142 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean convective precipitation rate 'cprate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 143 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total snowfall rate 'mtsfr' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 144 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Boundary layer dissipation 'bldrate' = { @@ -19009,18 +18794,6 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Mean surface sensible heat flux -'msshfl' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 146 ; - } -#Mean surface latent heat flux -'mslhfl' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 147 ; - } #Mean short-wave heating rate 'mswhr' = { discipline = 192 ; @@ -19033,59 +18806,14 @@ parameterCategory = 172 ; parameterNumber = 154 ; } -#Mean surface downward solar radiation flux -'msdsrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 169 ; - } -#Mean surface downward thermal radiation flux -'msdtrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 175 ; - } -#Mean surface net solar radiation flux -'msnsrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 176 ; - } -#Mean surface net thermal radiation flux -'msntrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 177 ; - } -#Mean top net solar radiation flux -'mtnsrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 178 ; - } -#Mean top net thermal radiation flux -'mtntrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 179 ; - } -#East-West surface stress rate of accumulation -'ewssra' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 180 ; - } -#North-South surface stress rate of accumulation -'nsssra' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 181 ; - } #Evaporation 'erate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 182 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean sunshine duration rate 'msdr' = { @@ -19113,45 +18841,21 @@ } #Mean runoff rate 'mrort' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 205 ; - } -#Top net solar radiation, clear sky -'p208.172' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 208 ; - } -#Top net thermal radiation, clear sky -'p209.172' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 209 ; - } -#Surface net solar radiation, clear sky -'p210.172' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'p211.172' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 211 ; - } -#Solar insolation rate of accumulation -'soira' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 212 ; + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total precipitation rate 'tprate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 228 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Convective snowfall 'p239.172' = { @@ -21841,17 +21545,15 @@ parameterCategory = 220 ; parameterNumber = 228 ; } -#Mean of 10 metre wind speed -'mean10ws' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 5 ; - } #Mean total cloud cover 'meantcc' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 6 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } #Surface temperature significance 'sts' = { diff --git a/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def b/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def index ab4af4326..c1c9099b5 100644 --- a/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/cfVarName.legacy.def @@ -1369,3 +1369,405 @@ parameterCategory = 172 ; parameterNumber = 228 ; } +#Mean large-scale precipitation rate +'mlsprt' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 142 ; +} +#Mean convective precipitation rate +'cprate' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 143 ; +} +#Mean runoff rate +'mrort' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 205 ; +} +#Mean total cloud cover +'meantcc' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 6 ; +} +#Mean of 10 metre wind speed +'mean10ws' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 5 ; +} +#Sea water potential temperature +'thetao' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; +} +#Sea water practical salinity +'so' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; +} +#Upward sea water velocity +'wo' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; +} +#Sea water sigma theta +'sigmat' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; +} +#Surface downward eastward stress +'taueo' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; +} +#Surface downward northward stress +'tauno' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; +} +#Surface geopotential +'p51.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; +} +#Vertical integral of temperature +'vit' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; +} +#Vertical integral of cloud liquid water +'vilw' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; +} +#Vertical integral of cloud frozen water +'viiw' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; +} +#Vertical integral of ozone +'vioz' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; +} +#Vertical integral of energy conversion +'viec' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; +} +#Vertical integral of eastward mass flux +'vimae' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; +} +#Vertical integral of northward mass flux +'viman' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; +} +#Vertical integral of eastward kinetic energy flux +'vikee' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; +} +#Vertical integral of northward kinetic energy flux +'viken' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; +} +#Vertical integral of eastward geopotential flux +'vige' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; +} +#Vertical integral of northward geopotential flux +'vign' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; +} +#Vertical integral of eastward total energy flux +'vitoee' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; +} +#Vertical integral of northward total energy flux +'vitoen' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; +} +#Vertical integral of eastward ozone flux +'vioze' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; +} +#Vertical integral of northward ozone flux +'viozn' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; +} +#Vertical integral of divergence of mass flux +'vimad' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; +} +#Vertical integral of divergence of kinetic energy flux +'viked' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; +} +#Vertical integral of divergence of thermal energy flux +'vithed' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; +} +#Vertical integral of divergence of geopotential flux +'vigd' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; +} +#Vertical integral of divergence of total energy flux +'vitoed' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; +} +#Vertical integral of divergence of ozone flux +'viozd' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; +} +#Variance of geopotential +'p206.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; +} +#Covariance of geopotential/temperature +'p207.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; +} +#Variance of temperature +'p208.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; +} +#Covariance of geopotential/specific humidity +'p209.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; +} +#Covariance of temperature/specific humidity +'p210.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; +} +#Variance of specific humidity +'p211.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; +} +#Covariance of u component/geopotential +'p212.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; +} +#Covariance of u component/temperature +'p213.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; +} +#Covariance of u component/specific humidity +'p214.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; +} +#Variance of u component +'p215.162' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} +#Mean vertical velocity +'mvv' = { + discipline = 192 ; + parameterCategory = 130 ; + parameterNumber = 232 ; +} +#Mean surface sensible heat flux +'msshfl' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 146 ; +} +#Mean surface latent heat flux +'mslhfl' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 147 ; +} +#Mean temperature at 2 metres in the last 24 hours +'mean2t24' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 55 ; +} +#Mean 2 metre temperature in the last 24 hours gradient +'mean2t24grd' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 55 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours +'mn2d24' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 56 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours gradient +'mn2d24grd' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 56 ; +} +#Mean surface downward solar radiation flux +'msdsrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 169 ; +} +#Mean surface downward thermal radiation flux +'msdtrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 175 ; +} +#Mean surface net solar radiation flux +'msnsrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 176 ; +} +#Mean surface net thermal radiation flux +'msntrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 177 ; +} +#Mean top net solar radiation flux +'mtnsrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 178 ; +} +#Mean top net thermal radiation flux +'mtntrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 179 ; +} +#East-West surface stress rate of accumulation +'ewssra' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 180 ; +} +#North-South surface stress rate of accumulation +'nsssra' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 181 ; +} +#Standard deviation wave height +'sdhs' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 240 ; +} +#Mean of 10 metre wind speed +'mu10' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 241 ; +} +#Mean wind direction +'mdwi' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 242 ; +} +#Standard deviation of 10 metre wind speed +'sdu' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 243 ; +} +#Top net solar radiation, clear sky +'p208.172' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 208 ; +} +#Top net thermal radiation, clear sky +'p209.172' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 209 ; +} +#Surface net solar radiation, clear sky +'p210.172' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 210 ; +} +#Surface net thermal radiation, clear sky +'p211.172' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 211 ; +} +#Solar insolation rate of accumulation +'soira' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 212 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/name.def b/definitions/grib2/localConcepts/ecmf/name.def index 30466e4c5..c5d77647c 100644 --- a/definitions/grib2/localConcepts/ecmf/name.def +++ b/definitions/grib2/localConcepts/ecmf/name.def @@ -224,18 +224,6 @@ typeOfStatisticalProcessing = 3 ; lengthOfTimeRange = 24 ; } -#Mean temperature at 2 metres in the last 24 hours -'Mean temperature at 2 metres in the last 24 hours' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours -'Mean 2 metre dewpoint temperature in the last 24 hours' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 56 ; - } #Observation count 'Observation count' = { discipline = 192 ; @@ -2579,6 +2567,24 @@ parameterCategory = 171 ; parameterNumber = 122 ; } +#Mean surface runoff rate +'Mean surface runoff rate' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean sub-surface runoff rate +'Mean sub-surface runoff rate' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Volcanic ash aerosol mixing ratio 'Volcanic ash aerosol mixing ratio' = { discipline = 192 ; @@ -13825,6 +13831,46 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Time-mean snow depth +'Time-mean snow depth' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'Time-mean low cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'Time-mean medium cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'Time-mean high cloud cover' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'Time-mean forecast albedo' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } #Covariance between 2-metre temperature and volumetric soil water layer 1 'Covariance between 2-metre temperature and volumetric soil water layer 1' = { localTablesVersion = 1 ; @@ -14385,18 +14431,6 @@ parameterCategory = 129 ; parameterNumber = 54 ; } -#Mean 2 metre temperature in the last 24 hours gradient -'Mean 2 metre temperature in the last 24 hours gradient' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours gradient -'Mean 2 metre dewpoint temperature in the last 24 hours gradient' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 56 ; - } #Downward UV radiation at the surface gradient 'Downward UV radiation at the surface gradient' = { discipline = 192 ; @@ -15669,12 +15703,6 @@ parameterCategory = 130 ; parameterNumber = 231 ; } -#Mean vertical velocity -'Mean vertical velocity' = { - discipline = 192 ; - parameterCategory = 130 ; - parameterNumber = 232 ; - } #2m temperature anomaly of at least +2K '2m temperature anomaly of at least +2K' = { discipline = 192 ; @@ -16573,30 +16601,6 @@ parameterCategory = 140 ; parameterNumber = 200 ; } -#Standard deviation wave height -'Standard deviation wave height' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 240 ; - } -#Mean of 10 metre wind speed -'Mean of 10 metre wind speed' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 241 ; - } -#Mean wind direction -'Mean wind direction' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 242 ; - } -#Standard deviation of 10 metre wind speed -'Standard deviation of 10 metre wind speed' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 243 ; - } #2D wave spectra (multiple) '2D wave spectra (multiple)' = { discipline = 192 ; @@ -16813,24 +16817,6 @@ parameterCategory = 151 ; parameterNumber = 128 ; } -#Sea water potential temperature -'Sea water potential temperature' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 129 ; - } -#Sea water practical salinity -'Sea water practical salinity' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 130 ; - } -#Upward sea water velocity -'Upward sea water velocity' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 133 ; - } #Modulus of strain rate tensor 'Modulus of strain rate tensor' = { discipline = 192 ; @@ -16855,12 +16841,6 @@ parameterCategory = 151 ; parameterNumber = 137 ; } -#Sea water sigma theta -'Sea water sigma theta' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 138 ; - } #Richardson number 'Richardson number' = { discipline = 192 ; @@ -16933,18 +16913,6 @@ parameterCategory = 151 ; parameterNumber = 152 ; } -#Surface downward eastward stress -'Surface downward eastward stress' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 153 ; - } -#Surface downward northward stress -'Surface downward northward stress' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 154 ; - } #Turbulent kinetic energy input 'Turbulent kinetic energy input' = { discipline = 192 ; @@ -17545,198 +17513,6 @@ parameterCategory = 160 ; parameterNumber = 254 ; } -#Surface geopotential -'Surface geopotential' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 51 ; - } -#Vertical integral of temperature -'Vertical integral of temperature' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 54 ; - } -#Vertical integral of cloud liquid water -'Vertical integral of cloud liquid water' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 56 ; - } -#Vertical integral of cloud frozen water -'Vertical integral of cloud frozen water' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 57 ; - } -#Vertical integral of ozone -'Vertical integral of ozone' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 58 ; - } -#Vertical integral of energy conversion -'Vertical integral of energy conversion' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 64 ; - } -#Vertical integral of eastward mass flux -'Vertical integral of eastward mass flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 65 ; - } -#Vertical integral of northward mass flux -'Vertical integral of northward mass flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 66 ; - } -#Vertical integral of eastward kinetic energy flux -'Vertical integral of eastward kinetic energy flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 67 ; - } -#Vertical integral of northward kinetic energy flux -'Vertical integral of northward kinetic energy flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 68 ; - } -#Vertical integral of eastward geopotential flux -'Vertical integral of eastward geopotential flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 73 ; - } -#Vertical integral of northward geopotential flux -'Vertical integral of northward geopotential flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 74 ; - } -#Vertical integral of eastward total energy flux -'Vertical integral of eastward total energy flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 75 ; - } -#Vertical integral of northward total energy flux -'Vertical integral of northward total energy flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 76 ; - } -#Vertical integral of eastward ozone flux -'Vertical integral of eastward ozone flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 77 ; - } -#Vertical integral of northward ozone flux -'Vertical integral of northward ozone flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 78 ; - } -#Vertical integral of divergence of mass flux -'Vertical integral of divergence of mass flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 81 ; - } -#Vertical integral of divergence of kinetic energy flux -'Vertical integral of divergence of kinetic energy flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 82 ; - } -#Vertical integral of divergence of thermal energy flux -'Vertical integral of divergence of thermal energy flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 83 ; - } -#Vertical integral of divergence of geopotential flux -'Vertical integral of divergence of geopotential flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 85 ; - } -#Vertical integral of divergence of total energy flux -'Vertical integral of divergence of total energy flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 86 ; - } -#Vertical integral of divergence of ozone flux -'Vertical integral of divergence of ozone flux' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 87 ; - } -#Variance of geopotential -'Variance of geopotential' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 206 ; - } -#Covariance of geopotential/temperature -'Covariance of geopotential/temperature' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 207 ; - } -#Variance of temperature -'Variance of temperature' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 208 ; - } -#Covariance of geopotential/specific humidity -'Covariance of geopotential/specific humidity' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 209 ; - } -#Covariance of temperature/specific humidity -'Covariance of temperature/specific humidity' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 210 ; - } -#Variance of specific humidity -'Variance of specific humidity' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 211 ; - } -#Covariance of u component/geopotential -'Covariance of u component/geopotential' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 212 ; - } -#Covariance of u component/temperature -'Covariance of u component/temperature' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 213 ; - } -#Covariance of u component/specific humidity -'Covariance of u component/specific humidity' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 214 ; - } -#Variance of u component -'Variance of u component' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 215 ; - } #Covariance of v component/geopotential 'Covariance of v component/geopotential' = { discipline = 192 ; @@ -18987,21 +18763,30 @@ } #Mean large-scale precipitation rate 'Mean large-scale precipitation rate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 142 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean convective precipitation rate 'Mean convective precipitation rate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 143 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total snowfall rate 'Mean total snowfall rate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 144 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Boundary layer dissipation 'Boundary layer dissipation' = { @@ -19009,18 +18794,6 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Mean surface sensible heat flux -'Mean surface sensible heat flux' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 146 ; - } -#Mean surface latent heat flux -'Mean surface latent heat flux' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 147 ; - } #Mean short-wave heating rate 'Mean short-wave heating rate' = { discipline = 192 ; @@ -19033,59 +18806,14 @@ parameterCategory = 172 ; parameterNumber = 154 ; } -#Mean surface downward solar radiation flux -'Mean surface downward solar radiation flux' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 169 ; - } -#Mean surface downward thermal radiation flux -'Mean surface downward thermal radiation flux' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 175 ; - } -#Mean surface net solar radiation flux -'Mean surface net solar radiation flux' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 176 ; - } -#Mean surface net thermal radiation flux -'Mean surface net thermal radiation flux' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 177 ; - } -#Mean top net solar radiation flux -'Mean top net solar radiation flux' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 178 ; - } -#Mean top net thermal radiation flux -'Mean top net thermal radiation flux' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 179 ; - } -#East-West surface stress rate of accumulation -'East-West surface stress rate of accumulation' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 180 ; - } -#North-South surface stress rate of accumulation -'North-South surface stress rate of accumulation' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 181 ; - } #Evaporation 'Evaporation' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 182 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean sunshine duration rate 'Mean sunshine duration rate' = { @@ -19113,45 +18841,21 @@ } #Mean runoff rate 'Mean runoff rate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 205 ; - } -#Top net solar radiation, clear sky -'Top net solar radiation, clear sky' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 208 ; - } -#Top net thermal radiation, clear sky -'Top net thermal radiation, clear sky' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 209 ; - } -#Surface net solar radiation, clear sky -'Surface net solar radiation, clear sky' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'Surface net thermal radiation, clear sky' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 211 ; - } -#Solar insolation rate of accumulation -'Solar insolation rate of accumulation' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 212 ; + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total precipitation rate 'Mean total precipitation rate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 228 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Convective snowfall 'Convective snowfall' = { @@ -21841,17 +21545,15 @@ parameterCategory = 220 ; parameterNumber = 228 ; } -#Mean of 10 metre wind speed -'Mean of 10 metre wind speed' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 5 ; - } #Mean total cloud cover 'Mean total cloud cover' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 6 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } #Surface temperature significance 'Surface temperature significance' = { diff --git a/definitions/grib2/localConcepts/ecmf/name.legacy.def b/definitions/grib2/localConcepts/ecmf/name.legacy.def index c3e229a57..7a451911c 100644 --- a/definitions/grib2/localConcepts/ecmf/name.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/name.legacy.def @@ -1369,3 +1369,405 @@ parameterCategory = 172 ; parameterNumber = 228 ; } +#Mean large-scale precipitation rate +'Mean large-scale precipitation rate' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 142 ; +} +#Mean convective precipitation rate +'Mean convective precipitation rate' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 143 ; +} +#Mean runoff rate +'Mean runoff rate' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 205 ; +} +#Mean total cloud cover +'Mean total cloud cover' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 6 ; +} +#Mean of 10 metre wind speed +'Mean of 10 metre wind speed' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 5 ; +} +#Sea water potential temperature +'Sea water potential temperature' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; +} +#Sea water practical salinity +'Sea water practical salinity' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; +} +#Upward sea water velocity +'Upward sea water velocity' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; +} +#Sea water sigma theta +'Sea water sigma theta' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; +} +#Surface downward eastward stress +'Surface downward eastward stress' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; +} +#Surface downward northward stress +'Surface downward northward stress' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; +} +#Surface geopotential +'Surface geopotential' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; +} +#Vertical integral of temperature +'Vertical integral of temperature' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; +} +#Vertical integral of cloud liquid water +'Vertical integral of cloud liquid water' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; +} +#Vertical integral of cloud frozen water +'Vertical integral of cloud frozen water' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; +} +#Vertical integral of ozone +'Vertical integral of ozone' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; +} +#Vertical integral of energy conversion +'Vertical integral of energy conversion' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; +} +#Vertical integral of eastward mass flux +'Vertical integral of eastward mass flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; +} +#Vertical integral of northward mass flux +'Vertical integral of northward mass flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; +} +#Vertical integral of eastward kinetic energy flux +'Vertical integral of eastward kinetic energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; +} +#Vertical integral of northward kinetic energy flux +'Vertical integral of northward kinetic energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; +} +#Vertical integral of eastward geopotential flux +'Vertical integral of eastward geopotential flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; +} +#Vertical integral of northward geopotential flux +'Vertical integral of northward geopotential flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; +} +#Vertical integral of eastward total energy flux +'Vertical integral of eastward total energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; +} +#Vertical integral of northward total energy flux +'Vertical integral of northward total energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; +} +#Vertical integral of eastward ozone flux +'Vertical integral of eastward ozone flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; +} +#Vertical integral of northward ozone flux +'Vertical integral of northward ozone flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; +} +#Vertical integral of divergence of mass flux +'Vertical integral of divergence of mass flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; +} +#Vertical integral of divergence of kinetic energy flux +'Vertical integral of divergence of kinetic energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; +} +#Vertical integral of divergence of thermal energy flux +'Vertical integral of divergence of thermal energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; +} +#Vertical integral of divergence of geopotential flux +'Vertical integral of divergence of geopotential flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; +} +#Vertical integral of divergence of total energy flux +'Vertical integral of divergence of total energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; +} +#Vertical integral of divergence of ozone flux +'Vertical integral of divergence of ozone flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; +} +#Variance of geopotential +'Variance of geopotential' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; +} +#Covariance of geopotential/temperature +'Covariance of geopotential/temperature' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; +} +#Variance of temperature +'Variance of temperature' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; +} +#Covariance of geopotential/specific humidity +'Covariance of geopotential/specific humidity' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; +} +#Covariance of temperature/specific humidity +'Covariance of temperature/specific humidity' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; +} +#Variance of specific humidity +'Variance of specific humidity' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; +} +#Covariance of u component/geopotential +'Covariance of u component/geopotential' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; +} +#Covariance of u component/temperature +'Covariance of u component/temperature' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; +} +#Covariance of u component/specific humidity +'Covariance of u component/specific humidity' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; +} +#Variance of u component +'Variance of u component' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} +#Mean vertical velocity +'Mean vertical velocity' = { + discipline = 192 ; + parameterCategory = 130 ; + parameterNumber = 232 ; +} +#Mean surface sensible heat flux +'Mean surface sensible heat flux' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 146 ; +} +#Mean surface latent heat flux +'Mean surface latent heat flux' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 147 ; +} +#Mean temperature at 2 metres in the last 24 hours +'Mean temperature at 2 metres in the last 24 hours' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 55 ; +} +#Mean 2 metre temperature in the last 24 hours gradient +'Mean 2 metre temperature in the last 24 hours gradient' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 55 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours +'Mean 2 metre dewpoint temperature in the last 24 hours' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 56 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours gradient +'Mean 2 metre dewpoint temperature in the last 24 hours gradient' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 56 ; +} +#Mean surface downward solar radiation flux +'Mean surface downward solar radiation flux' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 169 ; +} +#Mean surface downward thermal radiation flux +'Mean surface downward thermal radiation flux' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 175 ; +} +#Mean surface net solar radiation flux +'Mean surface net solar radiation flux' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 176 ; +} +#Mean surface net thermal radiation flux +'Mean surface net thermal radiation flux' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 177 ; +} +#Mean top net solar radiation flux +'Mean top net solar radiation flux' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 178 ; +} +#Mean top net thermal radiation flux +'Mean top net thermal radiation flux' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 179 ; +} +#East-West surface stress rate of accumulation +'East-West surface stress rate of accumulation' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 180 ; +} +#North-South surface stress rate of accumulation +'North-South surface stress rate of accumulation' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 181 ; +} +#Standard deviation wave height +'Standard deviation wave height' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 240 ; +} +#Mean of 10 metre wind speed +'Mean of 10 metre wind speed' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 241 ; +} +#Mean wind direction +'Mean wind direction' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 242 ; +} +#Standard deviation of 10 metre wind speed +'Standard deviation of 10 metre wind speed' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 243 ; +} +#Top net solar radiation, clear sky +'Top net solar radiation, clear sky' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 208 ; +} +#Top net thermal radiation, clear sky +'Top net thermal radiation, clear sky' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 209 ; +} +#Surface net solar radiation, clear sky +'Surface net solar radiation, clear sky' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 210 ; +} +#Surface net thermal radiation, clear sky +'Surface net thermal radiation, clear sky' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 211 ; +} +#Solar insolation rate of accumulation +'Solar insolation rate of accumulation' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 212 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/paramId.def b/definitions/grib2/localConcepts/ecmf/paramId.def index 6ba1493c0..12fe43ab4 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.def @@ -224,18 +224,6 @@ typeOfStatisticalProcessing = 3 ; lengthOfTimeRange = 24 ; } -#Mean temperature at 2 metres in the last 24 hours -'55' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours -'56' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 56 ; - } #Observation count '62' = { discipline = 192 ; @@ -2579,6 +2567,24 @@ parameterCategory = 171 ; parameterNumber = 122 ; } +#Mean surface runoff rate +'172008' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean sub-surface runoff rate +'172009' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Volcanic ash aerosol mixing ratio '210013' = { discipline = 192 ; @@ -13825,6 +13831,46 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Time-mean snow depth +'235141' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'235186' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'235187' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'235188' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'235243' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } #Covariance between 2-metre temperature and volumetric soil water layer 1 '254001' = { localTablesVersion = 1 ; @@ -14385,18 +14431,6 @@ parameterCategory = 129 ; parameterNumber = 54 ; } -#Mean 2 metre temperature in the last 24 hours gradient -'129055' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours gradient -'129056' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 56 ; - } #Downward UV radiation at the surface gradient '129057' = { discipline = 192 ; @@ -15669,12 +15703,6 @@ parameterCategory = 130 ; parameterNumber = 231 ; } -#Mean vertical velocity -'130232' = { - discipline = 192 ; - parameterCategory = 130 ; - parameterNumber = 232 ; - } #2m temperature anomaly of at least +2K '131001' = { discipline = 192 ; @@ -16573,30 +16601,6 @@ parameterCategory = 140 ; parameterNumber = 200 ; } -#Standard deviation wave height -'140240' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 240 ; - } -#Mean of 10 metre wind speed -'140241' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 241 ; - } -#Mean wind direction -'140242' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 242 ; - } -#Standard deviation of 10 metre wind speed -'140243' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 243 ; - } #2D wave spectra (multiple) '140250' = { discipline = 192 ; @@ -16813,24 +16817,6 @@ parameterCategory = 151 ; parameterNumber = 128 ; } -#Sea water potential temperature -'151129' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 129 ; - } -#Sea water practical salinity -'151130' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 130 ; - } -#Upward sea water velocity -'151133' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 133 ; - } #Modulus of strain rate tensor '151134' = { discipline = 192 ; @@ -16855,12 +16841,6 @@ parameterCategory = 151 ; parameterNumber = 137 ; } -#Sea water sigma theta -'151138' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 138 ; - } #Richardson number '151139' = { discipline = 192 ; @@ -16933,18 +16913,6 @@ parameterCategory = 151 ; parameterNumber = 152 ; } -#Surface downward eastward stress -'151153' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 153 ; - } -#Surface downward northward stress -'151154' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 154 ; - } #Turbulent kinetic energy input '151155' = { discipline = 192 ; @@ -17545,198 +17513,6 @@ parameterCategory = 160 ; parameterNumber = 254 ; } -#Surface geopotential -'162051' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 51 ; - } -#Vertical integral of temperature -'162054' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 54 ; - } -#Vertical integral of cloud liquid water -'162056' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 56 ; - } -#Vertical integral of cloud frozen water -'162057' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 57 ; - } -#Vertical integral of ozone -'162058' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 58 ; - } -#Vertical integral of energy conversion -'162064' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 64 ; - } -#Vertical integral of eastward mass flux -'162065' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 65 ; - } -#Vertical integral of northward mass flux -'162066' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 66 ; - } -#Vertical integral of eastward kinetic energy flux -'162067' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 67 ; - } -#Vertical integral of northward kinetic energy flux -'162068' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 68 ; - } -#Vertical integral of eastward geopotential flux -'162073' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 73 ; - } -#Vertical integral of northward geopotential flux -'162074' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 74 ; - } -#Vertical integral of eastward total energy flux -'162075' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 75 ; - } -#Vertical integral of northward total energy flux -'162076' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 76 ; - } -#Vertical integral of eastward ozone flux -'162077' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 77 ; - } -#Vertical integral of northward ozone flux -'162078' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 78 ; - } -#Vertical integral of divergence of mass flux -'162081' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 81 ; - } -#Vertical integral of divergence of kinetic energy flux -'162082' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 82 ; - } -#Vertical integral of divergence of thermal energy flux -'162083' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 83 ; - } -#Vertical integral of divergence of geopotential flux -'162085' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 85 ; - } -#Vertical integral of divergence of total energy flux -'162086' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 86 ; - } -#Vertical integral of divergence of ozone flux -'162087' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 87 ; - } -#Variance of geopotential -'162206' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 206 ; - } -#Covariance of geopotential/temperature -'162207' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 207 ; - } -#Variance of temperature -'162208' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 208 ; - } -#Covariance of geopotential/specific humidity -'162209' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 209 ; - } -#Covariance of temperature/specific humidity -'162210' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 210 ; - } -#Variance of specific humidity -'162211' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 211 ; - } -#Covariance of u component/geopotential -'162212' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 212 ; - } -#Covariance of u component/temperature -'162213' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 213 ; - } -#Covariance of u component/specific humidity -'162214' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 214 ; - } -#Variance of u component -'162215' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 215 ; - } #Covariance of v component/geopotential '162216' = { discipline = 192 ; @@ -18987,21 +18763,30 @@ } #Mean large-scale precipitation rate '172142' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 142 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean convective precipitation rate '172143' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 143 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total snowfall rate '172144' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 144 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Boundary layer dissipation '172145' = { @@ -19009,18 +18794,6 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Mean surface sensible heat flux -'172146' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 146 ; - } -#Mean surface latent heat flux -'172147' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 147 ; - } #Mean short-wave heating rate '172153' = { discipline = 192 ; @@ -19033,59 +18806,14 @@ parameterCategory = 172 ; parameterNumber = 154 ; } -#Mean surface downward solar radiation flux -'172169' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 169 ; - } -#Mean surface downward thermal radiation flux -'172175' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 175 ; - } -#Mean surface net solar radiation flux -'172176' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 176 ; - } -#Mean surface net thermal radiation flux -'172177' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 177 ; - } -#Mean top net solar radiation flux -'172178' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 178 ; - } -#Mean top net thermal radiation flux -'172179' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 179 ; - } -#East-West surface stress rate of accumulation -'172180' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 180 ; - } -#North-South surface stress rate of accumulation -'172181' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 181 ; - } #Evaporation '172182' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 182 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean sunshine duration rate '172189' = { @@ -19113,45 +18841,21 @@ } #Mean runoff rate '172205' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 205 ; - } -#Top net solar radiation, clear sky -'172208' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 208 ; - } -#Top net thermal radiation, clear sky -'172209' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 209 ; - } -#Surface net solar radiation, clear sky -'172210' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'172211' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 211 ; - } -#Solar insolation rate of accumulation -'172212' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 212 ; + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total precipitation rate '172228' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 228 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Convective snowfall '172239' = { @@ -21841,17 +21545,15 @@ parameterCategory = 220 ; parameterNumber = 228 ; } -#Mean of 10 metre wind speed -'228005' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 5 ; - } #Mean total cloud cover '228006' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 6 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } #Surface temperature significance '234139' = { diff --git a/definitions/grib2/localConcepts/ecmf/paramId.legacy.def b/definitions/grib2/localConcepts/ecmf/paramId.legacy.def index aaf6da765..4413e87b9 100644 --- a/definitions/grib2/localConcepts/ecmf/paramId.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/paramId.legacy.def @@ -1369,3 +1369,405 @@ parameterCategory = 172 ; parameterNumber = 228 ; } +#Mean large-scale precipitation rate +'172142' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 142 ; +} +#Mean convective precipitation rate +'172143' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 143 ; +} +#Mean runoff rate +'172205' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 205 ; +} +#Mean total cloud cover +'228006' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 6 ; +} +#Mean of 10 metre wind speed +'228005' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 5 ; +} +#Sea water potential temperature +'151129' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; +} +#Sea water practical salinity +'151130' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; +} +#Upward sea water velocity +'151133' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; +} +#Sea water sigma theta +'151138' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; +} +#Surface downward eastward stress +'151153' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; +} +#Surface downward northward stress +'151154' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; +} +#Surface geopotential +'162051' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; +} +#Vertical integral of temperature +'162054' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; +} +#Vertical integral of cloud liquid water +'162056' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; +} +#Vertical integral of cloud frozen water +'162057' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; +} +#Vertical integral of ozone +'162058' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; +} +#Vertical integral of energy conversion +'162064' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; +} +#Vertical integral of eastward mass flux +'162065' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; +} +#Vertical integral of northward mass flux +'162066' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; +} +#Vertical integral of eastward kinetic energy flux +'162067' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; +} +#Vertical integral of northward kinetic energy flux +'162068' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; +} +#Vertical integral of eastward geopotential flux +'162073' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; +} +#Vertical integral of northward geopotential flux +'162074' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; +} +#Vertical integral of eastward total energy flux +'162075' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; +} +#Vertical integral of northward total energy flux +'162076' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; +} +#Vertical integral of eastward ozone flux +'162077' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; +} +#Vertical integral of northward ozone flux +'162078' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; +} +#Vertical integral of divergence of mass flux +'162081' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; +} +#Vertical integral of divergence of kinetic energy flux +'162082' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; +} +#Vertical integral of divergence of thermal energy flux +'162083' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; +} +#Vertical integral of divergence of geopotential flux +'162085' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; +} +#Vertical integral of divergence of total energy flux +'162086' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; +} +#Vertical integral of divergence of ozone flux +'162087' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; +} +#Variance of geopotential +'162206' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; +} +#Covariance of geopotential/temperature +'162207' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; +} +#Variance of temperature +'162208' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; +} +#Covariance of geopotential/specific humidity +'162209' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; +} +#Covariance of temperature/specific humidity +'162210' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; +} +#Variance of specific humidity +'162211' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; +} +#Covariance of u component/geopotential +'162212' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; +} +#Covariance of u component/temperature +'162213' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; +} +#Covariance of u component/specific humidity +'162214' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; +} +#Variance of u component +'162215' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} +#Mean vertical velocity +'130232' = { + discipline = 192 ; + parameterCategory = 130 ; + parameterNumber = 232 ; +} +#Mean surface sensible heat flux +'172146' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 146 ; +} +#Mean surface latent heat flux +'172147' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 147 ; +} +#Mean temperature at 2 metres in the last 24 hours +'55' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 55 ; +} +#Mean 2 metre temperature in the last 24 hours gradient +'129055' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 55 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours +'56' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 56 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours gradient +'129056' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 56 ; +} +#Mean surface downward solar radiation flux +'172169' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 169 ; +} +#Mean surface downward thermal radiation flux +'172175' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 175 ; +} +#Mean surface net solar radiation flux +'172176' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 176 ; +} +#Mean surface net thermal radiation flux +'172177' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 177 ; +} +#Mean top net solar radiation flux +'172178' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 178 ; +} +#Mean top net thermal radiation flux +'172179' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 179 ; +} +#East-West surface stress rate of accumulation +'172180' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 180 ; +} +#North-South surface stress rate of accumulation +'172181' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 181 ; +} +#Standard deviation wave height +'140240' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 240 ; +} +#Mean of 10 metre wind speed +'140241' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 241 ; +} +#Mean wind direction +'140242' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 242 ; +} +#Standard deviation of 10 metre wind speed +'140243' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 243 ; +} +#Top net solar radiation, clear sky +'172208' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 208 ; +} +#Top net thermal radiation, clear sky +'172209' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 209 ; +} +#Surface net solar radiation, clear sky +'172210' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 210 ; +} +#Surface net thermal radiation, clear sky +'172211' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 211 ; +} +#Solar insolation rate of accumulation +'172212' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 212 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/shortName.def b/definitions/grib2/localConcepts/ecmf/shortName.def index 1ec2bca2e..b7e53c29d 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.def @@ -224,18 +224,6 @@ typeOfStatisticalProcessing = 3 ; lengthOfTimeRange = 24 ; } -#Mean temperature at 2 metres in the last 24 hours -'mean2t24' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours -'mn2d24' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 56 ; - } #Observation count 'obct' = { discipline = 192 ; @@ -2579,6 +2567,24 @@ parameterCategory = 171 ; parameterNumber = 122 ; } +#Mean surface runoff rate +'msror' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean sub-surface runoff rate +'mssror' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Volcanic ash aerosol mixing ratio 'aermr13' = { discipline = 192 ; @@ -13825,6 +13831,46 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Time-mean snow depth +'avg_sd_m' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'avg_lcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'avg_mcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'avg_hcc_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'avg_fal_frac' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } #Covariance between 2-metre temperature and volumetric soil water layer 1 'covar_t2m_swvl1' = { localTablesVersion = 1 ; @@ -14385,18 +14431,6 @@ parameterCategory = 129 ; parameterNumber = 54 ; } -#Mean 2 metre temperature in the last 24 hours gradient -'mean2t24grd' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours gradient -'mn2d24grd' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 56 ; - } #Downward UV radiation at the surface gradient 'uvbgrd' = { discipline = 192 ; @@ -15669,12 +15703,6 @@ parameterCategory = 130 ; parameterNumber = 231 ; } -#Mean vertical velocity -'mvv' = { - discipline = 192 ; - parameterCategory = 130 ; - parameterNumber = 232 ; - } #2m temperature anomaly of at least +2K '2tag2' = { discipline = 192 ; @@ -16573,30 +16601,6 @@ parameterCategory = 140 ; parameterNumber = 200 ; } -#Standard deviation wave height -'sdhs' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 240 ; - } -#Mean of 10 metre wind speed -'mu10' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 241 ; - } -#Mean wind direction -'mdwi' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 242 ; - } -#Standard deviation of 10 metre wind speed -'sdu' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 243 ; - } #2D wave spectra (multiple) '2dsp' = { discipline = 192 ; @@ -16813,24 +16817,6 @@ parameterCategory = 151 ; parameterNumber = 128 ; } -#Sea water potential temperature -'thetao' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 129 ; - } -#Sea water practical salinity -'so' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 130 ; - } -#Upward sea water velocity -'wo' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 133 ; - } #Modulus of strain rate tensor 'mst' = { discipline = 192 ; @@ -16855,12 +16841,6 @@ parameterCategory = 151 ; parameterNumber = 137 ; } -#Sea water sigma theta -'sigmat' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 138 ; - } #Richardson number 'rn' = { discipline = 192 ; @@ -16933,18 +16913,6 @@ parameterCategory = 151 ; parameterNumber = 152 ; } -#Surface downward eastward stress -'taueo' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 153 ; - } -#Surface downward northward stress -'tauno' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 154 ; - } #Turbulent kinetic energy input 'tki' = { discipline = 192 ; @@ -17545,198 +17513,6 @@ parameterCategory = 160 ; parameterNumber = 254 ; } -#Surface geopotential -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 51 ; - } -#Vertical integral of temperature -'vit' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 54 ; - } -#Vertical integral of cloud liquid water -'vilw' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 56 ; - } -#Vertical integral of cloud frozen water -'viiw' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 57 ; - } -#Vertical integral of ozone -'vioz' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 58 ; - } -#Vertical integral of energy conversion -'viec' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 64 ; - } -#Vertical integral of eastward mass flux -'vimae' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 65 ; - } -#Vertical integral of northward mass flux -'viman' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 66 ; - } -#Vertical integral of eastward kinetic energy flux -'vikee' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 67 ; - } -#Vertical integral of northward kinetic energy flux -'viken' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 68 ; - } -#Vertical integral of eastward geopotential flux -'vige' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 73 ; - } -#Vertical integral of northward geopotential flux -'vign' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 74 ; - } -#Vertical integral of eastward total energy flux -'vitoee' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 75 ; - } -#Vertical integral of northward total energy flux -'vitoen' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 76 ; - } -#Vertical integral of eastward ozone flux -'vioze' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 77 ; - } -#Vertical integral of northward ozone flux -'viozn' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 78 ; - } -#Vertical integral of divergence of mass flux -'vimad' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 81 ; - } -#Vertical integral of divergence of kinetic energy flux -'viked' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 82 ; - } -#Vertical integral of divergence of thermal energy flux -'vithed' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 83 ; - } -#Vertical integral of divergence of geopotential flux -'vigd' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 85 ; - } -#Vertical integral of divergence of total energy flux -'vitoed' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 86 ; - } -#Vertical integral of divergence of ozone flux -'viozd' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 87 ; - } -#Variance of geopotential -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 206 ; - } -#Covariance of geopotential/temperature -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 207 ; - } -#Variance of temperature -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 208 ; - } -#Covariance of geopotential/specific humidity -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 209 ; - } -#Covariance of temperature/specific humidity -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 210 ; - } -#Variance of specific humidity -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 211 ; - } -#Covariance of u component/geopotential -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 212 ; - } -#Covariance of u component/temperature -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 213 ; - } -#Covariance of u component/specific humidity -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 214 ; - } -#Variance of u component -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 215 ; - } #Covariance of v component/geopotential '~' = { discipline = 192 ; @@ -18987,21 +18763,30 @@ } #Mean large-scale precipitation rate 'mlsprt' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 142 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean convective precipitation rate 'cprate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 143 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total snowfall rate 'mtsfr' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 144 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Boundary layer dissipation 'bldrate' = { @@ -19009,18 +18794,6 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Mean surface sensible heat flux -'msshfl' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 146 ; - } -#Mean surface latent heat flux -'mslhfl' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 147 ; - } #Mean short-wave heating rate 'mswhr' = { discipline = 192 ; @@ -19033,59 +18806,14 @@ parameterCategory = 172 ; parameterNumber = 154 ; } -#Mean surface downward solar radiation flux -'msdsrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 169 ; - } -#Mean surface downward thermal radiation flux -'msdtrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 175 ; - } -#Mean surface net solar radiation flux -'msnsrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 176 ; - } -#Mean surface net thermal radiation flux -'msntrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 177 ; - } -#Mean top net solar radiation flux -'mtnsrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 178 ; - } -#Mean top net thermal radiation flux -'mtntrf' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 179 ; - } -#East-West surface stress rate of accumulation -'ewssra' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 180 ; - } -#North-South surface stress rate of accumulation -'nsssra' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 181 ; - } #Evaporation 'erate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 182 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean sunshine duration rate 'msdr' = { @@ -19113,45 +18841,21 @@ } #Mean runoff rate 'mrort' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 205 ; - } -#Top net solar radiation, clear sky -'~' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 208 ; - } -#Top net thermal radiation, clear sky -'~' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 209 ; - } -#Surface net solar radiation, clear sky -'~' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'~' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 211 ; - } -#Solar insolation rate of accumulation -'soira' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 212 ; + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total precipitation rate 'tprate' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 228 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Convective snowfall '~' = { @@ -21841,17 +21545,15 @@ parameterCategory = 220 ; parameterNumber = 228 ; } -#Mean of 10 metre wind speed -'mean10ws' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 5 ; - } #Mean total cloud cover 'meantcc' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 6 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } #Surface temperature significance 'sts' = { diff --git a/definitions/grib2/localConcepts/ecmf/shortName.legacy.def b/definitions/grib2/localConcepts/ecmf/shortName.legacy.def index ec7ef430b..1a5608823 100644 --- a/definitions/grib2/localConcepts/ecmf/shortName.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/shortName.legacy.def @@ -1369,3 +1369,405 @@ parameterCategory = 172 ; parameterNumber = 228 ; } +#Mean large-scale precipitation rate +'mlsprt' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 142 ; +} +#Mean convective precipitation rate +'cprate' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 143 ; +} +#Mean runoff rate +'mrort' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 205 ; +} +#Mean total cloud cover +'meantcc' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 6 ; +} +#Mean of 10 metre wind speed +'mean10ws' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 5 ; +} +#Sea water potential temperature +'thetao' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; +} +#Sea water practical salinity +'so' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; +} +#Upward sea water velocity +'wo' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; +} +#Sea water sigma theta +'sigmat' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; +} +#Surface downward eastward stress +'taueo' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; +} +#Surface downward northward stress +'tauno' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; +} +#Surface geopotential +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; +} +#Vertical integral of temperature +'vit' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; +} +#Vertical integral of cloud liquid water +'vilw' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; +} +#Vertical integral of cloud frozen water +'viiw' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; +} +#Vertical integral of ozone +'vioz' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; +} +#Vertical integral of energy conversion +'viec' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; +} +#Vertical integral of eastward mass flux +'vimae' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; +} +#Vertical integral of northward mass flux +'viman' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; +} +#Vertical integral of eastward kinetic energy flux +'vikee' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; +} +#Vertical integral of northward kinetic energy flux +'viken' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; +} +#Vertical integral of eastward geopotential flux +'vige' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; +} +#Vertical integral of northward geopotential flux +'vign' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; +} +#Vertical integral of eastward total energy flux +'vitoee' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; +} +#Vertical integral of northward total energy flux +'vitoen' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; +} +#Vertical integral of eastward ozone flux +'vioze' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; +} +#Vertical integral of northward ozone flux +'viozn' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; +} +#Vertical integral of divergence of mass flux +'vimad' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; +} +#Vertical integral of divergence of kinetic energy flux +'viked' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; +} +#Vertical integral of divergence of thermal energy flux +'vithed' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; +} +#Vertical integral of divergence of geopotential flux +'vigd' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; +} +#Vertical integral of divergence of total energy flux +'vitoed' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; +} +#Vertical integral of divergence of ozone flux +'viozd' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; +} +#Variance of geopotential +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; +} +#Covariance of geopotential/temperature +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; +} +#Variance of temperature +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; +} +#Covariance of geopotential/specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; +} +#Covariance of temperature/specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; +} +#Variance of specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; +} +#Covariance of u component/geopotential +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; +} +#Covariance of u component/temperature +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; +} +#Covariance of u component/specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; +} +#Variance of u component +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} +#Mean vertical velocity +'mvv' = { + discipline = 192 ; + parameterCategory = 130 ; + parameterNumber = 232 ; +} +#Mean surface sensible heat flux +'msshfl' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 146 ; +} +#Mean surface latent heat flux +'mslhfl' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 147 ; +} +#Mean temperature at 2 metres in the last 24 hours +'mean2t24' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 55 ; +} +#Mean 2 metre temperature in the last 24 hours gradient +'mean2t24grd' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 55 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours +'mn2d24' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 56 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours gradient +'mn2d24grd' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 56 ; +} +#Mean surface downward solar radiation flux +'msdsrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 169 ; +} +#Mean surface downward thermal radiation flux +'msdtrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 175 ; +} +#Mean surface net solar radiation flux +'msnsrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 176 ; +} +#Mean surface net thermal radiation flux +'msntrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 177 ; +} +#Mean top net solar radiation flux +'mtnsrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 178 ; +} +#Mean top net thermal radiation flux +'mtntrf' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 179 ; +} +#East-West surface stress rate of accumulation +'ewssra' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 180 ; +} +#North-South surface stress rate of accumulation +'nsssra' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 181 ; +} +#Standard deviation wave height +'sdhs' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 240 ; +} +#Mean of 10 metre wind speed +'mu10' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 241 ; +} +#Mean wind direction +'mdwi' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 242 ; +} +#Standard deviation of 10 metre wind speed +'sdu' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 243 ; +} +#Top net solar radiation, clear sky +'~' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 208 ; +} +#Top net thermal radiation, clear sky +'~' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 209 ; +} +#Surface net solar radiation, clear sky +'~' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 210 ; +} +#Surface net thermal radiation, clear sky +'~' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 211 ; +} +#Solar insolation rate of accumulation +'soira' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 212 ; +} diff --git a/definitions/grib2/localConcepts/ecmf/units.def b/definitions/grib2/localConcepts/ecmf/units.def index 506f9c365..1629e52b0 100644 --- a/definitions/grib2/localConcepts/ecmf/units.def +++ b/definitions/grib2/localConcepts/ecmf/units.def @@ -224,18 +224,6 @@ typeOfStatisticalProcessing = 3 ; lengthOfTimeRange = 24 ; } -#Mean temperature at 2 metres in the last 24 hours -'K' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours -'K' = { - discipline = 192 ; - parameterCategory = 128 ; - parameterNumber = 56 ; - } #Observation count '~' = { discipline = 192 ; @@ -2579,6 +2567,24 @@ parameterCategory = 171 ; parameterNumber = 122 ; } +#Mean surface runoff rate +'m s**-1' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Mean sub-surface runoff rate +'m s**-1' = { + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Volcanic ash aerosol mixing ratio 'kg kg**-1' = { discipline = 192 ; @@ -13825,6 +13831,46 @@ typeOfSecondFixedSurface = 255 ; typeOfStatisticalProcessing = 1 ; } +#Time-mean snow depth +'m of water equivalent' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 254 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean medium cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high cloud cover +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast albedo +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfStatisticalProcessing = 0 ; + } #Covariance between 2-metre temperature and volumetric soil water layer 1 'K m**3 m**-3' = { localTablesVersion = 1 ; @@ -14385,18 +14431,6 @@ parameterCategory = 129 ; parameterNumber = 54 ; } -#Mean 2 metre temperature in the last 24 hours gradient -'K' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 55 ; - } -#Mean 2 metre dewpoint temperature in the last 24 hours gradient -'K' = { - discipline = 192 ; - parameterCategory = 129 ; - parameterNumber = 56 ; - } #Downward UV radiation at the surface gradient 'J m**-2' = { discipline = 192 ; @@ -15669,12 +15703,6 @@ parameterCategory = 130 ; parameterNumber = 231 ; } -#Mean vertical velocity -'Pa s**-1' = { - discipline = 192 ; - parameterCategory = 130 ; - parameterNumber = 232 ; - } #2m temperature anomaly of at least +2K '%' = { discipline = 192 ; @@ -16573,30 +16601,6 @@ parameterCategory = 140 ; parameterNumber = 200 ; } -#Standard deviation wave height -'m' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 240 ; - } -#Mean of 10 metre wind speed -'m s**-1' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 241 ; - } -#Mean wind direction -'degrees' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 242 ; - } -#Standard deviation of 10 metre wind speed -'m s**-1' = { - discipline = 192 ; - parameterCategory = 140 ; - parameterNumber = 243 ; - } #2D wave spectra (multiple) 'm**2 s radian**-1' = { discipline = 192 ; @@ -16813,24 +16817,6 @@ parameterCategory = 151 ; parameterNumber = 128 ; } -#Sea water potential temperature -'deg C' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 129 ; - } -#Sea water practical salinity -'psu' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 130 ; - } -#Upward sea water velocity -'m s**-1' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 133 ; - } #Modulus of strain rate tensor 's**-1' = { discipline = 192 ; @@ -16855,12 +16841,6 @@ parameterCategory = 151 ; parameterNumber = 137 ; } -#Sea water sigma theta -'kg m**-3' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 138 ; - } #Richardson number '~' = { discipline = 192 ; @@ -16933,18 +16913,6 @@ parameterCategory = 151 ; parameterNumber = 152 ; } -#Surface downward eastward stress -'N m**-2' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 153 ; - } -#Surface downward northward stress -'N m**-2' = { - discipline = 192 ; - parameterCategory = 151 ; - parameterNumber = 154 ; - } #Turbulent kinetic energy input 'J m**-2' = { discipline = 192 ; @@ -17545,198 +17513,6 @@ parameterCategory = 160 ; parameterNumber = 254 ; } -#Surface geopotential -'m**2 s**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 51 ; - } -#Vertical integral of temperature -'K kg m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 54 ; - } -#Vertical integral of cloud liquid water -'kg m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 56 ; - } -#Vertical integral of cloud frozen water -'kg m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 57 ; - } -#Vertical integral of ozone -'kg m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 58 ; - } -#Vertical integral of energy conversion -'W m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 64 ; - } -#Vertical integral of eastward mass flux -'kg m**-1 s**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 65 ; - } -#Vertical integral of northward mass flux -'kg m**-1 s**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 66 ; - } -#Vertical integral of eastward kinetic energy flux -'W m**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 67 ; - } -#Vertical integral of northward kinetic energy flux -'W m**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 68 ; - } -#Vertical integral of eastward geopotential flux -'W m**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 73 ; - } -#Vertical integral of northward geopotential flux -'W m**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 74 ; - } -#Vertical integral of eastward total energy flux -'W m**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 75 ; - } -#Vertical integral of northward total energy flux -'W m**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 76 ; - } -#Vertical integral of eastward ozone flux -'kg m**-1 s**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 77 ; - } -#Vertical integral of northward ozone flux -'kg m**-1 s**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 78 ; - } -#Vertical integral of divergence of mass flux -'kg m**-2 s**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 81 ; - } -#Vertical integral of divergence of kinetic energy flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 82 ; - } -#Vertical integral of divergence of thermal energy flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 83 ; - } -#Vertical integral of divergence of geopotential flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 85 ; - } -#Vertical integral of divergence of total energy flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 86 ; - } -#Vertical integral of divergence of ozone flux -'kg m**-2 s**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 87 ; - } -#Variance of geopotential -'m**4 s**-4' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 206 ; - } -#Covariance of geopotential/temperature -'m**2 K s**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 207 ; - } -#Variance of temperature -'K**2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 208 ; - } -#Covariance of geopotential/specific humidity -'m**2 s**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 209 ; - } -#Covariance of temperature/specific humidity -'K' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 210 ; - } -#Variance of specific humidity -'~' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 211 ; - } -#Covariance of u component/geopotential -'m**3 s**-3' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 212 ; - } -#Covariance of u component/temperature -'m s**-1 K' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 213 ; - } -#Covariance of u component/specific humidity -'m s**-1' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 214 ; - } -#Variance of u component -'m**2 s**-2' = { - discipline = 192 ; - parameterCategory = 162 ; - parameterNumber = 215 ; - } #Covariance of v component/geopotential 'm**3 s**-3' = { discipline = 192 ; @@ -18987,21 +18763,30 @@ } #Mean large-scale precipitation rate 'm s**-1' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 142 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean convective precipitation rate 'm s**-1' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 143 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total snowfall rate 'm of water equivalent s**-1' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 144 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Boundary layer dissipation 'W m**-2' = { @@ -19009,18 +18794,6 @@ parameterCategory = 172 ; parameterNumber = 145 ; } -#Mean surface sensible heat flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 146 ; - } -#Mean surface latent heat flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 147 ; - } #Mean short-wave heating rate 'K s**-1' = { discipline = 192 ; @@ -19033,59 +18806,14 @@ parameterCategory = 172 ; parameterNumber = 154 ; } -#Mean surface downward solar radiation flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 169 ; - } -#Mean surface downward thermal radiation flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 175 ; - } -#Mean surface net solar radiation flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 176 ; - } -#Mean surface net thermal radiation flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 177 ; - } -#Mean top net solar radiation flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 178 ; - } -#Mean top net thermal radiation flux -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 179 ; - } -#East-West surface stress rate of accumulation -'N m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 180 ; - } -#North-South surface stress rate of accumulation -'N m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 181 ; - } #Evaporation 'm of water equivalent s**-1' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 182 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean sunshine duration rate 's s**-1' = { @@ -19113,45 +18841,21 @@ } #Mean runoff rate 'm s**-1' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 205 ; - } -#Top net solar radiation, clear sky -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 208 ; - } -#Top net thermal radiation, clear sky -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 209 ; - } -#Surface net solar radiation, clear sky -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 210 ; - } -#Surface net thermal radiation, clear sky -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 211 ; - } -#Solar insolation rate of accumulation -'W m**-2' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 212 ; + localTablesVersion = 1 ; + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Mean total precipitation rate 'm s**-1' = { - discipline = 192 ; - parameterCategory = 172 ; - parameterNumber = 228 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; } #Convective snowfall 'm of water equivalent s**-1' = { @@ -21841,17 +21545,15 @@ parameterCategory = 220 ; parameterNumber = 228 ; } -#Mean of 10 metre wind speed -'m s**-1' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 5 ; - } #Mean total cloud cover '(0 - 1)' = { - discipline = 192 ; - parameterCategory = 228 ; - parameterNumber = 6 ; + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; } #Surface temperature significance '%' = { diff --git a/definitions/grib2/localConcepts/ecmf/units.legacy.def b/definitions/grib2/localConcepts/ecmf/units.legacy.def index ca9926f81..b6a28f51b 100644 --- a/definitions/grib2/localConcepts/ecmf/units.legacy.def +++ b/definitions/grib2/localConcepts/ecmf/units.legacy.def @@ -1369,3 +1369,405 @@ parameterCategory = 172 ; parameterNumber = 228 ; } +#Mean large-scale precipitation rate +'m s**-1' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 142 ; +} +#Mean convective precipitation rate +'m s**-1' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 143 ; +} +#Mean runoff rate +'m s**-1' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 205 ; +} +#Mean total cloud cover +'(0 - 1)' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 6 ; +} +#Mean of 10 metre wind speed +'m s**-1' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 5 ; +} +#Sea water potential temperature +'deg C' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; +} +#Sea water practical salinity +'psu' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; +} +#Upward sea water velocity +'m s**-1' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; +} +#Sea water sigma theta +'kg m**-3' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; +} +#Surface downward eastward stress +'N m**-2' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; +} +#Surface downward northward stress +'N m**-2' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; +} +#Surface geopotential +'m**2 s**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; +} +#Vertical integral of temperature +'K kg m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; +} +#Vertical integral of cloud liquid water +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; +} +#Vertical integral of cloud frozen water +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; +} +#Vertical integral of ozone +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; +} +#Vertical integral of energy conversion +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; +} +#Vertical integral of eastward mass flux +'kg m**-1 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; +} +#Vertical integral of northward mass flux +'kg m**-1 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; +} +#Vertical integral of eastward kinetic energy flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; +} +#Vertical integral of northward kinetic energy flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; +} +#Vertical integral of eastward geopotential flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; +} +#Vertical integral of northward geopotential flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; +} +#Vertical integral of eastward total energy flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; +} +#Vertical integral of northward total energy flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; +} +#Vertical integral of eastward ozone flux +'kg m**-1 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; +} +#Vertical integral of northward ozone flux +'kg m**-1 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; +} +#Vertical integral of divergence of mass flux +'kg m**-2 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; +} +#Vertical integral of divergence of kinetic energy flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; +} +#Vertical integral of divergence of thermal energy flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; +} +#Vertical integral of divergence of geopotential flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; +} +#Vertical integral of divergence of total energy flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; +} +#Vertical integral of divergence of ozone flux +'kg m**-2 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; +} +#Variance of geopotential +'m**4 s**-4' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; +} +#Covariance of geopotential/temperature +'m**2 K s**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; +} +#Variance of temperature +'K**2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; +} +#Covariance of geopotential/specific humidity +'m**2 s**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; +} +#Covariance of temperature/specific humidity +'K' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; +} +#Variance of specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; +} +#Covariance of u component/geopotential +'m**3 s**-3' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; +} +#Covariance of u component/temperature +'m s**-1 K' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; +} +#Covariance of u component/specific humidity +'m s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; +} +#Variance of u component +'m**2 s**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} +#Mean vertical velocity +'Pa s**-1' = { + discipline = 192 ; + parameterCategory = 130 ; + parameterNumber = 232 ; +} +#Mean surface sensible heat flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 146 ; +} +#Mean surface latent heat flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 147 ; +} +#Mean temperature at 2 metres in the last 24 hours +'K' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 55 ; +} +#Mean 2 metre temperature in the last 24 hours gradient +'K' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 55 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours +'K' = { + discipline = 192 ; + parameterCategory = 128 ; + parameterNumber = 56 ; +} +#Mean 2 metre dewpoint temperature in the last 24 hours gradient +'K' = { + discipline = 192 ; + parameterCategory = 129 ; + parameterNumber = 56 ; +} +#Mean surface downward solar radiation flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 169 ; +} +#Mean surface downward thermal radiation flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 175 ; +} +#Mean surface net solar radiation flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 176 ; +} +#Mean surface net thermal radiation flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 177 ; +} +#Mean top net solar radiation flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 178 ; +} +#Mean top net thermal radiation flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 179 ; +} +#East-West surface stress rate of accumulation +'N m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 180 ; +} +#North-South surface stress rate of accumulation +'N m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 181 ; +} +#Standard deviation wave height +'m' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 240 ; +} +#Mean of 10 metre wind speed +'m s**-1' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 241 ; +} +#Mean wind direction +'degrees' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 242 ; +} +#Standard deviation of 10 metre wind speed +'m s**-1' = { + discipline = 192 ; + parameterCategory = 140 ; + parameterNumber = 243 ; +} +#Top net solar radiation, clear sky +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 208 ; +} +#Top net thermal radiation, clear sky +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 209 ; +} +#Surface net solar radiation, clear sky +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 210 ; +} +#Surface net thermal radiation, clear sky +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 211 ; +} +#Solar insolation rate of accumulation +'W m**-2' = { + discipline = 192 ; + parameterCategory = 172 ; + parameterNumber = 212 ; +} diff --git a/definitions/grib2/localConcepts/era/cfName.def b/definitions/grib2/localConcepts/era/cfName.def new file mode 100644 index 000000000..f4a8abea5 --- /dev/null +++ b/definitions/grib2/localConcepts/era/cfName.def @@ -0,0 +1,72 @@ +# Automatically generated by ./create_def.pl, do not edit +#Geopotential +'geopotential' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } +#Temperature +'air_temperature' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific humidity +'specific_humidity' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Vertical velocity +'lagrangian_tendency_of_air_pressure' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Snow depth +'lwe_thickness_of_surface_snow_amount' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Sea water potential temperature +'sea_water_potential_temperature' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; + } +#Sea water practical salinity +'sea_water_practical_salinity' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; + } +#Upward sea water velocity +'upward_sea_water_velocity' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; + } +#Sea water sigma theta +'sea_water_sigma_theta' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; + } +#Surface downward eastward stress +'surface_downward_eastward_stress' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; + } +#Surface downward northward stress +'surface_downward_northward_stress' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; +} diff --git a/definitions/grib2/localConcepts/era/name.def b/definitions/grib2/localConcepts/era/name.def new file mode 100644 index 000000000..78a476de6 --- /dev/null +++ b/definitions/grib2/localConcepts/era/name.def @@ -0,0 +1,716 @@ +# Automatically generated by ./create_def.pl, do not edit +#Geopotential +'Geopotential' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } +#Temperature +'Temperature' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific humidity +'Specific humidity' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Vertical velocity +'Vertical velocity' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Logarithm of surface pressure +'Logarithm of surface pressure' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + } +#Temperature difference +'Temperature difference' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 130 ; + } +#Specific humidity difference +'Specific humidity difference' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 133 ; + } +#Vorticity (relative) difference +'Vorticity (relative) difference' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 138 ; + } +#Logarithm of surface pressure difference +'Logarithm of surface pressure difference' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 152 ; + } +#Divergence difference +'Divergence difference' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 155 ; + } +#Ozone mass mixing ratio difference +'Ozone mass mixing ratio difference' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 203 ; + } +#Snow depth +'Snow depth' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Random pattern 1 for sppt +'Random pattern 1 for sppt' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 1 ; + } +#Random pattern 2 for sppt +'Random pattern 2 for sppt' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 2 ; + } +#Random pattern 3 for sppt +'Random pattern 3 for sppt' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 3 ; + } +#Random pattern 1 for SPP scheme +'Random pattern 1 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 101 ; + } +#Random pattern 2 for SPP scheme +'Random pattern 2 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 102 ; + } +#Random pattern 3 for SPP scheme +'Random pattern 3 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 103 ; + } +#Random pattern 4 for SPP scheme +'Random pattern 4 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 104 ; + } +#Random pattern 5 for SPP scheme +'Random pattern 5 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 105 ; + } +#Random pattern 6 for SPP scheme +'Random pattern 6 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 106 ; + } +#Random pattern 7 for SPP scheme +'Random pattern 7 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 107 ; + } +#Random pattern 8 for SPP scheme +'Random pattern 8 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 108 ; + } +#Random pattern 9 for SPP scheme +'Random pattern 9 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 109 ; + } +#Random pattern 10 for SPP scheme +'Random pattern 10 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 110 ; + } +#Random pattern 11 for SPP scheme +'Random pattern 11 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 111 ; + } +#Random pattern 12 for SPP scheme +'Random pattern 12 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 112 ; + } +#Random pattern 13 for SPP scheme +'Random pattern 13 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 113 ; + } +#Random pattern 14 for SPP scheme +'Random pattern 14 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 114 ; + } +#Random pattern 15 for SPP scheme +'Random pattern 15 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 115 ; + } +#Random pattern 16 for SPP scheme +'Random pattern 16 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 116 ; + } +#Random pattern 17 for SPP scheme +'Random pattern 17 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 117 ; + } +#Random pattern 18 for SPP scheme +'Random pattern 18 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 118 ; + } +#Random pattern 19 for SPP scheme +'Random pattern 19 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 119 ; + } +#Random pattern 20 for SPP scheme +'Random pattern 20 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 120 ; + } +#Random pattern 21 for SPP scheme +'Random pattern 21 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 121 ; + } +#Random pattern 22 for SPP scheme +'Random pattern 22 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 122 ; + } +#Random pattern 23 for SPP scheme +'Random pattern 23 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 123 ; + } +#Random pattern 24 for SPP scheme +'Random pattern 24 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 124 ; + } +#Random pattern 25 for SPP scheme +'Random pattern 25 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 125 ; + } +#Random pattern 26 for SPP scheme +'Random pattern 26 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 126 ; + } +#Random pattern 27 for SPP scheme +'Random pattern 27 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 127 ; + } +#Random pattern 28 for SPP scheme +'Random pattern 28 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 128 ; + } +#Random pattern 29 for SPP scheme +'Random pattern 29 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 129 ; + } +#Random pattern 30 for SPP scheme +'Random pattern 30 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 130 ; + } +#Random pattern 31 for SPP scheme +'Random pattern 31 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 131 ; + } +#Random pattern 32 for SPP scheme +'Random pattern 32 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 132 ; + } +#Random pattern 33 for SPP scheme +'Random pattern 33 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 133 ; + } +#Random pattern 34 for SPP scheme +'Random pattern 34 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 134 ; + } +#Random pattern 35 for SPP scheme +'Random pattern 35 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 135 ; + } +#Random pattern 36 for SPP scheme +'Random pattern 36 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 136 ; + } +#Random pattern 37 for SPP scheme +'Random pattern 37 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 137 ; + } +#Random pattern 38 for SPP scheme +'Random pattern 38 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 138 ; + } +#Random pattern 39 for SPP scheme +'Random pattern 39 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 139 ; + } +#Random pattern 40 for SPP scheme +'Random pattern 40 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 140 ; + } +#Random pattern 41 for SPP scheme +'Random pattern 41 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 141 ; + } +#Random pattern 42 for SPP scheme +'Random pattern 42 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 142 ; + } +#Random pattern 43 for SPP scheme +'Random pattern 43 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 143 ; + } +#Random pattern 44 for SPP scheme +'Random pattern 44 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 144 ; + } +#Random pattern 45 for SPP scheme +'Random pattern 45 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 145 ; + } +#Random pattern 46 for SPP scheme +'Random pattern 46 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 146 ; + } +#Random pattern 47 for SPP scheme +'Random pattern 47 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 147 ; + } +#Random pattern 48 for SPP scheme +'Random pattern 48 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 148 ; + } +#Random pattern 49 for SPP scheme +'Random pattern 49 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 149 ; + } +#Random pattern 50 for SPP scheme +'Random pattern 50 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 150 ; + } +#Random pattern 51 for SPP scheme +'Random pattern 51 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 151 ; + } +#Random pattern 52 for SPP scheme +'Random pattern 52 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 152 ; + } +#Random pattern 53 for SPP scheme +'Random pattern 53 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 153 ; + } +#Random pattern 54 for SPP scheme +'Random pattern 54 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 154 ; + } +#Random pattern 55 for SPP scheme +'Random pattern 55 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 155 ; + } +#Random pattern 56 for SPP scheme +'Random pattern 56 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 156 ; + } +#Random pattern 57 for SPP scheme +'Random pattern 57 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 157 ; + } +#Random pattern 58 for SPP scheme +'Random pattern 58 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 158 ; + } +#Random pattern 59 for SPP scheme +'Random pattern 59 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 159 ; + } +#Random pattern 60 for SPP scheme +'Random pattern 60 for SPP scheme' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 160 ; + } +#Evaporation from the top of canopy +'Evaporation from the top of canopy' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 100 ; + } +#Evaporation from bare soil +'Evaporation from bare soil' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 101 ; + } +#Evaporation from open water surfaces excluding oceans +'Evaporation from open water surfaces excluding oceans' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 102 ; + } +#Evaporation from vegetation transpiration +'Evaporation from vegetation transpiration' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 103 ; + } +#Snow cover +'Snow cover' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Sea water potential temperature +'Sea water potential temperature' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; + } +#Sea water practical salinity +'Sea water practical salinity' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; + } +#Upward sea water velocity +'Upward sea water velocity' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; + } +#Sea water sigma theta +'Sea water sigma theta' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; + } +#Surface downward eastward stress +'Surface downward eastward stress' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; + } +#Surface downward northward stress +'Surface downward northward stress' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; + } +#Surface geopotential +'Surface geopotential' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; + } +#Vertical integral of temperature +'Vertical integral of temperature' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; + } +#Vertical integral of cloud liquid water +'Vertical integral of cloud liquid water' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; + } +#Vertical integral of cloud frozen water +'Vertical integral of cloud frozen water' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; + } +#Vertical integral of ozone +'Vertical integral of ozone' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; + } +#Vertical integral of energy conversion +'Vertical integral of energy conversion' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; + } +#Vertical integral of eastward mass flux +'Vertical integral of eastward mass flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; + } +#Vertical integral of northward mass flux +'Vertical integral of northward mass flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; + } +#Vertical integral of eastward kinetic energy flux +'Vertical integral of eastward kinetic energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; + } +#Vertical integral of northward kinetic energy flux +'Vertical integral of northward kinetic energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; + } +#Vertical integral of eastward geopotential flux +'Vertical integral of eastward geopotential flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; + } +#Vertical integral of northward geopotential flux +'Vertical integral of northward geopotential flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; + } +#Vertical integral of eastward total energy flux +'Vertical integral of eastward total energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; + } +#Vertical integral of northward total energy flux +'Vertical integral of northward total energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; + } +#Vertical integral of eastward ozone flux +'Vertical integral of eastward ozone flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; + } +#Vertical integral of northward ozone flux +'Vertical integral of northward ozone flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; + } +#Vertical integral of divergence of mass flux +'Vertical integral of divergence of mass flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; + } +#Vertical integral of divergence of kinetic energy flux +'Vertical integral of divergence of kinetic energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; + } +#Vertical integral of divergence of thermal energy flux +'Vertical integral of divergence of thermal energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; + } +#Vertical integral of divergence of geopotential flux +'Vertical integral of divergence of geopotential flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; + } +#Vertical integral of divergence of total energy flux +'Vertical integral of divergence of total energy flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; + } +#Vertical integral of divergence of ozone flux +'Vertical integral of divergence of ozone flux' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; + } +#Variance of geopotential +'Variance of geopotential' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; + } +#Covariance of geopotential/temperature +'Covariance of geopotential/temperature' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; + } +#Variance of temperature +'Variance of temperature' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; + } +#Covariance of geopotential/specific humidity +'Covariance of geopotential/specific humidity' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; + } +#Covariance of temperature/specific humidity +'Covariance of temperature/specific humidity' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; + } +#Variance of specific humidity +'Variance of specific humidity' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; + } +#Covariance of u component/geopotential +'Covariance of u component/geopotential' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; + } +#Covariance of u component/temperature +'Covariance of u component/temperature' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; + } +#Covariance of u component/specific humidity +'Covariance of u component/specific humidity' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; + } +#Variance of u component +'Variance of u component' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} diff --git a/definitions/grib2/localConcepts/era/paramId.def b/definitions/grib2/localConcepts/era/paramId.def new file mode 100644 index 000000000..31219cfa9 --- /dev/null +++ b/definitions/grib2/localConcepts/era/paramId.def @@ -0,0 +1,716 @@ +# Automatically generated by ./create_def.pl, do not edit +#Geopotential +'129' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } +#Temperature +'130' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific humidity +'133' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Vertical velocity +'135' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Logarithm of surface pressure +'152' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + } +#Temperature difference +'200130' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 130 ; + } +#Specific humidity difference +'200133' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 133 ; + } +#Vorticity (relative) difference +'200138' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 138 ; + } +#Logarithm of surface pressure difference +'200152' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 152 ; + } +#Divergence difference +'200155' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 155 ; + } +#Ozone mass mixing ratio difference +'200203' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 203 ; + } +#Snow depth +'3066' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Random pattern 1 for sppt +'213001' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 1 ; + } +#Random pattern 2 for sppt +'213002' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 2 ; + } +#Random pattern 3 for sppt +'213003' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 3 ; + } +#Random pattern 1 for SPP scheme +'213101' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 101 ; + } +#Random pattern 2 for SPP scheme +'213102' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 102 ; + } +#Random pattern 3 for SPP scheme +'213103' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 103 ; + } +#Random pattern 4 for SPP scheme +'213104' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 104 ; + } +#Random pattern 5 for SPP scheme +'213105' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 105 ; + } +#Random pattern 6 for SPP scheme +'213106' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 106 ; + } +#Random pattern 7 for SPP scheme +'213107' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 107 ; + } +#Random pattern 8 for SPP scheme +'213108' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 108 ; + } +#Random pattern 9 for SPP scheme +'213109' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 109 ; + } +#Random pattern 10 for SPP scheme +'213110' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 110 ; + } +#Random pattern 11 for SPP scheme +'213111' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 111 ; + } +#Random pattern 12 for SPP scheme +'213112' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 112 ; + } +#Random pattern 13 for SPP scheme +'213113' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 113 ; + } +#Random pattern 14 for SPP scheme +'213114' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 114 ; + } +#Random pattern 15 for SPP scheme +'213115' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 115 ; + } +#Random pattern 16 for SPP scheme +'213116' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 116 ; + } +#Random pattern 17 for SPP scheme +'213117' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 117 ; + } +#Random pattern 18 for SPP scheme +'213118' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 118 ; + } +#Random pattern 19 for SPP scheme +'213119' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 119 ; + } +#Random pattern 20 for SPP scheme +'213120' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 120 ; + } +#Random pattern 21 for SPP scheme +'213121' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 121 ; + } +#Random pattern 22 for SPP scheme +'213122' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 122 ; + } +#Random pattern 23 for SPP scheme +'213123' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 123 ; + } +#Random pattern 24 for SPP scheme +'213124' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 124 ; + } +#Random pattern 25 for SPP scheme +'213125' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 125 ; + } +#Random pattern 26 for SPP scheme +'213126' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 126 ; + } +#Random pattern 27 for SPP scheme +'213127' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 127 ; + } +#Random pattern 28 for SPP scheme +'213128' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 128 ; + } +#Random pattern 29 for SPP scheme +'213129' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 129 ; + } +#Random pattern 30 for SPP scheme +'213130' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 130 ; + } +#Random pattern 31 for SPP scheme +'213131' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 131 ; + } +#Random pattern 32 for SPP scheme +'213132' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 132 ; + } +#Random pattern 33 for SPP scheme +'213133' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 133 ; + } +#Random pattern 34 for SPP scheme +'213134' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 134 ; + } +#Random pattern 35 for SPP scheme +'213135' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 135 ; + } +#Random pattern 36 for SPP scheme +'213136' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 136 ; + } +#Random pattern 37 for SPP scheme +'213137' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 137 ; + } +#Random pattern 38 for SPP scheme +'213138' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 138 ; + } +#Random pattern 39 for SPP scheme +'213139' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 139 ; + } +#Random pattern 40 for SPP scheme +'213140' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 140 ; + } +#Random pattern 41 for SPP scheme +'213141' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 141 ; + } +#Random pattern 42 for SPP scheme +'213142' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 142 ; + } +#Random pattern 43 for SPP scheme +'213143' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 143 ; + } +#Random pattern 44 for SPP scheme +'213144' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 144 ; + } +#Random pattern 45 for SPP scheme +'213145' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 145 ; + } +#Random pattern 46 for SPP scheme +'213146' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 146 ; + } +#Random pattern 47 for SPP scheme +'213147' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 147 ; + } +#Random pattern 48 for SPP scheme +'213148' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 148 ; + } +#Random pattern 49 for SPP scheme +'213149' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 149 ; + } +#Random pattern 50 for SPP scheme +'213150' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 150 ; + } +#Random pattern 51 for SPP scheme +'213151' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 151 ; + } +#Random pattern 52 for SPP scheme +'213152' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 152 ; + } +#Random pattern 53 for SPP scheme +'213153' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 153 ; + } +#Random pattern 54 for SPP scheme +'213154' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 154 ; + } +#Random pattern 55 for SPP scheme +'213155' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 155 ; + } +#Random pattern 56 for SPP scheme +'213156' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 156 ; + } +#Random pattern 57 for SPP scheme +'213157' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 157 ; + } +#Random pattern 58 for SPP scheme +'213158' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 158 ; + } +#Random pattern 59 for SPP scheme +'213159' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 159 ; + } +#Random pattern 60 for SPP scheme +'213160' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 160 ; + } +#Evaporation from the top of canopy +'228100' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 100 ; + } +#Evaporation from bare soil +'228101' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 101 ; + } +#Evaporation from open water surfaces excluding oceans +'228102' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 102 ; + } +#Evaporation from vegetation transpiration +'228103' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 103 ; + } +#Snow cover +'260038' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Sea water potential temperature +'151129' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; + } +#Sea water practical salinity +'151130' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; + } +#Upward sea water velocity +'151133' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; + } +#Sea water sigma theta +'151138' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; + } +#Surface downward eastward stress +'151153' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; + } +#Surface downward northward stress +'151154' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; + } +#Surface geopotential +'162051' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; + } +#Vertical integral of temperature +'162054' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; + } +#Vertical integral of cloud liquid water +'162056' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; + } +#Vertical integral of cloud frozen water +'162057' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; + } +#Vertical integral of ozone +'162058' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; + } +#Vertical integral of energy conversion +'162064' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; + } +#Vertical integral of eastward mass flux +'162065' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; + } +#Vertical integral of northward mass flux +'162066' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; + } +#Vertical integral of eastward kinetic energy flux +'162067' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; + } +#Vertical integral of northward kinetic energy flux +'162068' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; + } +#Vertical integral of eastward geopotential flux +'162073' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; + } +#Vertical integral of northward geopotential flux +'162074' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; + } +#Vertical integral of eastward total energy flux +'162075' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; + } +#Vertical integral of northward total energy flux +'162076' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; + } +#Vertical integral of eastward ozone flux +'162077' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; + } +#Vertical integral of northward ozone flux +'162078' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; + } +#Vertical integral of divergence of mass flux +'162081' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; + } +#Vertical integral of divergence of kinetic energy flux +'162082' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; + } +#Vertical integral of divergence of thermal energy flux +'162083' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; + } +#Vertical integral of divergence of geopotential flux +'162085' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; + } +#Vertical integral of divergence of total energy flux +'162086' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; + } +#Vertical integral of divergence of ozone flux +'162087' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; + } +#Variance of geopotential +'162206' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; + } +#Covariance of geopotential/temperature +'162207' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; + } +#Variance of temperature +'162208' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; + } +#Covariance of geopotential/specific humidity +'162209' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; + } +#Covariance of temperature/specific humidity +'162210' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; + } +#Variance of specific humidity +'162211' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; + } +#Covariance of u component/geopotential +'162212' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; + } +#Covariance of u component/temperature +'162213' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; + } +#Covariance of u component/specific humidity +'162214' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; + } +#Variance of u component +'162215' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} diff --git a/definitions/grib2/localConcepts/era/shortName.def b/definitions/grib2/localConcepts/era/shortName.def new file mode 100644 index 000000000..beb0f3d79 --- /dev/null +++ b/definitions/grib2/localConcepts/era/shortName.def @@ -0,0 +1,716 @@ +# Automatically generated by ./create_def.pl, do not edit +#Geopotential +'z' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } +#Temperature +'t' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific humidity +'q' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Vertical velocity +'w' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Logarithm of surface pressure +'lnsp' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + } +#Temperature difference +'tdiff' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 130 ; + } +#Specific humidity difference +'qdiff' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 133 ; + } +#Vorticity (relative) difference +'vodiff' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 138 ; + } +#Logarithm of surface pressure difference +'lnspdiff' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 152 ; + } +#Divergence difference +'ddiff' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 155 ; + } +#Ozone mass mixing ratio difference +'o3diff' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 203 ; + } +#Snow depth +'sde' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Random pattern 1 for sppt +'sppt1' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 1 ; + } +#Random pattern 2 for sppt +'sppt2' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 2 ; + } +#Random pattern 3 for sppt +'sppt3' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 3 ; + } +#Random pattern 1 for SPP scheme +'spp1' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 101 ; + } +#Random pattern 2 for SPP scheme +'spp2' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 102 ; + } +#Random pattern 3 for SPP scheme +'spp3' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 103 ; + } +#Random pattern 4 for SPP scheme +'spp4' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 104 ; + } +#Random pattern 5 for SPP scheme +'spp5' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 105 ; + } +#Random pattern 6 for SPP scheme +'spp6' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 106 ; + } +#Random pattern 7 for SPP scheme +'spp7' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 107 ; + } +#Random pattern 8 for SPP scheme +'spp8' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 108 ; + } +#Random pattern 9 for SPP scheme +'spp9' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 109 ; + } +#Random pattern 10 for SPP scheme +'spp10' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 110 ; + } +#Random pattern 11 for SPP scheme +'spp11' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 111 ; + } +#Random pattern 12 for SPP scheme +'spp12' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 112 ; + } +#Random pattern 13 for SPP scheme +'spp13' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 113 ; + } +#Random pattern 14 for SPP scheme +'spp14' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 114 ; + } +#Random pattern 15 for SPP scheme +'spp15' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 115 ; + } +#Random pattern 16 for SPP scheme +'spp16' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 116 ; + } +#Random pattern 17 for SPP scheme +'spp17' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 117 ; + } +#Random pattern 18 for SPP scheme +'spp18' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 118 ; + } +#Random pattern 19 for SPP scheme +'spp19' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 119 ; + } +#Random pattern 20 for SPP scheme +'spp20' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 120 ; + } +#Random pattern 21 for SPP scheme +'spp21' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 121 ; + } +#Random pattern 22 for SPP scheme +'spp22' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 122 ; + } +#Random pattern 23 for SPP scheme +'spp23' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 123 ; + } +#Random pattern 24 for SPP scheme +'spp24' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 124 ; + } +#Random pattern 25 for SPP scheme +'spp25' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 125 ; + } +#Random pattern 26 for SPP scheme +'spp26' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 126 ; + } +#Random pattern 27 for SPP scheme +'spp27' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 127 ; + } +#Random pattern 28 for SPP scheme +'spp28' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 128 ; + } +#Random pattern 29 for SPP scheme +'spp29' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 129 ; + } +#Random pattern 30 for SPP scheme +'spp30' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 130 ; + } +#Random pattern 31 for SPP scheme +'spp31' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 131 ; + } +#Random pattern 32 for SPP scheme +'spp32' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 132 ; + } +#Random pattern 33 for SPP scheme +'spp33' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 133 ; + } +#Random pattern 34 for SPP scheme +'spp34' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 134 ; + } +#Random pattern 35 for SPP scheme +'spp35' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 135 ; + } +#Random pattern 36 for SPP scheme +'spp36' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 136 ; + } +#Random pattern 37 for SPP scheme +'spp37' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 137 ; + } +#Random pattern 38 for SPP scheme +'spp38' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 138 ; + } +#Random pattern 39 for SPP scheme +'spp39' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 139 ; + } +#Random pattern 40 for SPP scheme +'spp40' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 140 ; + } +#Random pattern 41 for SPP scheme +'spp41' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 141 ; + } +#Random pattern 42 for SPP scheme +'spp42' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 142 ; + } +#Random pattern 43 for SPP scheme +'spp43' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 143 ; + } +#Random pattern 44 for SPP scheme +'spp44' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 144 ; + } +#Random pattern 45 for SPP scheme +'spp45' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 145 ; + } +#Random pattern 46 for SPP scheme +'spp46' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 146 ; + } +#Random pattern 47 for SPP scheme +'spp47' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 147 ; + } +#Random pattern 48 for SPP scheme +'spp48' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 148 ; + } +#Random pattern 49 for SPP scheme +'spp49' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 149 ; + } +#Random pattern 50 for SPP scheme +'spp50' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 150 ; + } +#Random pattern 51 for SPP scheme +'spp51' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 151 ; + } +#Random pattern 52 for SPP scheme +'spp52' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 152 ; + } +#Random pattern 53 for SPP scheme +'spp53' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 153 ; + } +#Random pattern 54 for SPP scheme +'spp54' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 154 ; + } +#Random pattern 55 for SPP scheme +'spp55' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 155 ; + } +#Random pattern 56 for SPP scheme +'spp56' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 156 ; + } +#Random pattern 57 for SPP scheme +'spp57' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 157 ; + } +#Random pattern 58 for SPP scheme +'spp58' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 158 ; + } +#Random pattern 59 for SPP scheme +'spp59' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 159 ; + } +#Random pattern 60 for SPP scheme +'spp60' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 160 ; + } +#Evaporation from the top of canopy +'evatc' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 100 ; + } +#Evaporation from bare soil +'evabs' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 101 ; + } +#Evaporation from open water surfaces excluding oceans +'evaow' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 102 ; + } +#Evaporation from vegetation transpiration +'evavt' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 103 ; + } +#Snow cover +'snowc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Sea water potential temperature +'thetao' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; + } +#Sea water practical salinity +'so' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; + } +#Upward sea water velocity +'wo' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; + } +#Sea water sigma theta +'sigmat' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; + } +#Surface downward eastward stress +'taueo' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; + } +#Surface downward northward stress +'tauno' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; + } +#Surface geopotential +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; + } +#Vertical integral of temperature +'vit' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; + } +#Vertical integral of cloud liquid water +'vilw' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; + } +#Vertical integral of cloud frozen water +'viiw' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; + } +#Vertical integral of ozone +'vioz' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; + } +#Vertical integral of energy conversion +'viec' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; + } +#Vertical integral of eastward mass flux +'vimae' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; + } +#Vertical integral of northward mass flux +'viman' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; + } +#Vertical integral of eastward kinetic energy flux +'vikee' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; + } +#Vertical integral of northward kinetic energy flux +'viken' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; + } +#Vertical integral of eastward geopotential flux +'vige' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; + } +#Vertical integral of northward geopotential flux +'vign' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; + } +#Vertical integral of eastward total energy flux +'vitoee' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; + } +#Vertical integral of northward total energy flux +'vitoen' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; + } +#Vertical integral of eastward ozone flux +'vioze' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; + } +#Vertical integral of northward ozone flux +'viozn' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; + } +#Vertical integral of divergence of mass flux +'vimad' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; + } +#Vertical integral of divergence of kinetic energy flux +'viked' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; + } +#Vertical integral of divergence of thermal energy flux +'vithed' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; + } +#Vertical integral of divergence of geopotential flux +'vigd' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; + } +#Vertical integral of divergence of total energy flux +'vitoed' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; + } +#Vertical integral of divergence of ozone flux +'viozd' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; + } +#Variance of geopotential +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; + } +#Covariance of geopotential/temperature +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; + } +#Variance of temperature +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; + } +#Covariance of geopotential/specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; + } +#Covariance of temperature/specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; + } +#Variance of specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; + } +#Covariance of u component/geopotential +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; + } +#Covariance of u component/temperature +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; + } +#Covariance of u component/specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; + } +#Variance of u component +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} diff --git a/definitions/grib2/localConcepts/era/units.def b/definitions/grib2/localConcepts/era/units.def new file mode 100644 index 000000000..95c5b4af8 --- /dev/null +++ b/definitions/grib2/localConcepts/era/units.def @@ -0,0 +1,716 @@ +# Automatically generated by ./create_def.pl, do not edit +#Geopotential +'m**2 s**-2' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } +#Temperature +'K' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Specific humidity +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Vertical velocity +'Pa s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Logarithm of surface pressure +'Numeric' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 25 ; + typeOfFirstFixedSurface = 105 ; + } +#Temperature difference +'K' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 130 ; + } +#Specific humidity difference +'kg kg**-1' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 133 ; + } +#Vorticity (relative) difference +'s**-1' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 138 ; + } +#Logarithm of surface pressure difference +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 152 ; + } +#Divergence difference +'s**-1' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 155 ; + } +#Ozone mass mixing ratio difference +'kg kg**-1' = { + discipline = 192 ; + parameterCategory = 200 ; + parameterNumber = 203 ; + } +#Snow depth +'m' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Random pattern 1 for sppt +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 1 ; + } +#Random pattern 2 for sppt +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 2 ; + } +#Random pattern 3 for sppt +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 3 ; + } +#Random pattern 1 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 101 ; + } +#Random pattern 2 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 102 ; + } +#Random pattern 3 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 103 ; + } +#Random pattern 4 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 104 ; + } +#Random pattern 5 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 105 ; + } +#Random pattern 6 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 106 ; + } +#Random pattern 7 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 107 ; + } +#Random pattern 8 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 108 ; + } +#Random pattern 9 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 109 ; + } +#Random pattern 10 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 110 ; + } +#Random pattern 11 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 111 ; + } +#Random pattern 12 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 112 ; + } +#Random pattern 13 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 113 ; + } +#Random pattern 14 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 114 ; + } +#Random pattern 15 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 115 ; + } +#Random pattern 16 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 116 ; + } +#Random pattern 17 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 117 ; + } +#Random pattern 18 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 118 ; + } +#Random pattern 19 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 119 ; + } +#Random pattern 20 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 120 ; + } +#Random pattern 21 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 121 ; + } +#Random pattern 22 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 122 ; + } +#Random pattern 23 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 123 ; + } +#Random pattern 24 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 124 ; + } +#Random pattern 25 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 125 ; + } +#Random pattern 26 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 126 ; + } +#Random pattern 27 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 127 ; + } +#Random pattern 28 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 128 ; + } +#Random pattern 29 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 129 ; + } +#Random pattern 30 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 130 ; + } +#Random pattern 31 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 131 ; + } +#Random pattern 32 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 132 ; + } +#Random pattern 33 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 133 ; + } +#Random pattern 34 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 134 ; + } +#Random pattern 35 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 135 ; + } +#Random pattern 36 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 136 ; + } +#Random pattern 37 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 137 ; + } +#Random pattern 38 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 138 ; + } +#Random pattern 39 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 139 ; + } +#Random pattern 40 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 140 ; + } +#Random pattern 41 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 141 ; + } +#Random pattern 42 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 142 ; + } +#Random pattern 43 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 143 ; + } +#Random pattern 44 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 144 ; + } +#Random pattern 45 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 145 ; + } +#Random pattern 46 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 146 ; + } +#Random pattern 47 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 147 ; + } +#Random pattern 48 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 148 ; + } +#Random pattern 49 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 149 ; + } +#Random pattern 50 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 150 ; + } +#Random pattern 51 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 151 ; + } +#Random pattern 52 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 152 ; + } +#Random pattern 53 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 153 ; + } +#Random pattern 54 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 154 ; + } +#Random pattern 55 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 155 ; + } +#Random pattern 56 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 156 ; + } +#Random pattern 57 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 157 ; + } +#Random pattern 58 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 158 ; + } +#Random pattern 59 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 159 ; + } +#Random pattern 60 for SPP scheme +'dimensionless' = { + discipline = 192 ; + parameterCategory = 213 ; + parameterNumber = 160 ; + } +#Evaporation from the top of canopy +'m of water equivalent' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 100 ; + } +#Evaporation from bare soil +'m of water equivalent' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 101 ; + } +#Evaporation from open water surfaces excluding oceans +'m of water equivalent' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 102 ; + } +#Evaporation from vegetation transpiration +'m of water equivalent' = { + discipline = 192 ; + parameterCategory = 228 ; + parameterNumber = 103 ; + } +#Snow cover +'%' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Sea water potential temperature +'deg C' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 129 ; + } +#Sea water practical salinity +'psu' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 130 ; + } +#Upward sea water velocity +'m s**-1' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 133 ; + } +#Sea water sigma theta +'kg m**-3' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 138 ; + } +#Surface downward eastward stress +'N m**-2' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 153 ; + } +#Surface downward northward stress +'N m**-2' = { + discipline = 192 ; + parameterCategory = 151 ; + parameterNumber = 154 ; + } +#Surface geopotential +'m**2 s**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 51 ; + } +#Vertical integral of temperature +'K kg m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 54 ; + } +#Vertical integral of cloud liquid water +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 56 ; + } +#Vertical integral of cloud frozen water +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 57 ; + } +#Vertical integral of ozone +'kg m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 58 ; + } +#Vertical integral of energy conversion +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 64 ; + } +#Vertical integral of eastward mass flux +'kg m**-1 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 65 ; + } +#Vertical integral of northward mass flux +'kg m**-1 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 66 ; + } +#Vertical integral of eastward kinetic energy flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 67 ; + } +#Vertical integral of northward kinetic energy flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 68 ; + } +#Vertical integral of eastward geopotential flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 73 ; + } +#Vertical integral of northward geopotential flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 74 ; + } +#Vertical integral of eastward total energy flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 75 ; + } +#Vertical integral of northward total energy flux +'W m**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 76 ; + } +#Vertical integral of eastward ozone flux +'kg m**-1 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 77 ; + } +#Vertical integral of northward ozone flux +'kg m**-1 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 78 ; + } +#Vertical integral of divergence of mass flux +'kg m**-2 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 81 ; + } +#Vertical integral of divergence of kinetic energy flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 82 ; + } +#Vertical integral of divergence of thermal energy flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 83 ; + } +#Vertical integral of divergence of geopotential flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 85 ; + } +#Vertical integral of divergence of total energy flux +'W m**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 86 ; + } +#Vertical integral of divergence of ozone flux +'kg m**-2 s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 87 ; + } +#Variance of geopotential +'m**4 s**-4' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 206 ; + } +#Covariance of geopotential/temperature +'m**2 K s**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 207 ; + } +#Variance of temperature +'K**2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 208 ; + } +#Covariance of geopotential/specific humidity +'m**2 s**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 209 ; + } +#Covariance of temperature/specific humidity +'K' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 210 ; + } +#Variance of specific humidity +'~' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 211 ; + } +#Covariance of u component/geopotential +'m**3 s**-3' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 212 ; + } +#Covariance of u component/temperature +'m s**-1 K' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 213 ; + } +#Covariance of u component/specific humidity +'m s**-1' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 214 ; + } +#Variance of u component +'m**2 s**-2' = { + discipline = 192 ; + parameterCategory = 162 ; + parameterNumber = 215 ; +} diff --git a/definitions/grib2/localConcepts/era6/cfName.def b/definitions/grib2/localConcepts/era6/cfName.def index b4593411b..04675741a 100644 --- a/definitions/grib2/localConcepts/era6/cfName.def +++ b/definitions/grib2/localConcepts/era6/cfName.def @@ -42,6 +42,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'surface_albedo' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation 'lwe_thickness_of_water_evaporation_amount' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/name.def b/definitions/grib2/localConcepts/era6/name.def index a716f4abd..b5c4fefb8 100644 --- a/definitions/grib2/localConcepts/era6/name.def +++ b/definitions/grib2/localConcepts/era6/name.def @@ -124,6 +124,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'Albedo (climatological)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation 'Evaporation' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/paramId.def b/definitions/grib2/localConcepts/era6/paramId.def index 48ebc11f2..85dc31997 100644 --- a/definitions/grib2/localConcepts/era6/paramId.def +++ b/definitions/grib2/localConcepts/era6/paramId.def @@ -124,6 +124,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'174' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation '182' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/shortName.def b/definitions/grib2/localConcepts/era6/shortName.def index 02efcff3c..0b9c836b9 100644 --- a/definitions/grib2/localConcepts/era6/shortName.def +++ b/definitions/grib2/localConcepts/era6/shortName.def @@ -124,6 +124,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'al' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation 'e' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/era6/units.def b/definitions/grib2/localConcepts/era6/units.def index 828da275e..699b0c19a 100644 --- a/definitions/grib2/localConcepts/era6/units.def +++ b/definitions/grib2/localConcepts/era6/units.def @@ -124,6 +124,14 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Albedo (climatological) +'(0 - 1)' = { + localTablesVersion = 1 ; + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + typeOfGeneratingProcess = 9 ; + } #Evaporation 'm of water equivalent' = { localTablesVersion = 1 ; diff --git a/definitions/grib2/localConcepts/kwbc/cfVarName.def b/definitions/grib2/localConcepts/kwbc/cfVarName.def new file mode 100644 index 000000000..06c621dd5 --- /dev/null +++ b/definitions/grib2/localConcepts/kwbc/cfVarName.def @@ -0,0 +1,1915 @@ +# Automatically generated by ./create_def.pl, do not edit +#Convective available potential energy +'cape' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 6 ; + } +#Snow phase change heat flux +'snohf' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 192 ; + } +#Condensate +'tcond' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 195 ; + } +#Horizontal moisture convergence +'mconv' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 197 ; + } +#Categorical rain +'crain' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 192 ; + } +#Categorical freezing rain +'cfrzr' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + } +#Categorical ice pellets +'cicep' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 194 ; + } +#Categorical snow +'csnow' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + } +#Convective precipitation rate +'cprat' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 196 ; + } +#Percent frozen precipitation +'cpofp' = { + discipline = 1 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + } +#Potential evaporation +'pevap' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 199 ; + } +#Snow cover +'snowc' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 201 ; + } +#Rain fraction of total cloud water +'frain' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 202 ; + } +#Rime factor +'rime' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 203 ; + } +#Total column integrated rain +'tcolr' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 204 ; + } +#Total column integrated snow +'tcols' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 205 ; + } +#Water equivalent of accumulated snow depth (deprecated) +'sdwe' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + } +#Vertical speed shear +'vwsh' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 192 ; + } +#Horizontal momentum flux +'mflx' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 193 ; + } +#U-component storm motion +'ustm' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 194 ; + } +#V-component storm motion +'vstm' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 195 ; + } +#Drag coefficient +'cd' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 196 ; + } +#Frictional velocity +'fricv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 197 ; + } +#5-wave geopotential height +'wavh5' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 193 ; + } +#Zonal flux of gravity wave stress +'u-gwd' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 194 ; + } +#Meridional flux of gravity wave stress +'v-gwd' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 195 ; + } +#5-wave geopotential height anomaly +'wava5' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 197 ; + } +#Downward short-wave radiation flux +'dswrf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 192 ; + } +#Upward short-wave radiation flux +'uswrf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 193 ; + } +#UV index +'uvi' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 196 ; + } +#Downward long-wave radiation flux +'dlwrf' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 192 ; + } +#Upward long-wave radiation flux +'ulwrf' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 193 ; + } +#Non-convective cloud cover +'cdlyr' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 192 ; + } +#Cloud work function +'cwork' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 193 ; + } +#Convective cloud efficiency +'cuefi' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 194 ; + } +#Total column-integrated cloud water +'tcolw' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 196 ; + } +#Total column-integrated cloud ice +'tcoli' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 197 ; + } +#Total column-integrated condensate +'tcolc' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 198 ; + } +#Ice fraction of total condensate +'fice' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 199 ; + } +#Surface lifted index +'lftx' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 192 ; + } +#Best (4-layer) lifted index +'lftx4' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 193 ; + } +#Ozone mixing ratio +'o3mr' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 192 ; + } +#Maximum snow albedo +'mxsalb' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 192 ; + } +#Snow free albedo +'snfalb' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 193 ; + } +#Seconds prior to initial reference time (defined in Section 1) +'tsec' = { + discipline = 0 ; + parameterCategory = 191 ; + parameterNumber = 194 ; + } +#Baseflow-groundwater runoff +'bgrun' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 192 ; + } +#Storm surface runoff +'ssrun' = { + discipline = 1 ; + parameterCategory = 0 ; + parameterNumber = 193 ; + } +#Volumetric soil moisture content +'soilw' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 192 ; + } +#Ground heat flux +'gflux' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 193 ; + } +#Moisture availability +'mstav' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 194 ; + } +#Exchange coefficient +'sfexc' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 195 ; + } +#Plant canopy surface water +'cnwat' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 196 ; + } +#Blackadar mixing length scale +'bmixl' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 197 ; + } +#Canopy conductance +'ccond' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 199 ; + } +#Minimal stomatal resistance +'rsmin' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 200 ; + } +#Solar parameter in canopy conductance +'rcs' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + } +#Temperature parameter in canopy conductance +'rct' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 203 ; + } +#Soil moisture parameter in canopy conductance +'rcsol' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 205 ; + } +#Humidity parameter in canopy conductance +'rcq' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + } +#Liquid volumetric soil moisture (non-frozen) +'soill' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 192 ; + } +#Number of soil layers in root zone +'rlyrs' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 193 ; + } +#Transpiration stress-onset (soil moisture) +'smref' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 195 ; + } +#Direct evaporation cease (soil moisture) +'smdry' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 196 ; + } +#Soil porosity +'poros' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 197 ; + } +#Temperature tendency by all radiation +'ttrad' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 193 ; + } +#Relative Error Variance +'rev' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 194 ; + } +#Large Scale Condensate Heating rate +'lrghr' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 195 ; + } +#Deep Convective Heating rate +'cnvhr' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 196 ; + } +#Total Downward Heat Flux at Surface +'thflx' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 197 ; + } +#Temperature Tendency By All Physics +'ttdia' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 198 ; + } +#Temperature Tendency By Non-radiation Physics +'ttphy' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 199 ; + } +#Standard Dev. of IR Temp. over 1x1 deg. area +'tsd1d' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 200 ; + } +#Shallow Convective Heating rate +'shahr' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + } +#Vertical Diffusion Heating rate +'vdfhr' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 202 ; + } +#Potential temperature at top of viscous sublayer +'thz0' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 203 ; + } +#Tropical Cyclone Heat Potential +'tchp' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 204 ; + } +#Minimum Relative Humidity +'minrh' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 198 ; + } +#Total Icing Potential Diagnostic +'tipd' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 206 ; + } +#Number concentration for ice particles +'ncip' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 207 ; + } +#Snow temperature +'snot' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 208 ; + } +#Total column-integrated supercooled liquid water +'tclsw' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 209 ; + } +#Total column-integrated melting ice +'tcolm' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 210 ; + } +#Evaporation - Precipitation +'emnp' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 211 ; + } +#Sublimation (evaporation from snow) +'sbsno' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 212 ; + } +#Deep Convective Moistening Rate +'cnvmr' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 213 ; + } +#Shallow Convective Moistening Rate +'shamr' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 214 ; + } +#Vertical Diffusion Moistening Rate +'vdfmr' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 215 ; + } +#Condensation Pressure of Parcali Lifted From Indicate Surface +'condp' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 216 ; + } +#Large scale moistening rate +'lrgmr' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 217 ; + } +#Specific humidity at top of viscous sublayer +'qz0' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 218 ; + } +#Maximum specific humidity at 2m +'qmax' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 219 ; + } +#Minimum specific humidity at 2m +'qmin' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 220 ; + } +#Liquid precipitation (rainfall) +'arain' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 221 ; + } +#Snow temperature, depth-avg +'snowt' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 222 ; + } +#Total precipitation (nearest grid point) +'apcpn' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 223 ; + } +#Convective precipitation (nearest grid point) +'acpcpn' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 224 ; + } +#Freezing Rain +'frzr' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 225 ; + } +#Latitude of U Wind Component of Velocity +'lauv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 198 ; + } +#Longitude of U Wind Component of Velocity +'louv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 199 ; + } +#Latitude of V Wind Component of Velocity +'lavv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 200 ; + } +#Longitude of V Wind Component of Velocity +'lovv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 201 ; + } +#Latitude of Pressure Point +'lapp' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 202 ; + } +#Longitude of Pressure Point +'lopp' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 203 ; + } +#Vertical Eddy Diffusivity Heat exchange +'vedh' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 204 ; + } +#Covariance between Meridional and Zonal Components of the wind. +'covmz' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 205 ; + } +#Covariance between Temperature and Zonal Components of the wind. +'covtz' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 206 ; + } +#Covariance between Temperature and Meridional Components of the wind. +'covtm' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 207 ; + } +#Vertical Diffusion Zonal Acceleration +'vdfua' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 208 ; + } +#Vertical Diffusion Meridional Acceleration +'vdfva' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 209 ; + } +#Gravity wave drag zonal acceleration +'gwdu' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 210 ; + } +#Gravity wave drag meridional acceleration +'gwdv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 211 ; + } +#Convective zonal momentum mixing acceleration +'cnvu' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 212 ; + } +#Convective meridional momentum mixing acceleration +'cnvv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 213 ; + } +#Tendency of vertical velocity +'wtend' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 214 ; + } +#Omega (Dp/Dt) divide by density +'omgalf' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 215 ; + } +#Convective Gravity wave drag zonal acceleration +'cngwdu' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 216 ; + } +#Convective Gravity wave drag meridional acceleration +'cngwdv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 217 ; + } +#Velocity Point Model Surface +'lmv' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 218 ; + } +#Potential Vorticity (Mass-Weighted) +'pvmww' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 219 ; + } +#MSLP (Eta model reduction) +'mslet' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 192 ; + } +#MSLP (MAPS System Reduction) +'mslma' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 198 ; + } +#3-hr pressure tendency (Std. Atmos. Reduction) +'tslsa' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 199 ; + } +#Pressure of level from which parcel was lifted +'plpl' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 200 ; + } +#X-gradient of Log Pressure +'lpsx' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 201 ; + } +#Y-gradient of Log Pressure +'lpsy' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 202 ; + } +#X-gradient of Height +'hgtx' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 203 ; + } +#Y-gradient of Height +'hgty' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 204 ; + } +#Layer Thickness +'layth' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 205 ; + } +#Natural Log of Surface Pressure +'nlgsp' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 206 ; + } +#Convective updraft mass flux +'cnvumf' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 207 ; + } +#Convective downdraft mass flux +'cnvdmf' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 208 ; + } +#Convective detrainment mass flux +'cnvdemf' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 209 ; + } +#Mass Point Model Surface +'lmh' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 210 ; + } +#Geopotential Height (nearest grid point) +'hgtn' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 211 ; + } +#Pressure (nearest grid point) +'presn' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 212 ; + } +#UV-B downward solar flux +'duvb' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 194 ; + } +#Clear sky UV-B downward solar flux +'cduvb' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 195 ; + } +#Clear Sky Downward Solar Flux +'csdsf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 196 ; + } +#Solar Radiative Heating Rate +'swhr' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 197 ; + } +#Clear Sky Upward Solar Flux +'csusf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 198 ; + } +#Cloud Forcing Net Solar Flux +'cfnsf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 199 ; + } +#Visible Beam Downward Solar Flux +'vbdsf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 200 ; + } +#Visible Diffuse Downward Solar Flux +'vddsf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 201 ; + } +#Near IR Beam Downward Solar Flux +'nbdsf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 202 ; + } +#Near IR Diffuse Downward Solar Flux +'nddsf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 203 ; + } +#Downward Total radiation Flux +'dtrf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 204 ; + } +#Upward Total radiation Flux +'utrf' = { + discipline = 0 ; + parameterCategory = 4 ; + parameterNumber = 205 ; + } +#Long-Wave Radiative Heating Rate +'lwhr' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 194 ; + } +#Clear Sky Upward Long Wave Flux +'csulf' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 195 ; + } +#Clear Sky Downward Long Wave Flux +'csdlf' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 196 ; + } +#Cloud Forcing Net Long Wave Flux +'cfnlf' = { + discipline = 0 ; + parameterCategory = 5 ; + parameterNumber = 197 ; + } +#Convective Cloud Mass Flux +'mflux' = { + discipline = 0 ; + parameterCategory = 6 ; + parameterNumber = 200 ; + } +#Richardson Number +'ri' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 194 ; + } +#Convective Weather Detection Index +'cwdi' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 195 ; + } +#Updraft Helicity +'uphl' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 197 ; + } +#Leaf Area Index +'lai' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 198 ; + } +#Particulate matter (coarse) +'pmtc' = { + discipline = 0 ; + parameterCategory = 13 ; + parameterNumber = 192 ; + } +#Particulate matter (fine) +'pmtf' = { + discipline = 0 ; + parameterCategory = 13 ; + parameterNumber = 193 ; + } +#Particulate matter (fine) +'lpmtf' = { + discipline = 0 ; + parameterCategory = 13 ; + parameterNumber = 194 ; + } +#Integrated column particulate matter (fine) +'lipmf' = { + discipline = 0 ; + parameterCategory = 13 ; + parameterNumber = 195 ; + } +#Ozone Concentration (PPB) +'ozcon' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 193 ; + } +#Categorical Ozone Concentration +'ozcat' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 194 ; + } +#Ozone vertical diffusion +'vdfoz' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 195 ; + } +#Ozone production +'poz' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 196 ; + } +#Ozone tendency +'toz' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 197 ; + } +#Ozone production from temperature term +'pozt' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 198 ; + } +#Ozone production from col ozone term +'pozo' = { + discipline = 0 ; + parameterCategory = 14 ; + parameterNumber = 199 ; + } +#Derived radar reflectivity backscatter from rain +'refzr' = { + discipline = 0 ; + parameterCategory = 16 ; + parameterNumber = 192 ; + } +#Derived radar reflectivity backscatter from ice +'refzi' = { + discipline = 0 ; + parameterCategory = 16 ; + parameterNumber = 193 ; + } +#Derived radar reflectivity backscatter from parameterized convection +'refzc' = { + discipline = 0 ; + parameterCategory = 16 ; + parameterNumber = 194 ; + } +#Derived radar reflectivity +'refd' = { + discipline = 0 ; + parameterCategory = 16 ; + parameterNumber = 195 ; + } +#Maximum/Composite radar reflectivity +'refc' = { + discipline = 0 ; + parameterCategory = 16 ; + parameterNumber = 196 ; + } +#Lightning +'ltng' = { + discipline = 0 ; + parameterCategory = 17 ; + parameterNumber = 192 ; + } +#Slight risk convective outlook +'srcono' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 194 ; + } +#Moderate risk convective outlook +'mrcono' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 195 ; + } +#High risk convective outlook +'hrcono' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 196 ; + } +#Tornado probability +'torprob' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 197 ; + } +#Hail probability +'hailprob' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 198 ; + } +#Wind probability +'windprob' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 199 ; + } +#Significant Tornado probability +'storprob' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 200 ; + } +#Significant Hail probability +'shailpro' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 201 ; + } +#Significant Wind probability +'swindpro' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 202 ; + } +#Categorical Thunderstorm (1-yes, 0-no) +'tstmc' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 203 ; + } +#Number of mixed layers next to surface +'mixly' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 204 ; + } +#Flight Category +'flght' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 205 ; + } +#Confidence - Ceiling +'cicel' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 206 ; + } +#Confidence - Visibility +'civis' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 207 ; + } +#Confidence - Flight Category +'ciflt' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 208 ; + } +#Low-Level aviation interest +'lavni' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 209 ; + } +#High-Level aviation interest +'havni' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 210 ; + } +#Visible, Black Sky Albedo +'sbsalb' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 211 ; + } +#Visible, White Sky Albedo +'swsalb' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 212 ; + } +#Near IR, Black Sky Albedo +'nbsalb' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 213 ; + } +#Near IR, White Sky Albedo +'nwsalb' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 214 ; + } +#Total Probability of Severe Thunderstorms (Days 2,3) +'prsvr' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 215 ; + } +#Total Probability of Extreme Severe Thunderstorms (Days 2,3) +'prsigsvr' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 216 ; + } +#Supercooled Large Droplet (SLD) Potential +'sipd' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 217 ; + } +#Radiative emissivity +'epsr' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 218 ; + } +#Turbulence Potential Forecast Index +'tpfi' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 219 ; + } +#Volcanic Ash Forecast Transport and Dispersion +'vaftd' = { + discipline = 0 ; + parameterCategory = 19 ; + parameterNumber = 232 ; + } +#Latitude (-90 to +90) +'nlat' = { + discipline = 0 ; + parameterCategory = 191 ; + parameterNumber = 192 ; + } +#East Longitude (0 - 360) +'elon' = { + discipline = 0 ; + parameterCategory = 191 ; + parameterNumber = 193 ; + } +#Model Layer number (From bottom up) +'mlyno' = { + discipline = 0 ; + parameterCategory = 191 ; + parameterNumber = 195 ; + } +#Latitude (nearest neighbor) (-90 to +90) +'nlatn' = { + discipline = 0 ; + parameterCategory = 191 ; + parameterNumber = 196 ; + } +#East Longitude (nearest neighbor) (0 - 360) +'elonn' = { + discipline = 0 ; + parameterCategory = 191 ; + parameterNumber = 197 ; + } +#Probability of Freezing Precipitation +'cpozp' = { + discipline = 1 ; + parameterCategory = 1 ; + parameterNumber = 192 ; + } +#Probability of precipitation exceeding flash flood guidance values +'ppffg' = { + discipline = 1 ; + parameterCategory = 1 ; + parameterNumber = 194 ; + } +#Probability of Wetting Rain, exceeding in 0.10 in a given time period +'cwr' = { + discipline = 1 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + } +#Vegetation Type +'vgtyp' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 198 ; + } +#Wilting Point +'wilt' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 201 ; + } +#Rate of water dropping from canopy to ground +'rdrip' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 206 ; + } +#Ice-free water surface +'icwat' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 207 ; + } +#Surface exchange coefficients for T and Q divided by delta z +'akhs' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 208 ; + } +#Surface exchange coefficients for U and V divided by delta z +'akms' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 209 ; + } +#Vegetation canopy temperature +'vegt' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 210 ; + } +#Surface water storage +'sstor' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 211 ; + } +#Liquid soil moisture content (non-frozen) +'lsoil' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 212 ; + } +#Open water evaporation (standing water) +'ewatr' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 213 ; + } +#Groundwater recharge +'gwrec' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 214 ; + } +#Flood plain recharge +'qrec' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 215 ; + } +#Roughness length for heat +'sfcrh' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 216 ; + } +#Normalized Difference Vegetation Index +'ndvi' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 217 ; + } +#Land-sea coverage (nearest neighbor) [land=1,sea=0] +'landn' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 218 ; + } +#Asymptotic mixing length scale +'amixl' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 219 ; + } +#Water vapor added by precip assimilation +'wvinc' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 220 ; + } +#Water condensate added by precip assimilation +'wcinc' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 221 ; + } +#Water Vapor Flux Convergence (Vertical Int) +'wvconv' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 222 ; + } +#Water Condensate Flux Convergence (Vertical Int) +'wcconv' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 223 ; + } +#Water Vapor Zonal Flux (Vertical Int) +'wvuflx' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 224 ; + } +#Water Vapor Meridional Flux (Vertical Int) +'wvvflx' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 225 ; + } +#Water Condensate Zonal Flux (Vertical Int) +'wcuflx' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 226 ; + } +#Water Condensate Meridional Flux (Vertical Int) +'wcvflx' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 227 ; + } +#Aerodynamic conductance +'acond' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 228 ; + } +#Canopy water evaporation +'evcw' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 229 ; + } +#Transpiration +'trans' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 230 ; + } +#Surface Slope Type +'sltyp' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 194 ; + } +#Direct evaporation from bare soil +'evbs' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 198 ; + } +#Land Surface Precipitation Accumulation +'lspa' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 199 ; + } +#Bare soil surface skin temperature +'baret' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 200 ; + } +#Average surface skin temperature +'avsft' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 201 ; + } +#Effective radiative skin temperature +'radt' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 202 ; + } +#Field Capacity +'fldcp' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 203 ; + } +#Scatterometer Estimated U Wind Component +'usct' = { + discipline = 3 ; + parameterCategory = 1 ; + parameterNumber = 192 ; + } +#Scatterometer Estimated V Wind Component +'vsct' = { + discipline = 3 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + } +#Wave Steepness +'wstp' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 192 ; + } +#Ocean Mixed Layer U Velocity +'omlu' = { + discipline = 10 ; + parameterCategory = 1 ; + parameterNumber = 192 ; + } +#Ocean Mixed Layer V Velocity +'omlv' = { + discipline = 10 ; + parameterCategory = 1 ; + parameterNumber = 193 ; + } +#Barotropic U velocity +'ubaro' = { + discipline = 10 ; + parameterCategory = 1 ; + parameterNumber = 194 ; + } +#Barotropic V velocity +'vbaro' = { + discipline = 10 ; + parameterCategory = 1 ; + parameterNumber = 195 ; + } +#Storm Surge +'surge' = { + discipline = 10 ; + parameterCategory = 3 ; + parameterNumber = 192 ; + } +#Extra Tropical Storm Surge +'etsrg' = { + discipline = 10 ; + parameterCategory = 3 ; + parameterNumber = 193 ; + } +#Ocean Surface Elevation Relative to Geoid +'elevhtml' = { + discipline = 10 ; + parameterCategory = 3 ; + parameterNumber = 194 ; + } +#Sea Surface Height Relative to Geoid +'sshg' = { + discipline = 10 ; + parameterCategory = 3 ; + parameterNumber = 195 ; + } +#Ocean Mixed Layer Potential Density (Reference 2000m)
45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (16-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.205.table b/definitions/grib2/tables/10/4.205.table index 8d425ab9d..3fadf7d80 100644 --- a/definitions/grib2/tables/10/4.205.table +++ b/definitions/grib2/tables/10/4.205.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.206.table b/definitions/grib2/tables/10/4.206.table index 0be7fd4f8..43b0ba137 100644 --- a/definitions/grib2/tables/10/4.206.table +++ b/definitions/grib2/tables/10/4.206.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.207.table b/definitions/grib2/tables/10/4.207.table index fde9eb477..815a5777e 100644 --- a/definitions/grib2/tables/10/4.207.table +++ b/definitions/grib2/tables/10/4.207.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.208.table b/definitions/grib2/tables/10/4.208.table index 196becaaf..23ea97317 100644 --- a/definitions/grib2/tables/10/4.208.table +++ b/definitions/grib2/tables/10/4.208.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.209.table b/definitions/grib2/tables/10/4.209.table index 351c0f431..53c6c5eba 100644 --- a/definitions/grib2/tables/10/4.209.table +++ b/definitions/grib2/tables/10/4.209.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Stable -2 2 Mechanically-driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically-driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.210.table b/definitions/grib2/tables/10/4.210.table index 1c00b8c6f..149b2ba06 100644 --- a/definitions/grib2/tables/10/4.210.table +++ b/definitions/grib2/tables/10/4.210.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.211.table b/definitions/grib2/tables/10/4.211.table index 66ef656f6..b5753f19f 100644 --- a/definitions/grib2/tables/10/4.211.table +++ b/definitions/grib2/tables/10/4.211.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.212.table b/definitions/grib2/tables/10/4.212.table index c59bd24e8..738c45d2c 100644 --- a/definitions/grib2/tables/10/4.212.table +++ b/definitions/grib2/tables/10/4.212.table @@ -1,18 +1,18 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.213.table b/definitions/grib2/tables/10/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/10/4.213.table +++ b/definitions/grib2/tables/10/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.215.table b/definitions/grib2/tables/10/4.215.table index 460888217..5ed37c034 100644 --- a/definitions/grib2/tables/10/4.215.table +++ b/definitions/grib2/tables/10/4.215.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.216.table b/definitions/grib2/tables/10/4.216.table index 4d9a70f86..b51b358f4 100644 --- a/definitions/grib2/tables/10/4.216.table +++ b/definitions/grib2/tables/10/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain # 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/10/4.217.table b/definitions/grib2/tables/10/4.217.table index 51a263a99..6a014c9c3 100644 --- a/definitions/grib2/tables/10/4.217.table +++ b/definitions/grib2/tables/10/4.217.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.218.table b/definitions/grib2/tables/10/4.218.table index d4b2ab843..b6087448f 100644 --- a/definitions/grib2/tables/10/4.218.table +++ b/definitions/grib2/tables/10/4.218.table @@ -1,38 +1,38 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation / crops -15 15 Permanent snow / ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -# 19-96 Reserved -97 97 Snow / ice on land -98 98 Snow / ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud / fog / Stratus -102 102 Low cloud / Stratocumulus -103 103 Low cloud / unknown type -104 104 Medium cloud / Nimbostratus -105 105 Medium cloud / Altostratus -106 106 Medium cloud / unknown type -107 107 High cloud / Cumulus -108 108 High cloud / Cirrus -109 109 High cloud / unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation / crops +15 15 Permanent snow / ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +# 19-96 Reserved +97 97 Snow / ice on land +98 98 Snow / ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud / fog / Stratus +102 102 Low cloud / Stratocumulus +103 103 Low cloud / unknown type +104 104 Medium cloud / Nimbostratus +105 105 Medium cloud / Altostratus +106 106 Medium cloud / unknown type +107 107 High cloud / Cumulus +108 108 High cloud / Cirrus +109 109 High cloud / unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.219.table b/definitions/grib2/tables/10/4.219.table index f10ce468e..a02452fc4 100644 --- a/definitions/grib2/tables/10/4.219.table +++ b/definitions/grib2/tables/10/4.219.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.220.table b/definitions/grib2/tables/10/4.220.table index 9c957eb01..7a18fa1fd 100644 --- a/definitions/grib2/tables/10/4.220.table +++ b/definitions/grib2/tables/10/4.220.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.221.table b/definitions/grib2/tables/10/4.221.table index 5466929c7..eb0b64502 100644 --- a/definitions/grib2/tables/10/4.221.table +++ b/definitions/grib2/tables/10/4.221.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.222.table b/definitions/grib2/tables/10/4.222.table index c54194e29..f554a7f3d 100644 --- a/definitions/grib2/tables/10/4.222.table +++ b/definitions/grib2/tables/10/4.222.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.223.table b/definitions/grib2/tables/10/4.223.table index b6a9be136..706abab78 100644 --- a/definitions/grib2/tables/10/4.223.table +++ b/definitions/grib2/tables/10/4.223.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing value +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing value diff --git a/definitions/grib2/tables/10/4.224.table b/definitions/grib2/tables/10/4.224.table index af846f841..cf67496b8 100644 --- a/definitions/grib2/tables/10/4.224.table +++ b/definitions/grib2/tables/10/4.224.table @@ -1,18 +1,18 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/10/4.227.table b/definitions/grib2/tables/10/4.227.table index 6a98d49d0..7676664e4 100644 --- a/definitions/grib2/tables/10/4.227.table +++ b/definitions/grib2/tables/10/4.227.table @@ -4,6 +4,6 @@ 2 2 Convective 3 3 Stratiform 4 4 Freezing -# 5-191 Reserved +# 5-191 Reserved # 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/10/4.3.table b/definitions/grib2/tables/10/4.3.table index 68e2cc83f..8a4e919c9 100644 --- a/definitions/grib2/tables/10/4.3.table +++ b/definitions/grib2/tables/10/4.3.table @@ -1,16 +1,16 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.4.table b/definitions/grib2/tables/10/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/10/4.4.table +++ b/definitions/grib2/tables/10/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.5.table b/definitions/grib2/tables/10/4.5.table index 1ada3eb23..c3b8aec5d 100644 --- a/definitions/grib2/tables/10/4.5.table +++ b/definitions/grib2/tables/10/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface 2 2 Cloud base level 3 3 Level of cloud tops @@ -12,11 +12,11 @@ 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,7 +25,7 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level 112 112 Reserved 113 113 Logarithmic hybrid level @@ -36,7 +36,7 @@ 119 hpl Hybrid pressure level # 120-149 Reserved 150 150 Generalized vertical height coordinate -# 151-159 Reserved +# 151-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom @@ -44,6 +44,6 @@ 164 164 Bottom of thermally active sediment layer 165 165 Bottom of sediment layer penetrated by thermal wave 166 sfc Mixing layer -# 167-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 167-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.6.table b/definitions/grib2/tables/10/4.6.table index 54f2993c3..eaa5c4362 100644 --- a/definitions/grib2/tables/10/4.6.table +++ b/definitions/grib2/tables/10/4.6.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.7.table b/definitions/grib2/tables/10/4.7.table index 23e0d457e..e6d887bdb 100644 --- a/definitions/grib2/tables/10/4.7.table +++ b/definitions/grib2/tables/10/4.7.table @@ -1,14 +1,14 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.8.table b/definitions/grib2/tables/10/4.8.table index 37a6cf767..d06153079 100644 --- a/definitions/grib2/tables/10/4.8.table +++ b/definitions/grib2/tables/10/4.8.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.9.table b/definitions/grib2/tables/10/4.9.table index 19e64a3d2..5243e58dd 100644 --- a/definitions/grib2/tables/10/4.9.table +++ b/definitions/grib2/tables/10/4.9.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/4.91.table b/definitions/grib2/tables/10/4.91.table index 97b1c70ad..ae31ed61c 100644 --- a/definitions/grib2/tables/10/4.91.table +++ b/definitions/grib2/tables/10/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit 11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/10/5.1.table b/definitions/grib2/tables/10/5.1.table index 100d4106d..158a35850 100644 --- a/definitions/grib2/tables/10/5.1.table +++ b/definitions/grib2/tables/10/5.1.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/5.2.table b/definitions/grib2/tables/10/5.2.table index 7a4500ecd..d12b46fbd 100644 --- a/definitions/grib2/tables/10/5.2.table +++ b/definitions/grib2/tables/10/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use +# 12-191 Reserved +# 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/10/5.3.table b/definitions/grib2/tables/10/5.3.table index 705fa6524..6f228aeec 100644 --- a/definitions/grib2/tables/10/5.3.table +++ b/definitions/grib2/tables/10/5.3.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/5.4.table b/definitions/grib2/tables/10/5.4.table index 8133367a5..f844f557e 100644 --- a/definitions/grib2/tables/10/5.4.table +++ b/definitions/grib2/tables/10/5.4.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/5.40.table b/definitions/grib2/tables/10/5.40.table index 0d56ad0e0..2431eb547 100644 --- a/definitions/grib2/tables/10/5.40.table +++ b/definitions/grib2/tables/10/5.40.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/10/5.5.table b/definitions/grib2/tables/10/5.5.table index 5d625dbda..f2216e273 100644 --- a/definitions/grib2/tables/10/5.5.table +++ b/definitions/grib2/tables/10/5.5.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/5.6.table b/definitions/grib2/tables/10/5.6.table index 5838e994d..3b0892d37 100644 --- a/definitions/grib2/tables/10/5.6.table +++ b/definitions/grib2/tables/10/5.6.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/10/5.7.table b/definitions/grib2/tables/10/5.7.table index b93aa8130..f056d3059 100644 --- a/definitions/grib2/tables/10/5.7.table +++ b/definitions/grib2/tables/10/5.7.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/10/6.0.table b/definitions/grib2/tables/10/6.0.table index f539b26d7..a8f30f5a4 100644 --- a/definitions/grib2/tables/10/6.0.table +++ b/definitions/grib2/tables/10/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/11/0.0.table b/definitions/grib2/tables/11/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/11/0.0.table +++ b/definitions/grib2/tables/11/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/1.1.table b/definitions/grib2/tables/11/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/11/1.1.table +++ b/definitions/grib2/tables/11/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/11/1.2.table b/definitions/grib2/tables/11/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/11/1.2.table +++ b/definitions/grib2/tables/11/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/1.3.table b/definitions/grib2/tables/11/1.3.table index e8c38878d..34ace7fda 100644 --- a/definitions/grib2/tables/11/1.3.table +++ b/definitions/grib2/tables/11/1.3.table @@ -1,12 +1,12 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products 4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) 6 6 Sub-seasonal to seasonal prediction project (S2S) 7 7 Sub-seasonal to seasonal prediction project test (S2S) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/1.4.table b/definitions/grib2/tables/11/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/11/1.4.table +++ b/definitions/grib2/tables/11/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/11/3.0.table b/definitions/grib2/tables/11/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/11/3.0.table +++ b/definitions/grib2/tables/11/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/11/3.10.table b/definitions/grib2/tables/11/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/11/3.10.table +++ b/definitions/grib2/tables/11/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/11/3.11.table b/definitions/grib2/tables/11/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/11/3.11.table +++ b/definitions/grib2/tables/11/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/11/3.15.table b/definitions/grib2/tables/11/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/11/3.15.table +++ b/definitions/grib2/tables/11/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/3.2.table b/definitions/grib2/tables/11/3.2.table index a2107f6e9..b9574a424 100644 --- a/definitions/grib2/tables/11/3.2.table +++ b/definitions/grib2/tables/11/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame 9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/3.20.table b/definitions/grib2/tables/11/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/11/3.20.table +++ b/definitions/grib2/tables/11/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/3.21.table b/definitions/grib2/tables/11/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/11/3.21.table +++ b/definitions/grib2/tables/11/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/3.3.table b/definitions/grib2/tables/11/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/11/3.3.table +++ b/definitions/grib2/tables/11/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/11/3.4.table b/definitions/grib2/tables/11/3.4.table index 63c8adaaa..ea9cbe829 100644 --- a/definitions/grib2/tables/11/3.4.table +++ b/definitions/grib2/tables/11/3.4.table @@ -1,10 +1,10 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -# 5-8 Reserved +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +# 5-8 Reserved diff --git a/definitions/grib2/tables/11/3.5.table b/definitions/grib2/tables/11/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/11/3.5.table +++ b/definitions/grib2/tables/11/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/11/3.7.table b/definitions/grib2/tables/11/3.7.table index e2dc660dd..2d01b8d52 100644 --- a/definitions/grib2/tables/11/3.7.table +++ b/definitions/grib2/tables/11/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 The complex numbers Fnm. See separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/11/3.8.table b/definitions/grib2/tables/11/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/11/3.8.table +++ b/definitions/grib2/tables/11/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/3.9.table b/definitions/grib2/tables/11/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/11/3.9.table +++ b/definitions/grib2/tables/11/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/11/4.0.table b/definitions/grib2/tables/11/4.0.table index 1c1fe09ab..51b3ccfa7 100644 --- a/definitions/grib2/tables/11/4.0.table +++ b/definitions/grib2/tables/11/4.0.table @@ -1,59 +1,59 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time 8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval 15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -# 35-39 Reserved +# 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents 42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol 46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time 53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time 54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters 60 60 Individual ensemble re-forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time 61 61 Individual ensemble re-forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 55-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +# 55-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/11/4.1.0.table b/definitions/grib2/tables/11/4.1.0.table index 361108860..3413dbad5 100644 --- a/definitions/grib2/tables/11/4.1.0.table +++ b/definitions/grib2/tables/11/4.1.0.table @@ -1,27 +1,27 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.1.1.table b/definitions/grib2/tables/11/4.1.1.table index 29f1dec79..dea5bc49e 100644 --- a/definitions/grib2/tables/11/4.1.1.table +++ b/definitions/grib2/tables/11/4.1.1.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.1.10.table b/definitions/grib2/tables/11/4.1.10.table index 9c8c92b12..e6ce6faf7 100644 --- a/definitions/grib2/tables/11/4.1.10.table +++ b/definitions/grib2/tables/11/4.1.10.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Sub-surface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Sub-surface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.1.2.table b/definitions/grib2/tables/11/4.1.2.table index b90201c63..805836998 100644 --- a/definitions/grib2/tables/11/4.1.2.table +++ b/definitions/grib2/tables/11/4.1.2.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.1.3.table b/definitions/grib2/tables/11/4.1.3.table index fe1d8ae5a..adcbfb051 100644 --- a/definitions/grib2/tables/11/4.1.3.table +++ b/definitions/grib2/tables/11/4.1.3.table @@ -1,8 +1,8 @@ # Code table 4.1 - Parameter category by product discipline. Product discipline 3 - Space products -0 0 Image format products -1 1 Quantitative products -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.10.table b/definitions/grib2/tables/11/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/11/4.10.table +++ b/definitions/grib2/tables/11/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/11/4.11.table b/definitions/grib2/tables/11/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/11/4.11.table +++ b/definitions/grib2/tables/11/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.12.table b/definitions/grib2/tables/11/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/11/4.12.table +++ b/definitions/grib2/tables/11/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.13.table b/definitions/grib2/tables/11/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/11/4.13.table +++ b/definitions/grib2/tables/11/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.14.table b/definitions/grib2/tables/11/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/11/4.14.table +++ b/definitions/grib2/tables/11/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.15.table b/definitions/grib2/tables/11/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/11/4.15.table +++ b/definitions/grib2/tables/11/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.0.table b/definitions/grib2/tables/11/4.2.0.0.table index f7784cc33..e69e087c9 100644 --- a/definitions/grib2/tables/11/4.2.0.0.table +++ b/definitions/grib2/tables/11/4.2.0.0.table @@ -20,6 +20,6 @@ 18 18 Snow temperature (top of snow) (K) 19 19 Turbulent transfer coefficient for heat (Numeric) 20 20 Turbulent diffusion coefficient for heat (m2/s) -# 21-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 21-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.1.table b/definitions/grib2/tables/11/4.2.0.1.table index 827ba1dcf..256732de0 100644 --- a/definitions/grib2/tables/11/4.2.0.1.table +++ b/definitions/grib2/tables/11/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,10 +86,10 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) -# 93-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 93-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.13.table b/definitions/grib2/tables/11/4.2.0.13.table index b9979f0d3..90ab7d1b9 100644 --- a/definitions/grib2/tables/11/4.2.0.13.table +++ b/definitions/grib2/tables/11/4.2.0.13.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.14.table b/definitions/grib2/tables/11/4.2.0.14.table index 4a2a4e128..fca42ccc7 100644 --- a/definitions/grib2/tables/11/4.2.0.14.table +++ b/definitions/grib2/tables/11/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.15.table b/definitions/grib2/tables/11/4.2.0.15.table index 9a178ceb7..5a599a98e 100644 --- a/definitions/grib2/tables/11/4.2.0.15.table +++ b/definitions/grib2/tables/11/4.2.0.15.table @@ -14,6 +14,6 @@ 12 12 Reflectivity of rain (dB) 13 13 Reflectivity of graupel (dB) 14 14 Reflectivity of hail (dB) -# 15-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 15-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.16.table b/definitions/grib2/tables/11/4.2.0.16.table index 39215ab20..18dedb7c0 100644 --- a/definitions/grib2/tables/11/4.2.0.16.table +++ b/definitions/grib2/tables/11/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.18.table b/definitions/grib2/tables/11/4.2.0.18.table index 82fd13da1..fe06e9ea6 100644 --- a/definitions/grib2/tables/11/4.2.0.18.table +++ b/definitions/grib2/tables/11/4.2.0.18.table @@ -8,11 +8,11 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) 13 13 Total deposition (wet + dry) (Bq m-2) -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.19.table b/definitions/grib2/tables/11/4.2.0.19.table index 2aa34464a..90003262e 100644 --- a/definitions/grib2/tables/11/4.2.0.19.table +++ b/definitions/grib2/tables/11/4.2.0.19.table @@ -27,6 +27,6 @@ 25 25 Weather (Code table 4.225) 26 26 Convective outlook (Code table 4.224) 27 27 Icing scenario (Code table 4.227) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.190.table b/definitions/grib2/tables/11/4.2.0.190.table index 39fb55746..3d9d5ff85 100644 --- a/definitions/grib2/tables/11/4.2.0.190.table +++ b/definitions/grib2/tables/11/4.2.0.190.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.191.table b/definitions/grib2/tables/11/4.2.0.191.table index 81230c0e0..4ff12e532 100644 --- a/definitions/grib2/tables/11/4.2.0.191.table +++ b/definitions/grib2/tables/11/4.2.0.191.table @@ -2,6 +2,6 @@ 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/11/4.2.0.2.table b/definitions/grib2/tables/11/4.2.0.2.table index d587f84e9..f0570417b 100644 --- a/definitions/grib2/tables/11/4.2.0.2.table +++ b/definitions/grib2/tables/11/4.2.0.2.table @@ -35,6 +35,6 @@ 33 33 Wind fetch (m) 34 34 Normal wind component (m s-1) 35 35 Tangential wind component (m s-1) -# 36-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 36-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.20.table b/definitions/grib2/tables/11/4.2.0.20.table index 22cea6061..ca90179fe 100644 --- a/definitions/grib2/tables/11/4.2.0.20.table +++ b/definitions/grib2/tables/11/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -25,7 +25,7 @@ 57 57 Total yearly average burden of the atmosphere (mol) 58 58 Total yearly averaged atmospheric loss (mol/s) 59 59 Aerosol number concentration (m-3) -# 60-99 Reserved +# 60-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -37,6 +37,6 @@ 108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) 109 109 Aerosol lidar extinction from satellite (m-1) 110 110 Aerosol lidar extinction from the ground (m-1) -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.3.table b/definitions/grib2/tables/11/4.2.0.3.table index f718c6ea9..08c1c7bc3 100644 --- a/definitions/grib2/tables/11/4.2.0.3.table +++ b/definitions/grib2/tables/11/4.2.0.3.table @@ -26,6 +26,6 @@ 24 24 Anisotropy of sub-gridscale orography (Numeric) 25 25 Natural logarithm of pressure in Pa (Numeric) 26 26 Exner pressure (Numeric) -# 27-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 27-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.4.table b/definitions/grib2/tables/11/4.2.0.4.table index fea4cafc3..336fdb421 100644 --- a/definitions/grib2/tables/11/4.2.0.4.table +++ b/definitions/grib2/tables/11/4.2.0.4.table @@ -12,9 +12,9 @@ 10 10 Photosynthetically active radiation (W m-2) 11 11 Net short-wave radiation flux, clear sky (W m-2) 12 12 Downward UV radiation (W m-2) -# 13-49 Reserved +# 13-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) -# 52-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.5.table b/definitions/grib2/tables/11/4.2.0.5.table index b0c93dd3a..86a199ace 100644 --- a/definitions/grib2/tables/11/4.2.0.5.table +++ b/definitions/grib2/tables/11/4.2.0.5.table @@ -6,6 +6,6 @@ 4 4 Upward long-wave radiation flux (W m-2) 5 5 Net long-wave radiation flux (W m-2) 6 6 Net long-wave radiation flux, clear sky (W m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.6.table b/definitions/grib2/tables/11/4.2.0.6.table index a06f4292f..2d088e5fc 100644 --- a/definitions/grib2/tables/11/4.2.0.6.table +++ b/definitions/grib2/tables/11/4.2.0.6.table @@ -35,6 +35,6 @@ 33 33 Sunshine duration (s) 34 34 Surface long-wave effective total cloudiness (Numeric) 35 35 Surface short-wave effective total cloudiness (Numeric) -# 36-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 36-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.0.7.table b/definitions/grib2/tables/11/4.2.0.7.table index 7a7d2008b..6c1794c73 100644 --- a/definitions/grib2/tables/11/4.2.0.7.table +++ b/definitions/grib2/tables/11/4.2.0.7.table @@ -13,8 +13,8 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraft helicity (m2 s-2) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.1.0.table b/definitions/grib2/tables/11/4.2.1.0.table index bf1e3e93f..9c4d129da 100644 --- a/definitions/grib2/tables/11/4.2.1.0.table +++ b/definitions/grib2/tables/11/4.2.1.0.table @@ -6,6 +6,6 @@ 4 4 Snow water equivalent per cent of normal (%) 5 5 Baseflow-groundwater runoff (kg m-2) 6 6 Storm surface runoff (kg m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.1.1.table b/definitions/grib2/tables/11/4.2.1.1.table index cb5117dc8..aa560e479 100644 --- a/definitions/grib2/tables/11/4.2.1.1.table +++ b/definitions/grib2/tables/11/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.10.0.table b/definitions/grib2/tables/11/4.2.10.0.table index b820364fa..43643d405 100644 --- a/definitions/grib2/tables/11/4.2.10.0.table +++ b/definitions/grib2/tables/11/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (s-1) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.10.1.table b/definitions/grib2/tables/11/4.2.10.1.table index ae52b0c26..de6b562b8 100644 --- a/definitions/grib2/tables/11/4.2.10.1.table +++ b/definitions/grib2/tables/11/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.10.191.table b/definitions/grib2/tables/11/4.2.10.191.table index 14085ac9a..6cafbd3d4 100644 --- a/definitions/grib2/tables/11/4.2.10.191.table +++ b/definitions/grib2/tables/11/4.2.10.191.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.10.2.table b/definitions/grib2/tables/11/4.2.10.2.table index a6d9dd0c8..258aeef18 100644 --- a/definitions/grib2/tables/11/4.2.10.2.table +++ b/definitions/grib2/tables/11/4.2.10.2.table @@ -9,6 +9,6 @@ 7 7 Ice divergence (/s) 8 8 Ice temperature (K) 9 9 Ice internal pressure (Pa m) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.10.3.table b/definitions/grib2/tables/11/4.2.10.3.table index 112af09d5..3b9a2df46 100644 --- a/definitions/grib2/tables/11/4.2.10.3.table +++ b/definitions/grib2/tables/11/4.2.10.3.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.10.4.table b/definitions/grib2/tables/11/4.2.10.4.table index d80a32780..91ffb2b29 100644 --- a/definitions/grib2/tables/11/4.2.10.4.table +++ b/definitions/grib2/tables/11/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2 s-1) 6 6 Ocean vertical momentum diffusivity (m2 s-1) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (m-1) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.2.0.table b/definitions/grib2/tables/11/4.2.2.0.table index 9a426a5c2..0632ff414 100644 --- a/definitions/grib2/tables/11/4.2.2.0.table +++ b/definitions/grib2/tables/11/4.2.2.0.table @@ -32,6 +32,6 @@ 30 30 Deciduous forest cover (Proportion) 31 31 Normalized differential vegetation index (NDVI) (Numeric) 32 32 Root depth of vegetation (m) -# 33-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 33-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.2.3.table b/definitions/grib2/tables/11/4.2.2.3.table index e985e41aa..d7db59d5e 100644 --- a/definitions/grib2/tables/11/4.2.2.3.table +++ b/definitions/grib2/tables/11/4.2.2.3.table @@ -22,6 +22,6 @@ 20 20 Column-integrated soil moisture (kg m-2) 21 21 Soil ice (kg m-3) 22 22 Column-integrated soil ice (kg m-2) -# 23-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 23-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.2.4.table b/definitions/grib2/tables/11/4.2.2.4.table index a5f0a3c5c..0992f59db 100644 --- a/definitions/grib2/tables/11/4.2.2.4.table +++ b/definitions/grib2/tables/11/4.2.2.4.table @@ -4,5 +4,5 @@ 2 2 Haines Index (Numeric) 3 3 Fire burned area (%) # 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.3.0.table b/definitions/grib2/tables/11/4.2.3.0.table index 254e56bc8..8c19d43b2 100644 --- a/definitions/grib2/tables/11/4.2.3.0.table +++ b/definitions/grib2/tables/11/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.2.3.1.table b/definitions/grib2/tables/11/4.2.3.1.table index 176ac35fb..af1896b14 100644 --- a/definitions/grib2/tables/11/4.2.3.1.table +++ b/definitions/grib2/tables/11/4.2.3.1.table @@ -17,12 +17,12 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +23 23 Angstrom coefficient +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.201.table b/definitions/grib2/tables/11/4.201.table index dc3926b3f..b9711f69c 100644 --- a/definitions/grib2/tables/11/4.201.table +++ b/definitions/grib2/tables/11/4.201.table @@ -1,10 +1,10 @@ # Code table 4.201 - Precipitation type -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.202.table b/definitions/grib2/tables/11/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/11/4.202.table +++ b/definitions/grib2/tables/11/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.203.table b/definitions/grib2/tables/11/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/11/4.203.table +++ b/definitions/grib2/tables/11/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.204.table b/definitions/grib2/tables/11/4.204.table index 91bcf1814..ffbd89502 100644 --- a/definitions/grib2/tables/11/4.204.table +++ b/definitions/grib2/tables/11/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (16-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (16-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.205.table b/definitions/grib2/tables/11/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/11/4.205.table +++ b/definitions/grib2/tables/11/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.206.table b/definitions/grib2/tables/11/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/11/4.206.table +++ b/definitions/grib2/tables/11/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.207.table b/definitions/grib2/tables/11/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/11/4.207.table +++ b/definitions/grib2/tables/11/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.208.table b/definitions/grib2/tables/11/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/11/4.208.table +++ b/definitions/grib2/tables/11/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.209.table b/definitions/grib2/tables/11/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/11/4.209.table +++ b/definitions/grib2/tables/11/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.210.table b/definitions/grib2/tables/11/4.210.table index 524a6ca73..791878469 100644 --- a/definitions/grib2/tables/11/4.210.table +++ b/definitions/grib2/tables/11/4.210.table @@ -1,6 +1,6 @@ # Code table 4.210 - Contrail intensity -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.211.table b/definitions/grib2/tables/11/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/11/4.211.table +++ b/definitions/grib2/tables/11/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.212.table b/definitions/grib2/tables/11/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/11/4.212.table +++ b/definitions/grib2/tables/11/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.213.table b/definitions/grib2/tables/11/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/11/4.213.table +++ b/definitions/grib2/tables/11/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.215.table b/definitions/grib2/tables/11/4.215.table index 88fda8b8c..c264c6722 100644 --- a/definitions/grib2/tables/11/4.215.table +++ b/definitions/grib2/tables/11/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely-sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.216.table b/definitions/grib2/tables/11/4.216.table index 4d9a70f86..b51b358f4 100644 --- a/definitions/grib2/tables/11/4.216.table +++ b/definitions/grib2/tables/11/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain # 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/11/4.217.table b/definitions/grib2/tables/11/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/11/4.217.table +++ b/definitions/grib2/tables/11/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.218.table b/definitions/grib2/tables/11/4.218.table index 6940a0e41..acf069c32 100644 --- a/definitions/grib2/tables/11/4.218.table +++ b/definitions/grib2/tables/11/4.218.table @@ -1,38 +1,38 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation / crops -15 15 Permanent snow / ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -# 19-96 Reserved -97 97 Snow / ice on land -98 98 Snow / ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud / fog / Stratus -102 102 Low cloud / Stratocumulus -103 103 Low cloud / unknown type -104 104 Medium cloud / Nimbostratus -105 105 Medium cloud / Altostratus -106 106 Medium cloud / unknown type -107 107 High cloud / Cumulus -108 108 High cloud / Cirrus -109 109 High cloud / unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation / crops +15 15 Permanent snow / ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +# 19-96 Reserved +97 97 Snow / ice on land +98 98 Snow / ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud / fog / Stratus +102 102 Low cloud / Stratocumulus +103 103 Low cloud / unknown type +104 104 Medium cloud / Nimbostratus +105 105 Medium cloud / Altostratus +106 106 Medium cloud / unknown type +107 107 High cloud / Cumulus +108 108 High cloud / Cirrus +109 109 High cloud / unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.219.table b/definitions/grib2/tables/11/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/11/4.219.table +++ b/definitions/grib2/tables/11/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.220.table b/definitions/grib2/tables/11/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/11/4.220.table +++ b/definitions/grib2/tables/11/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.221.table b/definitions/grib2/tables/11/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/11/4.221.table +++ b/definitions/grib2/tables/11/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.222.table b/definitions/grib2/tables/11/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/11/4.222.table +++ b/definitions/grib2/tables/11/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.223.table b/definitions/grib2/tables/11/4.223.table index e54719f86..11f629ef5 100644 --- a/definitions/grib2/tables/11/4.223.table +++ b/definitions/grib2/tables/11/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing value +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing value diff --git a/definitions/grib2/tables/11/4.224.table b/definitions/grib2/tables/11/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/11/4.224.table +++ b/definitions/grib2/tables/11/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/11/4.227.table b/definitions/grib2/tables/11/4.227.table index 6a98d49d0..7676664e4 100644 --- a/definitions/grib2/tables/11/4.227.table +++ b/definitions/grib2/tables/11/4.227.table @@ -4,6 +4,6 @@ 2 2 Convective 3 3 Stratiform 4 4 Freezing -# 5-191 Reserved +# 5-191 Reserved # 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/11/4.234.table b/definitions/grib2/tables/11/4.234.table index 78d8fff12..9628e618e 100644 --- a/definitions/grib2/tables/11/4.234.table +++ b/definitions/grib2/tables/11/4.234.table @@ -6,14 +6,14 @@ 5 5 Deciduous broadleaf trees 6 6 Evergreen broadleaf trees 7 7 Tall grass -8 8 Desert -9 9 Tundra +8 8 Desert +9 9 Tundra 10 10 Irrigated crops -11 11 Semidesert +11 11 Semidesert 12 12 Ice caps and glaciers 13 13 Bogs and marshes 14 14 Inland water -15 15 Ocean +15 15 Ocean 16 16 Evergreen shrubs 17 17 Deciduous shrubs 18 18 Mixed forest diff --git a/definitions/grib2/tables/11/4.3.table b/definitions/grib2/tables/11/4.3.table index 8f7d20be3..1681cfc93 100644 --- a/definitions/grib2/tables/11/4.3.table +++ b/definitions/grib2/tables/11/4.3.table @@ -1,16 +1,16 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.4.table b/definitions/grib2/tables/11/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/11/4.4.table +++ b/definitions/grib2/tables/11/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.5.table b/definitions/grib2/tables/11/4.5.table index 1ada3eb23..c3b8aec5d 100644 --- a/definitions/grib2/tables/11/4.5.table +++ b/definitions/grib2/tables/11/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface 2 2 Cloud base level 3 3 Level of cloud tops @@ -12,11 +12,11 @@ 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,7 +25,7 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level 112 112 Reserved 113 113 Logarithmic hybrid level @@ -36,7 +36,7 @@ 119 hpl Hybrid pressure level # 120-149 Reserved 150 150 Generalized vertical height coordinate -# 151-159 Reserved +# 151-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom @@ -44,6 +44,6 @@ 164 164 Bottom of thermally active sediment layer 165 165 Bottom of sediment layer penetrated by thermal wave 166 sfc Mixing layer -# 167-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 167-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.6.table b/definitions/grib2/tables/11/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/11/4.6.table +++ b/definitions/grib2/tables/11/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.7.table b/definitions/grib2/tables/11/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/11/4.7.table +++ b/definitions/grib2/tables/11/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.8.table b/definitions/grib2/tables/11/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/11/4.8.table +++ b/definitions/grib2/tables/11/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.9.table b/definitions/grib2/tables/11/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/11/4.9.table +++ b/definitions/grib2/tables/11/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/4.91.table b/definitions/grib2/tables/11/4.91.table index 97b1c70ad..ae31ed61c 100644 --- a/definitions/grib2/tables/11/4.91.table +++ b/definitions/grib2/tables/11/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit 11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/11/5.1.table b/definitions/grib2/tables/11/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/11/5.1.table +++ b/definitions/grib2/tables/11/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/5.2.table b/definitions/grib2/tables/11/5.2.table index 7a4500ecd..d12b46fbd 100644 --- a/definitions/grib2/tables/11/5.2.table +++ b/definitions/grib2/tables/11/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use +# 12-191 Reserved +# 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/11/5.3.table b/definitions/grib2/tables/11/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/11/5.3.table +++ b/definitions/grib2/tables/11/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/5.4.table b/definitions/grib2/tables/11/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/11/5.4.table +++ b/definitions/grib2/tables/11/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/5.40.table b/definitions/grib2/tables/11/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/11/5.40.table +++ b/definitions/grib2/tables/11/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/11/5.5.table b/definitions/grib2/tables/11/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/11/5.5.table +++ b/definitions/grib2/tables/11/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/5.6.table b/definitions/grib2/tables/11/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/11/5.6.table +++ b/definitions/grib2/tables/11/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/11/5.7.table b/definitions/grib2/tables/11/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/11/5.7.table +++ b/definitions/grib2/tables/11/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/11/6.0.table b/definitions/grib2/tables/11/6.0.table index f539b26d7..a8f30f5a4 100644 --- a/definitions/grib2/tables/11/6.0.table +++ b/definitions/grib2/tables/11/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/12/0.0.table b/definitions/grib2/tables/12/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/12/0.0.table +++ b/definitions/grib2/tables/12/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/1.0.table b/definitions/grib2/tables/12/1.0.table index 84ec19886..b21d01815 100644 --- a/definitions/grib2/tables/12/1.0.table +++ b/definitions/grib2/tables/12/1.0.table @@ -1,17 +1,17 @@ # Code table 1.0 - GRIB master tables version number -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 -6 6 Version implemented on 15 September 2010 -7 7 Version implemented on 4 May 2011 -8 8 Version implemented on 2 November 2011 -9 9 Version implemented on 2 May 2012 +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Version implemented on 2 May 2012 10 10 Version implemented on 7 November 2012 11 11 Version implemented on 8 May 2013 12 12 Version implemented on 14 November 2013 13 13 Pre-operational to be implemented by next amendment -# 14-254 Future versions -255 255 Missing +# 14-254 Future versions +255 255 Missing diff --git a/definitions/grib2/tables/12/1.1.table b/definitions/grib2/tables/12/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/12/1.1.table +++ b/definitions/grib2/tables/12/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/12/1.2.table b/definitions/grib2/tables/12/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/12/1.2.table +++ b/definitions/grib2/tables/12/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/1.3.table b/definitions/grib2/tables/12/1.3.table index e8c38878d..34ace7fda 100644 --- a/definitions/grib2/tables/12/1.3.table +++ b/definitions/grib2/tables/12/1.3.table @@ -1,12 +1,12 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products 4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) 6 6 Sub-seasonal to seasonal prediction project (S2S) 7 7 Sub-seasonal to seasonal prediction project test (S2S) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/1.4.table b/definitions/grib2/tables/12/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/12/1.4.table +++ b/definitions/grib2/tables/12/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/12/1.5.table b/definitions/grib2/tables/12/1.5.table index b2cf9f087..533111959 100644 --- a/definitions/grib2/tables/12/1.5.table +++ b/definitions/grib2/tables/12/1.5.table @@ -1,7 +1,7 @@ # Code table 1.5 - Identification template number -0 0 Calendar definition -1 1 Paleontological offset -2 2 Calendar definition and paleontological offset -# 3-32767 Reserved -# 32768-65534 Reserved for local use -65535 65535 Missing +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/12/1.6.table b/definitions/grib2/tables/12/1.6.table index 5db921990..bd46899a7 100644 --- a/definitions/grib2/tables/12/1.6.table +++ b/definitions/grib2/tables/12/1.6.table @@ -1,8 +1,8 @@ # Code table 1.6 - Type of calendar -0 0 Gregorian -1 1 360-day -2 2 365-day -3 3 Proleptic Gregorian -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/3.0.table b/definitions/grib2/tables/12/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/12/3.0.table +++ b/definitions/grib2/tables/12/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/12/3.10.table b/definitions/grib2/tables/12/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/12/3.10.table +++ b/definitions/grib2/tables/12/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/12/3.11.table b/definitions/grib2/tables/12/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/12/3.11.table +++ b/definitions/grib2/tables/12/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/12/3.15.table b/definitions/grib2/tables/12/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/12/3.15.table +++ b/definitions/grib2/tables/12/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/3.2.table b/definitions/grib2/tables/12/3.2.table index 9238dc2a7..b9574a424 100644 --- a/definitions/grib2/tables/12/3.2.table +++ b/definitions/grib2/tables/12/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/3.20.table b/definitions/grib2/tables/12/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/12/3.20.table +++ b/definitions/grib2/tables/12/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/3.21.table b/definitions/grib2/tables/12/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/12/3.21.table +++ b/definitions/grib2/tables/12/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/3.3.table b/definitions/grib2/tables/12/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/12/3.3.table +++ b/definitions/grib2/tables/12/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/12/3.4.table b/definitions/grib2/tables/12/3.4.table index 63c8adaaa..ea9cbe829 100644 --- a/definitions/grib2/tables/12/3.4.table +++ b/definitions/grib2/tables/12/3.4.table @@ -1,10 +1,10 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -# 5-8 Reserved +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +# 5-8 Reserved diff --git a/definitions/grib2/tables/12/3.5.table b/definitions/grib2/tables/12/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/12/3.5.table +++ b/definitions/grib2/tables/12/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/12/3.7.table b/definitions/grib2/tables/12/3.7.table index 0a7d6efde..34c0de085 100644 --- a/definitions/grib2/tables/12/3.7.table +++ b/definitions/grib2/tables/12/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 see separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/12/3.8.table b/definitions/grib2/tables/12/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/12/3.8.table +++ b/definitions/grib2/tables/12/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/3.9.table b/definitions/grib2/tables/12/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/12/3.9.table +++ b/definitions/grib2/tables/12/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/12/4.0.table b/definitions/grib2/tables/12/4.0.table index b77e3f323..8608d20f9 100644 --- a/definitions/grib2/tables/12/4.0.table +++ b/definitions/grib2/tables/12/4.0.table @@ -1,61 +1,61 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time -8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -# 35-39 Reserved +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +# 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol -46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -# 49-50 Reserved -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time -52 52 Reserved -53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time -54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +# 49-50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +52 52 Reserved +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters 60 60 Individual ensemble re-forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time 61 61 Individual ensemble re-forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 55-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +# 55-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/12/4.1.0.table b/definitions/grib2/tables/12/4.1.0.table index 04cfd7802..df58636d6 100644 --- a/definitions/grib2/tables/12/4.1.0.table +++ b/definitions/grib2/tables/12/4.1.0.table @@ -1,27 +1,27 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.1.1.table b/definitions/grib2/tables/12/4.1.1.table index 7b22b6fed..05a854da0 100644 --- a/definitions/grib2/tables/12/4.1.1.table +++ b/definitions/grib2/tables/12/4.1.1.table @@ -1,7 +1,7 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.1.10.table b/definitions/grib2/tables/12/4.1.10.table index b97dcd355..e9663f391 100644 --- a/definitions/grib2/tables/12/4.1.10.table +++ b/definitions/grib2/tables/12/4.1.10.table @@ -1,10 +1,10 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Sub-surface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Sub-surface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.1.2.table b/definitions/grib2/tables/12/4.1.2.table index 5b488fe9e..e74126645 100644 --- a/definitions/grib2/tables/12/4.1.2.table +++ b/definitions/grib2/tables/12/4.1.2.table @@ -1,9 +1,9 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.1.3.table b/definitions/grib2/tables/12/4.1.3.table index 5096a166e..c1a1e267a 100644 --- a/definitions/grib2/tables/12/4.1.3.table +++ b/definitions/grib2/tables/12/4.1.3.table @@ -1,6 +1,6 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Image format products -1 1 Quantitative products -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.10.table b/definitions/grib2/tables/12/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/12/4.10.table +++ b/definitions/grib2/tables/12/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/12/4.11.table b/definitions/grib2/tables/12/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/12/4.11.table +++ b/definitions/grib2/tables/12/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.12.table b/definitions/grib2/tables/12/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/12/4.12.table +++ b/definitions/grib2/tables/12/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.13.table b/definitions/grib2/tables/12/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/12/4.13.table +++ b/definitions/grib2/tables/12/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.14.table b/definitions/grib2/tables/12/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/12/4.14.table +++ b/definitions/grib2/tables/12/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.15.table b/definitions/grib2/tables/12/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/12/4.15.table +++ b/definitions/grib2/tables/12/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.0.table b/definitions/grib2/tables/12/4.2.0.0.table index ce91fe429..f5841e889 100644 --- a/definitions/grib2/tables/12/4.2.0.0.table +++ b/definitions/grib2/tables/12/4.2.0.0.table @@ -20,6 +20,6 @@ 18 18 Snow temperature (top of snow) (K) 19 19 Turbulent transfer coefficient for heat (Numeric) 20 20 Turbulent diffusion coefficient for heat (m2/s) -# 21-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 21-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.1.table b/definitions/grib2/tables/12/4.2.0.1.table index d1d1704df..fb7c3d776 100644 --- a/definitions/grib2/tables/12/4.2.0.1.table +++ b/definitions/grib2/tables/12/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,10 +86,10 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) -# 93-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 93-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.13.table b/definitions/grib2/tables/12/4.2.0.13.table index 5086101ad..3f5c30675 100644 --- a/definitions/grib2/tables/12/4.2.0.13.table +++ b/definitions/grib2/tables/12/4.2.0.13.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.14.table b/definitions/grib2/tables/12/4.2.0.14.table index 215884737..97fb38c8b 100644 --- a/definitions/grib2/tables/12/4.2.0.14.table +++ b/definitions/grib2/tables/12/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.15.table b/definitions/grib2/tables/12/4.2.0.15.table index d74fa7234..bb0b9ab46 100644 --- a/definitions/grib2/tables/12/4.2.0.15.table +++ b/definitions/grib2/tables/12/4.2.0.15.table @@ -14,6 +14,6 @@ 12 12 Reflectivity of rain (dB) 13 13 Reflectivity of graupel (dB) 14 14 Reflectivity of hail (dB) -# 15-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 15-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.16.table b/definitions/grib2/tables/12/4.2.0.16.table index 0c240a853..9499d9333 100644 --- a/definitions/grib2/tables/12/4.2.0.16.table +++ b/definitions/grib2/tables/12/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.18.table b/definitions/grib2/tables/12/4.2.0.18.table index 18c41aa48..7e0a736eb 100644 --- a/definitions/grib2/tables/12/4.2.0.18.table +++ b/definitions/grib2/tables/12/4.2.0.18.table @@ -8,11 +8,11 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) 13 13 Total deposition (wet + dry) (Bq m-2) -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.19.table b/definitions/grib2/tables/12/4.2.0.19.table index 75101bd37..d2beef083 100644 --- a/definitions/grib2/tables/12/4.2.0.19.table +++ b/definitions/grib2/tables/12/4.2.0.19.table @@ -27,6 +27,6 @@ 25 25 Weather (Code table 4.225) 26 26 Convective outlook (Code table 4.224) 27 27 Icing scenario (Code table 4.227) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.190.table b/definitions/grib2/tables/12/4.2.0.190.table index de621a924..a0d6ba0ac 100644 --- a/definitions/grib2/tables/12/4.2.0.190.table +++ b/definitions/grib2/tables/12/4.2.0.190.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.191.table b/definitions/grib2/tables/12/4.2.0.191.table index 1f949f149..2e82e01da 100644 --- a/definitions/grib2/tables/12/4.2.0.191.table +++ b/definitions/grib2/tables/12/4.2.0.191.table @@ -2,6 +2,6 @@ 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.2.table b/definitions/grib2/tables/12/4.2.0.2.table index 84882e8b8..ad1d84f52 100644 --- a/definitions/grib2/tables/12/4.2.0.2.table +++ b/definitions/grib2/tables/12/4.2.0.2.table @@ -35,6 +35,6 @@ 33 33 Wind fetch (m) 34 34 Normal wind component (m s-1) 35 35 Tangential wind component (m s-1) -# 36-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 36-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.20.table b/definitions/grib2/tables/12/4.2.0.20.table index ac97b0b39..a0eb7724a 100644 --- a/definitions/grib2/tables/12/4.2.0.20.table +++ b/definitions/grib2/tables/12/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -25,7 +25,7 @@ 57 57 Total yearly average burden of the atmosphere (mol) 58 58 Total yearly averaged atmospheric loss (mol/s) 59 59 Aerosol number concentration (m-3) -# 60-99 Reserved +# 60-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -37,6 +37,6 @@ 108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) 109 109 Aerosol lidar extinction from satellite (m-1) 110 110 Aerosol lidar extinction from the ground (m-1) -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.3.table b/definitions/grib2/tables/12/4.2.0.3.table index 9a88e0027..e1a68bfc5 100644 --- a/definitions/grib2/tables/12/4.2.0.3.table +++ b/definitions/grib2/tables/12/4.2.0.3.table @@ -26,6 +26,6 @@ 24 24 Anisotropy of sub-gridscale orography (Numeric) 25 25 Natural logarithm of pressure in Pa (Numeric) 26 26 Exner pressure (Numeric) -# 27-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 27-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.4.table b/definitions/grib2/tables/12/4.2.0.4.table index dbfcbddb7..03b5cea38 100644 --- a/definitions/grib2/tables/12/4.2.0.4.table +++ b/definitions/grib2/tables/12/4.2.0.4.table @@ -12,9 +12,9 @@ 10 10 Photosynthetically active radiation (W m-2) 11 11 Net short-wave radiation flux, clear sky (W m-2) 12 12 Downward UV radiation (W m-2) -# 13-49 Reserved +# 13-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) -# 52-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.5.table b/definitions/grib2/tables/12/4.2.0.5.table index f1c04650d..1bdd6ebee 100644 --- a/definitions/grib2/tables/12/4.2.0.5.table +++ b/definitions/grib2/tables/12/4.2.0.5.table @@ -6,6 +6,6 @@ 4 4 Upward long-wave radiation flux (W m-2) 5 5 Net long-wave radiation flux (W m-2) 6 6 Net long-wave radiation flux, clear sky (W m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.6.table b/definitions/grib2/tables/12/4.2.0.6.table index 9ee97b73f..89da06eec 100644 --- a/definitions/grib2/tables/12/4.2.0.6.table +++ b/definitions/grib2/tables/12/4.2.0.6.table @@ -35,6 +35,6 @@ 33 33 Sunshine duration (s) 34 34 Surface long-wave effective total cloudiness (Numeric) 35 35 Surface short-wave effective total cloudiness (Numeric) -# 36-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 36-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.0.7.table b/definitions/grib2/tables/12/4.2.0.7.table index db47d0113..8a2b85fb9 100644 --- a/definitions/grib2/tables/12/4.2.0.7.table +++ b/definitions/grib2/tables/12/4.2.0.7.table @@ -13,8 +13,8 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraft helicity (m2 s-2) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.1.0.table b/definitions/grib2/tables/12/4.2.1.0.table index e93f0a332..b6c648f00 100644 --- a/definitions/grib2/tables/12/4.2.1.0.table +++ b/definitions/grib2/tables/12/4.2.1.0.table @@ -6,6 +6,6 @@ 4 4 Snow water equivalent per cent of normal (%) 5 5 Baseflow-groundwater runoff (kg m-2) 6 6 Storm surface runoff (kg m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.1.1.table b/definitions/grib2/tables/12/4.2.1.1.table index b488eb0bd..171da3958 100644 --- a/definitions/grib2/tables/12/4.2.1.1.table +++ b/definitions/grib2/tables/12/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.10.0.table b/definitions/grib2/tables/12/4.2.10.0.table index 761b6395c..76b3da22c 100644 --- a/definitions/grib2/tables/12/4.2.10.0.table +++ b/definitions/grib2/tables/12/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (s-1) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.10.1.table b/definitions/grib2/tables/12/4.2.10.1.table index 5959bfa28..f0a073c00 100644 --- a/definitions/grib2/tables/12/4.2.10.1.table +++ b/definitions/grib2/tables/12/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.10.191.table b/definitions/grib2/tables/12/4.2.10.191.table index 18e56f930..6b9eee36e 100644 --- a/definitions/grib2/tables/12/4.2.10.191.table +++ b/definitions/grib2/tables/12/4.2.10.191.table @@ -1,6 +1,6 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.10.2.table b/definitions/grib2/tables/12/4.2.10.2.table index 6f0664420..24458b91f 100644 --- a/definitions/grib2/tables/12/4.2.10.2.table +++ b/definitions/grib2/tables/12/4.2.10.2.table @@ -9,6 +9,6 @@ 7 7 Ice divergence (/s) 8 8 Ice temperature (K) 9 9 Ice internal pressure (Pa m) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.10.3.table b/definitions/grib2/tables/12/4.2.10.3.table index f951bbe78..937720c93 100644 --- a/definitions/grib2/tables/12/4.2.10.3.table +++ b/definitions/grib2/tables/12/4.2.10.3.table @@ -1,6 +1,6 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.10.4.table b/definitions/grib2/tables/12/4.2.10.4.table index 450320ca1..e20a49470 100644 --- a/definitions/grib2/tables/12/4.2.10.4.table +++ b/definitions/grib2/tables/12/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2 s-1) 6 6 Ocean vertical momentum diffusivity (m2 s-1) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (m-1) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.2.0.table b/definitions/grib2/tables/12/4.2.2.0.table index 95b696a37..98eae911a 100644 --- a/definitions/grib2/tables/12/4.2.2.0.table +++ b/definitions/grib2/tables/12/4.2.2.0.table @@ -32,6 +32,6 @@ 30 30 Deciduous forest cover (Proportion) 31 31 Normalized differential vegetation index (NDVI) (Numeric) 32 32 Root depth of vegetation (m) -# 33-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 33-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.2.3.table b/definitions/grib2/tables/12/4.2.2.3.table index 2f6291077..3d3298c8a 100644 --- a/definitions/grib2/tables/12/4.2.2.3.table +++ b/definitions/grib2/tables/12/4.2.2.3.table @@ -22,6 +22,6 @@ 20 20 Column-integrated soil moisture (kg m-2) 21 21 Soil ice (kg m-3) 22 22 Column-integrated soil ice (kg m-2) -# 23-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 23-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.2.4.table b/definitions/grib2/tables/12/4.2.2.4.table index cf91e8b7a..30865c1b8 100644 --- a/definitions/grib2/tables/12/4.2.2.4.table +++ b/definitions/grib2/tables/12/4.2.2.4.table @@ -3,6 +3,6 @@ 1 1 Fire outlook due to dry thunderstorm (Code table 4.224) 2 2 Haines Index (Numeric) 3 3 Fire burned area (%) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.3.0.table b/definitions/grib2/tables/12/4.2.3.0.table index c0ffa29f5..80a829673 100644 --- a/definitions/grib2/tables/12/4.2.3.0.table +++ b/definitions/grib2/tables/12/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.2.3.1.table b/definitions/grib2/tables/12/4.2.3.1.table index 0c0fc8d37..bc16d8855 100644 --- a/definitions/grib2/tables/12/4.2.3.1.table +++ b/definitions/grib2/tables/12/4.2.3.1.table @@ -17,12 +17,12 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +23 23 Angstrom coefficient +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.201.table b/definitions/grib2/tables/12/4.201.table index 2510f2ef7..fa173c4e0 100644 --- a/definitions/grib2/tables/12/4.201.table +++ b/definitions/grib2/tables/12/4.201.table @@ -10,6 +10,6 @@ 8 8 Ice pellets 9 9 Graupel 10 10 Hail -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.202.table b/definitions/grib2/tables/12/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/12/4.202.table +++ b/definitions/grib2/tables/12/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.203.table b/definitions/grib2/tables/12/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/12/4.203.table +++ b/definitions/grib2/tables/12/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.204.table b/definitions/grib2/tables/12/4.204.table index 91bcf1814..ffbd89502 100644 --- a/definitions/grib2/tables/12/4.204.table +++ b/definitions/grib2/tables/12/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (16-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (16-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.205.table b/definitions/grib2/tables/12/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/12/4.205.table +++ b/definitions/grib2/tables/12/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.206.table b/definitions/grib2/tables/12/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/12/4.206.table +++ b/definitions/grib2/tables/12/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.207.table b/definitions/grib2/tables/12/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/12/4.207.table +++ b/definitions/grib2/tables/12/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.208.table b/definitions/grib2/tables/12/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/12/4.208.table +++ b/definitions/grib2/tables/12/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.209.table b/definitions/grib2/tables/12/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/12/4.209.table +++ b/definitions/grib2/tables/12/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.210.table b/definitions/grib2/tables/12/4.210.table index 524a6ca73..791878469 100644 --- a/definitions/grib2/tables/12/4.210.table +++ b/definitions/grib2/tables/12/4.210.table @@ -1,6 +1,6 @@ # Code table 4.210 - Contrail intensity -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.211.table b/definitions/grib2/tables/12/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/12/4.211.table +++ b/definitions/grib2/tables/12/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.212.table b/definitions/grib2/tables/12/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/12/4.212.table +++ b/definitions/grib2/tables/12/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.213.table b/definitions/grib2/tables/12/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/12/4.213.table +++ b/definitions/grib2/tables/12/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.215.table b/definitions/grib2/tables/12/4.215.table index 88fda8b8c..c264c6722 100644 --- a/definitions/grib2/tables/12/4.215.table +++ b/definitions/grib2/tables/12/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely-sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.216.table b/definitions/grib2/tables/12/4.216.table index 4d9a70f86..b51b358f4 100644 --- a/definitions/grib2/tables/12/4.216.table +++ b/definitions/grib2/tables/12/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain # 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/12/4.217.table b/definitions/grib2/tables/12/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/12/4.217.table +++ b/definitions/grib2/tables/12/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.218.table b/definitions/grib2/tables/12/4.218.table index 6940a0e41..acf069c32 100644 --- a/definitions/grib2/tables/12/4.218.table +++ b/definitions/grib2/tables/12/4.218.table @@ -1,38 +1,38 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation / crops -15 15 Permanent snow / ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -# 19-96 Reserved -97 97 Snow / ice on land -98 98 Snow / ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud / fog / Stratus -102 102 Low cloud / Stratocumulus -103 103 Low cloud / unknown type -104 104 Medium cloud / Nimbostratus -105 105 Medium cloud / Altostratus -106 106 Medium cloud / unknown type -107 107 High cloud / Cumulus -108 108 High cloud / Cirrus -109 109 High cloud / unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation / crops +15 15 Permanent snow / ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +# 19-96 Reserved +97 97 Snow / ice on land +98 98 Snow / ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud / fog / Stratus +102 102 Low cloud / Stratocumulus +103 103 Low cloud / unknown type +104 104 Medium cloud / Nimbostratus +105 105 Medium cloud / Altostratus +106 106 Medium cloud / unknown type +107 107 High cloud / Cumulus +108 108 High cloud / Cirrus +109 109 High cloud / unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.219.table b/definitions/grib2/tables/12/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/12/4.219.table +++ b/definitions/grib2/tables/12/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.220.table b/definitions/grib2/tables/12/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/12/4.220.table +++ b/definitions/grib2/tables/12/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.221.table b/definitions/grib2/tables/12/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/12/4.221.table +++ b/definitions/grib2/tables/12/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.222.table b/definitions/grib2/tables/12/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/12/4.222.table +++ b/definitions/grib2/tables/12/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.223.table b/definitions/grib2/tables/12/4.223.table index f0deb076a..572c4e7a8 100644 --- a/definitions/grib2/tables/12/4.223.table +++ b/definitions/grib2/tables/12/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/12/4.224.table b/definitions/grib2/tables/12/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/12/4.224.table +++ b/definitions/grib2/tables/12/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/12/4.227.table b/definitions/grib2/tables/12/4.227.table index 27c76553d..48c3b7633 100644 --- a/definitions/grib2/tables/12/4.227.table +++ b/definitions/grib2/tables/12/4.227.table @@ -1,9 +1,9 @@ # Code table 4.227 - Icing scenario (weather/cloud classification) -0 0 None -1 1 General -2 2 Convective -3 3 Stratiform -4 4 Freezing -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/12/4.234.table b/definitions/grib2/tables/12/4.234.table index 9844a91d2..d8b3715b3 100644 --- a/definitions/grib2/tables/12/4.234.table +++ b/definitions/grib2/tables/12/4.234.table @@ -1,21 +1,21 @@ # Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Crops, mixed farming -2 2 Short grass -3 3 Evergreen needleleaf trees -4 4 Deciduous needleleaf trees -5 5 Deciduous broadleaf trees -6 6 Evergreen broadleaf trees -7 7 Tall grass -8 8 Desert -9 9 Tundra -10 10 Irrigated crops -11 11 Semidesert -12 12 Ice caps and glaciers -13 13 Bogs and marshes -14 14 Inland water -15 15 Ocean -16 16 Evergreen shrubs -17 17 Deciduous shrubs -18 18 Mixed forest -19 19 Interrupted forest -20 20 Water and land mixtures +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/12/4.236.table b/definitions/grib2/tables/12/4.236.table index 08c7f8d56..b667b65fc 100644 --- a/definitions/grib2/tables/12/4.236.table +++ b/definitions/grib2/tables/12/4.236.table @@ -1,8 +1,8 @@ # Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Coarse -2 2 Medium -3 3 Medium-fine -4 4 Fine -5 5 Very-fine -6 6 Organic -7 7 Tropical-organic +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/12/4.3.table b/definitions/grib2/tables/12/4.3.table index 8f7d20be3..1681cfc93 100644 --- a/definitions/grib2/tables/12/4.3.table +++ b/definitions/grib2/tables/12/4.3.table @@ -1,16 +1,16 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.4.table b/definitions/grib2/tables/12/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/12/4.4.table +++ b/definitions/grib2/tables/12/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.5.table b/definitions/grib2/tables/12/4.5.table index 1ada3eb23..c3b8aec5d 100644 --- a/definitions/grib2/tables/12/4.5.table +++ b/definitions/grib2/tables/12/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface 2 2 Cloud base level 3 3 Level of cloud tops @@ -12,11 +12,11 @@ 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,7 +25,7 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level 112 112 Reserved 113 113 Logarithmic hybrid level @@ -36,7 +36,7 @@ 119 hpl Hybrid pressure level # 120-149 Reserved 150 150 Generalized vertical height coordinate -# 151-159 Reserved +# 151-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom @@ -44,6 +44,6 @@ 164 164 Bottom of thermally active sediment layer 165 165 Bottom of sediment layer penetrated by thermal wave 166 sfc Mixing layer -# 167-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 167-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.6.table b/definitions/grib2/tables/12/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/12/4.6.table +++ b/definitions/grib2/tables/12/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.7.table b/definitions/grib2/tables/12/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/12/4.7.table +++ b/definitions/grib2/tables/12/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.8.table b/definitions/grib2/tables/12/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/12/4.8.table +++ b/definitions/grib2/tables/12/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.9.table b/definitions/grib2/tables/12/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/12/4.9.table +++ b/definitions/grib2/tables/12/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/4.91.table b/definitions/grib2/tables/12/4.91.table index 97b1c70ad..ae31ed61c 100644 --- a/definitions/grib2/tables/12/4.91.table +++ b/definitions/grib2/tables/12/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit 11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/12/5.1.table b/definitions/grib2/tables/12/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/12/5.1.table +++ b/definitions/grib2/tables/12/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/5.2.table b/definitions/grib2/tables/12/5.2.table index 7a4500ecd..d12b46fbd 100644 --- a/definitions/grib2/tables/12/5.2.table +++ b/definitions/grib2/tables/12/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use +# 12-191 Reserved +# 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/12/5.3.table b/definitions/grib2/tables/12/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/12/5.3.table +++ b/definitions/grib2/tables/12/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/5.4.table b/definitions/grib2/tables/12/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/12/5.4.table +++ b/definitions/grib2/tables/12/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/5.40.table b/definitions/grib2/tables/12/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/12/5.40.table +++ b/definitions/grib2/tables/12/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/12/5.5.table b/definitions/grib2/tables/12/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/12/5.5.table +++ b/definitions/grib2/tables/12/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/5.6.table b/definitions/grib2/tables/12/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/12/5.6.table +++ b/definitions/grib2/tables/12/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/12/5.7.table b/definitions/grib2/tables/12/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/12/5.7.table +++ b/definitions/grib2/tables/12/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/12/6.0.table b/definitions/grib2/tables/12/6.0.table index f539b26d7..a8f30f5a4 100644 --- a/definitions/grib2/tables/12/6.0.table +++ b/definitions/grib2/tables/12/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/13/0.0.table b/definitions/grib2/tables/13/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/13/0.0.table +++ b/definitions/grib2/tables/13/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/1.0.table b/definitions/grib2/tables/13/1.0.table index dfca4d4c1..b90cc628e 100644 --- a/definitions/grib2/tables/13/1.0.table +++ b/definitions/grib2/tables/13/1.0.table @@ -1,18 +1,18 @@ # Code table 1.0 - GRIB master tables version number -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 -6 6 Version implemented on 15 September 2010 -7 7 Version implemented on 4 May 2011 -8 8 Version implemented on 2 November 2011 -9 9 Version implemented on 2 May 2012 +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Version implemented on 2 May 2012 10 10 Version implemented on 7 November 2012 11 11 Version implemented on 8 May 2013 12 12 Version implemented on 14 November 2013 13 13 Version implemented on 7 May 2014 14 14 Pre-operational to be implemented by next amendment # 15-254 Future versions -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/13/1.1.table b/definitions/grib2/tables/13/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/13/1.1.table +++ b/definitions/grib2/tables/13/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/13/1.2.table b/definitions/grib2/tables/13/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/13/1.2.table +++ b/definitions/grib2/tables/13/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/1.3.table b/definitions/grib2/tables/13/1.3.table index 9b37611b0..c3b924d9d 100644 --- a/definitions/grib2/tables/13/1.3.table +++ b/definitions/grib2/tables/13/1.3.table @@ -1,12 +1,12 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products 4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) 6 6 S2S operational products 7 7 S2S test products -# 8-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/1.4.table b/definitions/grib2/tables/13/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/13/1.4.table +++ b/definitions/grib2/tables/13/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/13/1.5.table b/definitions/grib2/tables/13/1.5.table index b2cf9f087..533111959 100644 --- a/definitions/grib2/tables/13/1.5.table +++ b/definitions/grib2/tables/13/1.5.table @@ -1,7 +1,7 @@ # Code table 1.5 - Identification template number -0 0 Calendar definition -1 1 Paleontological offset -2 2 Calendar definition and paleontological offset -# 3-32767 Reserved -# 32768-65534 Reserved for local use -65535 65535 Missing +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/13/1.6.table b/definitions/grib2/tables/13/1.6.table index 5db921990..bd46899a7 100644 --- a/definitions/grib2/tables/13/1.6.table +++ b/definitions/grib2/tables/13/1.6.table @@ -1,8 +1,8 @@ # Code table 1.6 - Type of calendar -0 0 Gregorian -1 1 360-day -2 2 365-day -3 3 Proleptic Gregorian -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/3.0.table b/definitions/grib2/tables/13/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/13/3.0.table +++ b/definitions/grib2/tables/13/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/13/3.10.table b/definitions/grib2/tables/13/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/13/3.10.table +++ b/definitions/grib2/tables/13/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/13/3.11.table b/definitions/grib2/tables/13/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/13/3.11.table +++ b/definitions/grib2/tables/13/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/13/3.15.table b/definitions/grib2/tables/13/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/13/3.15.table +++ b/definitions/grib2/tables/13/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/3.2.table b/definitions/grib2/tables/13/3.2.table index 9238dc2a7..b9574a424 100644 --- a/definitions/grib2/tables/13/3.2.table +++ b/definitions/grib2/tables/13/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/3.20.table b/definitions/grib2/tables/13/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/13/3.20.table +++ b/definitions/grib2/tables/13/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/3.21.table b/definitions/grib2/tables/13/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/13/3.21.table +++ b/definitions/grib2/tables/13/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/3.3.table b/definitions/grib2/tables/13/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/13/3.3.table +++ b/definitions/grib2/tables/13/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/13/3.4.table b/definitions/grib2/tables/13/3.4.table index 63c8adaaa..ea9cbe829 100644 --- a/definitions/grib2/tables/13/3.4.table +++ b/definitions/grib2/tables/13/3.4.table @@ -1,10 +1,10 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -# 5-8 Reserved +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +# 5-8 Reserved diff --git a/definitions/grib2/tables/13/3.5.table b/definitions/grib2/tables/13/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/13/3.5.table +++ b/definitions/grib2/tables/13/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/13/3.7.table b/definitions/grib2/tables/13/3.7.table index 0a7d6efde..34c0de085 100644 --- a/definitions/grib2/tables/13/3.7.table +++ b/definitions/grib2/tables/13/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 see separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/13/3.8.table b/definitions/grib2/tables/13/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/13/3.8.table +++ b/definitions/grib2/tables/13/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/3.9.table b/definitions/grib2/tables/13/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/13/3.9.table +++ b/definitions/grib2/tables/13/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/13/4.0.table b/definitions/grib2/tables/13/4.0.table index 89cf92c44..7627a2a3d 100644 --- a/definitions/grib2/tables/13/4.0.table +++ b/definitions/grib2/tables/13/4.0.table @@ -1,62 +1,62 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time -8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -# 35-39 Reserved +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +# 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol -46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -# 49-50 Reserved -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time -52 52 Reserved -53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time -54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters -# 55-59 Reserved +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +# 49-50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +52 52 Reserved +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +# 55-59 Reserved 60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time 61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 62-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +# 62-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/13/4.1.0.table b/definitions/grib2/tables/13/4.1.0.table index 04cfd7802..df58636d6 100644 --- a/definitions/grib2/tables/13/4.1.0.table +++ b/definitions/grib2/tables/13/4.1.0.table @@ -1,27 +1,27 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.1.1.table b/definitions/grib2/tables/13/4.1.1.table index 7b22b6fed..05a854da0 100644 --- a/definitions/grib2/tables/13/4.1.1.table +++ b/definitions/grib2/tables/13/4.1.1.table @@ -1,7 +1,7 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.1.10.table b/definitions/grib2/tables/13/4.1.10.table index b97dcd355..e9663f391 100644 --- a/definitions/grib2/tables/13/4.1.10.table +++ b/definitions/grib2/tables/13/4.1.10.table @@ -1,10 +1,10 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Sub-surface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Sub-surface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.1.2.table b/definitions/grib2/tables/13/4.1.2.table index 5b488fe9e..e74126645 100644 --- a/definitions/grib2/tables/13/4.1.2.table +++ b/definitions/grib2/tables/13/4.1.2.table @@ -1,9 +1,9 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.1.3.table b/definitions/grib2/tables/13/4.1.3.table index 5096a166e..c1a1e267a 100644 --- a/definitions/grib2/tables/13/4.1.3.table +++ b/definitions/grib2/tables/13/4.1.3.table @@ -1,6 +1,6 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Image format products -1 1 Quantitative products -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.10.table b/definitions/grib2/tables/13/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/13/4.10.table +++ b/definitions/grib2/tables/13/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/13/4.11.table b/definitions/grib2/tables/13/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/13/4.11.table +++ b/definitions/grib2/tables/13/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.12.table b/definitions/grib2/tables/13/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/13/4.12.table +++ b/definitions/grib2/tables/13/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.13.table b/definitions/grib2/tables/13/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/13/4.13.table +++ b/definitions/grib2/tables/13/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.14.table b/definitions/grib2/tables/13/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/13/4.14.table +++ b/definitions/grib2/tables/13/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.15.table b/definitions/grib2/tables/13/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/13/4.15.table +++ b/definitions/grib2/tables/13/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.0.table b/definitions/grib2/tables/13/4.2.0.0.table index 6de8a23c8..24d21959d 100644 --- a/definitions/grib2/tables/13/4.2.0.0.table +++ b/definitions/grib2/tables/13/4.2.0.0.table @@ -21,6 +21,6 @@ 19 19 Turbulent transfer coefficient for heat (Numeric) 20 20 Turbulent diffusion coefficient for heat (m2/s) 21 21 Apparent temperature (K) -# 22-191 Reserved +# 22-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.1.table b/definitions/grib2/tables/13/4.2.0.1.table index d1d1704df..fb7c3d776 100644 --- a/definitions/grib2/tables/13/4.2.0.1.table +++ b/definitions/grib2/tables/13/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,10 +86,10 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) -# 93-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 93-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.13.table b/definitions/grib2/tables/13/4.2.0.13.table index 5086101ad..3f5c30675 100644 --- a/definitions/grib2/tables/13/4.2.0.13.table +++ b/definitions/grib2/tables/13/4.2.0.13.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.14.table b/definitions/grib2/tables/13/4.2.0.14.table index 215884737..97fb38c8b 100644 --- a/definitions/grib2/tables/13/4.2.0.14.table +++ b/definitions/grib2/tables/13/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.15.table b/definitions/grib2/tables/13/4.2.0.15.table index d74fa7234..bb0b9ab46 100644 --- a/definitions/grib2/tables/13/4.2.0.15.table +++ b/definitions/grib2/tables/13/4.2.0.15.table @@ -14,6 +14,6 @@ 12 12 Reflectivity of rain (dB) 13 13 Reflectivity of graupel (dB) 14 14 Reflectivity of hail (dB) -# 15-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 15-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.16.table b/definitions/grib2/tables/13/4.2.0.16.table index 0c240a853..9499d9333 100644 --- a/definitions/grib2/tables/13/4.2.0.16.table +++ b/definitions/grib2/tables/13/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.18.table b/definitions/grib2/tables/13/4.2.0.18.table index 18c41aa48..7e0a736eb 100644 --- a/definitions/grib2/tables/13/4.2.0.18.table +++ b/definitions/grib2/tables/13/4.2.0.18.table @@ -8,11 +8,11 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) 13 13 Total deposition (wet + dry) (Bq m-2) -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.19.table b/definitions/grib2/tables/13/4.2.0.19.table index 75101bd37..d2beef083 100644 --- a/definitions/grib2/tables/13/4.2.0.19.table +++ b/definitions/grib2/tables/13/4.2.0.19.table @@ -27,6 +27,6 @@ 25 25 Weather (Code table 4.225) 26 26 Convective outlook (Code table 4.224) 27 27 Icing scenario (Code table 4.227) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.190.table b/definitions/grib2/tables/13/4.2.0.190.table index de621a924..a0d6ba0ac 100644 --- a/definitions/grib2/tables/13/4.2.0.190.table +++ b/definitions/grib2/tables/13/4.2.0.190.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.191.table b/definitions/grib2/tables/13/4.2.0.191.table index e3bba0ebe..b3a7092ea 100644 --- a/definitions/grib2/tables/13/4.2.0.191.table +++ b/definitions/grib2/tables/13/4.2.0.191.table @@ -3,6 +3,6 @@ 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.2.table b/definitions/grib2/tables/13/4.2.0.2.table index c83b07300..7bd1509f5 100644 --- a/definitions/grib2/tables/13/4.2.0.2.table +++ b/definitions/grib2/tables/13/4.2.0.2.table @@ -38,6 +38,6 @@ 36 36 Amplitude function for Rossby wave envelope for meridional wind (m/s) 37 37 Northward turbulent surface stress (N m-2 s) 38 38 Eastward turbulent surface stress (N m-2 s) -# 39-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 39-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.20.table b/definitions/grib2/tables/13/4.2.0.20.table index 9584f7c7f..df9ccc184 100644 --- a/definitions/grib2/tables/13/4.2.0.20.table +++ b/definitions/grib2/tables/13/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -25,7 +25,7 @@ 57 57 Total yearly average burden of the atmosphere (mol) 58 58 Total yearly averaged atmospheric loss (mol/s) 59 59 Aerosol number concentration (m-3) -# 60-99 Reserved +# 60-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -37,6 +37,6 @@ 108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) 109 109 Aerosol lidar extinction from satellite (/m) 110 110 Aerosol lidar extinction from the ground (/m) -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.3.table b/definitions/grib2/tables/13/4.2.0.3.table index 9a88e0027..e1a68bfc5 100644 --- a/definitions/grib2/tables/13/4.2.0.3.table +++ b/definitions/grib2/tables/13/4.2.0.3.table @@ -26,6 +26,6 @@ 24 24 Anisotropy of sub-gridscale orography (Numeric) 25 25 Natural logarithm of pressure in Pa (Numeric) 26 26 Exner pressure (Numeric) -# 27-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 27-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.4.table b/definitions/grib2/tables/13/4.2.0.4.table index dbfcbddb7..03b5cea38 100644 --- a/definitions/grib2/tables/13/4.2.0.4.table +++ b/definitions/grib2/tables/13/4.2.0.4.table @@ -12,9 +12,9 @@ 10 10 Photosynthetically active radiation (W m-2) 11 11 Net short-wave radiation flux, clear sky (W m-2) 12 12 Downward UV radiation (W m-2) -# 13-49 Reserved +# 13-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) -# 52-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.5.table b/definitions/grib2/tables/13/4.2.0.5.table index f1c04650d..1bdd6ebee 100644 --- a/definitions/grib2/tables/13/4.2.0.5.table +++ b/definitions/grib2/tables/13/4.2.0.5.table @@ -6,6 +6,6 @@ 4 4 Upward long-wave radiation flux (W m-2) 5 5 Net long-wave radiation flux (W m-2) 6 6 Net long-wave radiation flux, clear sky (W m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.6.table b/definitions/grib2/tables/13/4.2.0.6.table index 9ee97b73f..89da06eec 100644 --- a/definitions/grib2/tables/13/4.2.0.6.table +++ b/definitions/grib2/tables/13/4.2.0.6.table @@ -35,6 +35,6 @@ 33 33 Sunshine duration (s) 34 34 Surface long-wave effective total cloudiness (Numeric) 35 35 Surface short-wave effective total cloudiness (Numeric) -# 36-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 36-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.0.7.table b/definitions/grib2/tables/13/4.2.0.7.table index db47d0113..8a2b85fb9 100644 --- a/definitions/grib2/tables/13/4.2.0.7.table +++ b/definitions/grib2/tables/13/4.2.0.7.table @@ -13,8 +13,8 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraft helicity (m2 s-2) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.1.0.table b/definitions/grib2/tables/13/4.2.1.0.table index cf56b08ee..f455c3365 100644 --- a/definitions/grib2/tables/13/4.2.1.0.table +++ b/definitions/grib2/tables/13/4.2.1.0.table @@ -7,6 +7,6 @@ 5 5 Baseflow-groundwater runoff (kg m-2) 6 6 Storm surface runoff (kg m-2) 7 7 Discharge from rivers or streams (m3/s) -# 8-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.1.1.table b/definitions/grib2/tables/13/4.2.1.1.table index b488eb0bd..171da3958 100644 --- a/definitions/grib2/tables/13/4.2.1.1.table +++ b/definitions/grib2/tables/13/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.10.0.table b/definitions/grib2/tables/13/4.2.10.0.table index 095f51bdf..3611abd9a 100644 --- a/definitions/grib2/tables/13/4.2.10.0.table +++ b/definitions/grib2/tables/13/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (/s) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.10.1.table b/definitions/grib2/tables/13/4.2.10.1.table index 5959bfa28..f0a073c00 100644 --- a/definitions/grib2/tables/13/4.2.10.1.table +++ b/definitions/grib2/tables/13/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.10.191.table b/definitions/grib2/tables/13/4.2.10.191.table index dc0e23d7b..1ebf85006 100644 --- a/definitions/grib2/tables/13/4.2.10.191.table +++ b/definitions/grib2/tables/13/4.2.10.191.table @@ -3,6 +3,6 @@ 1 1 Meridional overturning stream function (m3/s) 2 2 Reserved 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.10.2.table b/definitions/grib2/tables/13/4.2.10.2.table index 157a9af65..0caeacba7 100644 --- a/definitions/grib2/tables/13/4.2.10.2.table +++ b/definitions/grib2/tables/13/4.2.10.2.table @@ -12,6 +12,6 @@ 10 10 Zonal vector component of vertically integrated ice internal pressure (Pa m) 11 11 Meridional vector component of vertically integrated ice internal pressure (Pa m) 12 12 Compressive ice strength (N/m) -# 13-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.10.3.table b/definitions/grib2/tables/13/4.2.10.3.table index f951bbe78..937720c93 100644 --- a/definitions/grib2/tables/13/4.2.10.3.table +++ b/definitions/grib2/tables/13/4.2.10.3.table @@ -1,6 +1,6 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.10.4.table b/definitions/grib2/tables/13/4.2.10.4.table index 54774f1b7..d5615ae26 100644 --- a/definitions/grib2/tables/13/4.2.10.4.table +++ b/definitions/grib2/tables/13/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2/s) 6 6 Ocean vertical momentum diffusivity (m2/s) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (/m) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.2.0.table b/definitions/grib2/tables/13/4.2.2.0.table index 93135b854..00342a32b 100644 --- a/definitions/grib2/tables/13/4.2.2.0.table +++ b/definitions/grib2/tables/13/4.2.2.0.table @@ -34,6 +34,6 @@ 32 32 Root depth of vegetation (m) 33 33 Water runoff and drainage (kg m-2) 34 34 Surface water runoff (kg m-2) -# 35-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 35-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.2.3.table b/definitions/grib2/tables/13/4.2.2.3.table index 2f6291077..3d3298c8a 100644 --- a/definitions/grib2/tables/13/4.2.2.3.table +++ b/definitions/grib2/tables/13/4.2.2.3.table @@ -22,6 +22,6 @@ 20 20 Column-integrated soil moisture (kg m-2) 21 21 Soil ice (kg m-3) 22 22 Column-integrated soil ice (kg m-2) -# 23-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 23-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.2.4.table b/definitions/grib2/tables/13/4.2.2.4.table index d4ede2f70..c8b877df6 100644 --- a/definitions/grib2/tables/13/4.2.2.4.table +++ b/definitions/grib2/tables/13/4.2.2.4.table @@ -4,6 +4,6 @@ 2 2 Haines Index (Numeric) 3 3 Fire burned area (%) 4 4 Fosberg index (Numeric) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.3.0.table b/definitions/grib2/tables/13/4.2.3.0.table index c0ffa29f5..80a829673 100644 --- a/definitions/grib2/tables/13/4.2.3.0.table +++ b/definitions/grib2/tables/13/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.2.3.1.table b/definitions/grib2/tables/13/4.2.3.1.table index 0c0fc8d37..bc16d8855 100644 --- a/definitions/grib2/tables/13/4.2.3.1.table +++ b/definitions/grib2/tables/13/4.2.3.1.table @@ -17,12 +17,12 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +23 23 Angstrom coefficient +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.201.table b/definitions/grib2/tables/13/4.201.table index 2510f2ef7..fa173c4e0 100644 --- a/definitions/grib2/tables/13/4.201.table +++ b/definitions/grib2/tables/13/4.201.table @@ -10,6 +10,6 @@ 8 8 Ice pellets 9 9 Graupel 10 10 Hail -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.202.table b/definitions/grib2/tables/13/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/13/4.202.table +++ b/definitions/grib2/tables/13/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.203.table b/definitions/grib2/tables/13/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/13/4.203.table +++ b/definitions/grib2/tables/13/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.204.table b/definitions/grib2/tables/13/4.204.table index 91bcf1814..ffbd89502 100644 --- a/definitions/grib2/tables/13/4.204.table +++ b/definitions/grib2/tables/13/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (16-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (16-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.205.table b/definitions/grib2/tables/13/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/13/4.205.table +++ b/definitions/grib2/tables/13/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.206.table b/definitions/grib2/tables/13/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/13/4.206.table +++ b/definitions/grib2/tables/13/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.207.table b/definitions/grib2/tables/13/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/13/4.207.table +++ b/definitions/grib2/tables/13/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.208.table b/definitions/grib2/tables/13/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/13/4.208.table +++ b/definitions/grib2/tables/13/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.209.table b/definitions/grib2/tables/13/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/13/4.209.table +++ b/definitions/grib2/tables/13/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.210.table b/definitions/grib2/tables/13/4.210.table index 524a6ca73..791878469 100644 --- a/definitions/grib2/tables/13/4.210.table +++ b/definitions/grib2/tables/13/4.210.table @@ -1,6 +1,6 @@ # Code table 4.210 - Contrail intensity -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.211.table b/definitions/grib2/tables/13/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/13/4.211.table +++ b/definitions/grib2/tables/13/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.212.table b/definitions/grib2/tables/13/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/13/4.212.table +++ b/definitions/grib2/tables/13/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.213.table b/definitions/grib2/tables/13/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/13/4.213.table +++ b/definitions/grib2/tables/13/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.215.table b/definitions/grib2/tables/13/4.215.table index 88fda8b8c..c264c6722 100644 --- a/definitions/grib2/tables/13/4.215.table +++ b/definitions/grib2/tables/13/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely-sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.216.table b/definitions/grib2/tables/13/4.216.table index 4d9a70f86..b51b358f4 100644 --- a/definitions/grib2/tables/13/4.216.table +++ b/definitions/grib2/tables/13/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain # 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/13/4.217.table b/definitions/grib2/tables/13/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/13/4.217.table +++ b/definitions/grib2/tables/13/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.218.table b/definitions/grib2/tables/13/4.218.table index 6940a0e41..acf069c32 100644 --- a/definitions/grib2/tables/13/4.218.table +++ b/definitions/grib2/tables/13/4.218.table @@ -1,38 +1,38 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation / crops -15 15 Permanent snow / ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -# 19-96 Reserved -97 97 Snow / ice on land -98 98 Snow / ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud / fog / Stratus -102 102 Low cloud / Stratocumulus -103 103 Low cloud / unknown type -104 104 Medium cloud / Nimbostratus -105 105 Medium cloud / Altostratus -106 106 Medium cloud / unknown type -107 107 High cloud / Cumulus -108 108 High cloud / Cirrus -109 109 High cloud / unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation / crops +15 15 Permanent snow / ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +# 19-96 Reserved +97 97 Snow / ice on land +98 98 Snow / ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud / fog / Stratus +102 102 Low cloud / Stratocumulus +103 103 Low cloud / unknown type +104 104 Medium cloud / Nimbostratus +105 105 Medium cloud / Altostratus +106 106 Medium cloud / unknown type +107 107 High cloud / Cumulus +108 108 High cloud / Cirrus +109 109 High cloud / unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.219.table b/definitions/grib2/tables/13/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/13/4.219.table +++ b/definitions/grib2/tables/13/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.220.table b/definitions/grib2/tables/13/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/13/4.220.table +++ b/definitions/grib2/tables/13/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.221.table b/definitions/grib2/tables/13/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/13/4.221.table +++ b/definitions/grib2/tables/13/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.222.table b/definitions/grib2/tables/13/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/13/4.222.table +++ b/definitions/grib2/tables/13/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.223.table b/definitions/grib2/tables/13/4.223.table index f0deb076a..572c4e7a8 100644 --- a/definitions/grib2/tables/13/4.223.table +++ b/definitions/grib2/tables/13/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/13/4.224.table b/definitions/grib2/tables/13/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/13/4.224.table +++ b/definitions/grib2/tables/13/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/13/4.227.table b/definitions/grib2/tables/13/4.227.table index 27c76553d..48c3b7633 100644 --- a/definitions/grib2/tables/13/4.227.table +++ b/definitions/grib2/tables/13/4.227.table @@ -1,9 +1,9 @@ # Code table 4.227 - Icing scenario (weather/cloud classification) -0 0 None -1 1 General -2 2 Convective -3 3 Stratiform -4 4 Freezing -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/13/4.234.table b/definitions/grib2/tables/13/4.234.table index 9844a91d2..d8b3715b3 100644 --- a/definitions/grib2/tables/13/4.234.table +++ b/definitions/grib2/tables/13/4.234.table @@ -1,21 +1,21 @@ # Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Crops, mixed farming -2 2 Short grass -3 3 Evergreen needleleaf trees -4 4 Deciduous needleleaf trees -5 5 Deciduous broadleaf trees -6 6 Evergreen broadleaf trees -7 7 Tall grass -8 8 Desert -9 9 Tundra -10 10 Irrigated crops -11 11 Semidesert -12 12 Ice caps and glaciers -13 13 Bogs and marshes -14 14 Inland water -15 15 Ocean -16 16 Evergreen shrubs -17 17 Deciduous shrubs -18 18 Mixed forest -19 19 Interrupted forest -20 20 Water and land mixtures +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/13/4.236.table b/definitions/grib2/tables/13/4.236.table index 08c7f8d56..b667b65fc 100644 --- a/definitions/grib2/tables/13/4.236.table +++ b/definitions/grib2/tables/13/4.236.table @@ -1,8 +1,8 @@ # Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Coarse -2 2 Medium -3 3 Medium-fine -4 4 Fine -5 5 Very-fine -6 6 Organic -7 7 Tropical-organic +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/13/4.3.table b/definitions/grib2/tables/13/4.3.table index 1a9d59dd1..2b775c807 100644 --- a/definitions/grib2/tables/13/4.3.table +++ b/definitions/grib2/tables/13/4.3.table @@ -1,18 +1,18 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast 12 12 Post-processed analysis 13 13 Post-processed forecast -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.4.table b/definitions/grib2/tables/13/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/13/4.4.table +++ b/definitions/grib2/tables/13/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.5.table b/definitions/grib2/tables/13/4.5.table index ddab1d723..d61b61c9f 100644 --- a/definitions/grib2/tables/13/4.5.table +++ b/definitions/grib2/tables/13/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface 2 2 Cloud base level 3 3 Level of cloud tops @@ -12,11 +12,11 @@ 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,7 +25,7 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level 112 112 Reserved 113 113 Logarithmic hybrid level @@ -36,7 +36,7 @@ 119 hpl Hybrid pressure level # 120-149 Reserved 150 150 Generalized vertical height coordinate -# 151-159 Reserved +# 151-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom @@ -45,6 +45,6 @@ 165 165 Bottom of sediment layer penetrated by thermal wave 166 sfc Mixing layer 167 167 Bottom of root zone -# 168-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 168-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.6.table b/definitions/grib2/tables/13/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/13/4.6.table +++ b/definitions/grib2/tables/13/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.7.table b/definitions/grib2/tables/13/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/13/4.7.table +++ b/definitions/grib2/tables/13/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.8.table b/definitions/grib2/tables/13/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/13/4.8.table +++ b/definitions/grib2/tables/13/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.9.table b/definitions/grib2/tables/13/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/13/4.9.table +++ b/definitions/grib2/tables/13/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/4.91.table b/definitions/grib2/tables/13/4.91.table index 97b1c70ad..ae31ed61c 100644 --- a/definitions/grib2/tables/13/4.91.table +++ b/definitions/grib2/tables/13/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit 11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/13/5.1.table b/definitions/grib2/tables/13/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/13/5.1.table +++ b/definitions/grib2/tables/13/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/5.2.table b/definitions/grib2/tables/13/5.2.table index 7a4500ecd..d12b46fbd 100644 --- a/definitions/grib2/tables/13/5.2.table +++ b/definitions/grib2/tables/13/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use +# 12-191 Reserved +# 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/13/5.3.table b/definitions/grib2/tables/13/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/13/5.3.table +++ b/definitions/grib2/tables/13/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/5.4.table b/definitions/grib2/tables/13/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/13/5.4.table +++ b/definitions/grib2/tables/13/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/5.40.table b/definitions/grib2/tables/13/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/13/5.40.table +++ b/definitions/grib2/tables/13/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/13/5.5.table b/definitions/grib2/tables/13/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/13/5.5.table +++ b/definitions/grib2/tables/13/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/5.6.table b/definitions/grib2/tables/13/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/13/5.6.table +++ b/definitions/grib2/tables/13/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/13/5.7.table b/definitions/grib2/tables/13/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/13/5.7.table +++ b/definitions/grib2/tables/13/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/13/6.0.table b/definitions/grib2/tables/13/6.0.table index f539b26d7..a8f30f5a4 100644 --- a/definitions/grib2/tables/13/6.0.table +++ b/definitions/grib2/tables/13/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/14/0.0.table b/definitions/grib2/tables/14/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/14/0.0.table +++ b/definitions/grib2/tables/14/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/1.0.table b/definitions/grib2/tables/14/1.0.table index 4dafc79fb..a004eadb3 100644 --- a/definitions/grib2/tables/14/1.0.table +++ b/definitions/grib2/tables/14/1.0.table @@ -1,19 +1,19 @@ # Code table 1.0 - GRIB master tables version number -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 -6 6 Version implemented on 15 September 2010 -7 7 Version implemented on 4 May 2011 -8 8 Version implemented on 2 November 2011 -9 9 Version implemented on 2 May 2012 -10 10 Version implemented on 7 November 2012 -11 11 Version implemented on 8 May 2013 -12 12 Version implemented on 14 November 2013 -13 13 Version implemented on 7 May 2014 -14 14 Version implemented on 5 November 2014 -15 15 Pre-operational to be implemented by next amendment -# 16-254 Future versions -255 255 Missing +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Version implemented on 2 May 2012 +10 10 Version implemented on 7 November 2012 +11 11 Version implemented on 8 May 2013 +12 12 Version implemented on 14 November 2013 +13 13 Version implemented on 7 May 2014 +14 14 Version implemented on 5 November 2014 +15 15 Pre-operational to be implemented by next amendment +# 16-254 Future versions +255 255 Missing diff --git a/definitions/grib2/tables/14/1.1.table b/definitions/grib2/tables/14/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/14/1.1.table +++ b/definitions/grib2/tables/14/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/14/1.2.table b/definitions/grib2/tables/14/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/14/1.2.table +++ b/definitions/grib2/tables/14/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/1.3.table b/definitions/grib2/tables/14/1.3.table index ea01c001c..eb3a79f9b 100644 --- a/definitions/grib2/tables/14/1.3.table +++ b/definitions/grib2/tables/14/1.3.table @@ -1,14 +1,14 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products 4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) 6 6 S2S operational products 7 7 S2S test products 8 8 Uncertainties in ensembles of regional re-analysis project (UERRA) 9 9 Uncertainties in ensembles of regional re-analysis project test (UERRA) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/1.4.table b/definitions/grib2/tables/14/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/14/1.4.table +++ b/definitions/grib2/tables/14/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/14/1.5.table b/definitions/grib2/tables/14/1.5.table index b2cf9f087..533111959 100644 --- a/definitions/grib2/tables/14/1.5.table +++ b/definitions/grib2/tables/14/1.5.table @@ -1,7 +1,7 @@ # Code table 1.5 - Identification template number -0 0 Calendar definition -1 1 Paleontological offset -2 2 Calendar definition and paleontological offset -# 3-32767 Reserved -# 32768-65534 Reserved for local use -65535 65535 Missing +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/14/1.6.table b/definitions/grib2/tables/14/1.6.table index 5db921990..bd46899a7 100644 --- a/definitions/grib2/tables/14/1.6.table +++ b/definitions/grib2/tables/14/1.6.table @@ -1,8 +1,8 @@ # Code table 1.6 - Type of calendar -0 0 Gregorian -1 1 360-day -2 2 365-day -3 3 Proleptic Gregorian -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/3.0.table b/definitions/grib2/tables/14/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/14/3.0.table +++ b/definitions/grib2/tables/14/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/14/3.10.table b/definitions/grib2/tables/14/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/14/3.10.table +++ b/definitions/grib2/tables/14/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/14/3.11.table b/definitions/grib2/tables/14/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/14/3.11.table +++ b/definitions/grib2/tables/14/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/14/3.15.table b/definitions/grib2/tables/14/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/14/3.15.table +++ b/definitions/grib2/tables/14/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/3.2.table b/definitions/grib2/tables/14/3.2.table index 9238dc2a7..b9574a424 100644 --- a/definitions/grib2/tables/14/3.2.table +++ b/definitions/grib2/tables/14/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/3.20.table b/definitions/grib2/tables/14/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/14/3.20.table +++ b/definitions/grib2/tables/14/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/3.21.table b/definitions/grib2/tables/14/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/14/3.21.table +++ b/definitions/grib2/tables/14/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/3.3.table b/definitions/grib2/tables/14/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/14/3.3.table +++ b/definitions/grib2/tables/14/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/14/3.4.table b/definitions/grib2/tables/14/3.4.table index 897b813d7..43835c014 100644 --- a/definitions/grib2/tables/14/3.4.table +++ b/definitions/grib2/tables/14/3.4.table @@ -1,17 +1,17 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -5 0 Points within odd rows are not offset in i (x) direction -5 1 Points within odd rows are offset by Di/2 in i (x) direction -6 0 Points within even rows are not offset in i (x) direction -6 1 Points within even rows are offset by Di/2 in i (x) direction -7 0 Points are not offset in j (y) direction -7 1 Points are offset by Dj/2 in j (y) direction -8 0 Rows have Ni grid points and columns have Nj grid points -8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +5 0 Points within odd rows are not offset in i (x) direction +5 1 Points within odd rows are offset by Di/2 in i (x) direction +6 0 Points within even rows are not offset in i (x) direction +6 1 Points within even rows are offset by Di/2 in i (x) direction +7 0 Points are not offset in j (y) direction +7 1 Points are offset by Dj/2 in j (y) direction +8 0 Rows have Ni grid points and columns have Nj grid points +8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction diff --git a/definitions/grib2/tables/14/3.5.table b/definitions/grib2/tables/14/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/14/3.5.table +++ b/definitions/grib2/tables/14/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/14/3.7.table b/definitions/grib2/tables/14/3.7.table index 0a7d6efde..34c0de085 100644 --- a/definitions/grib2/tables/14/3.7.table +++ b/definitions/grib2/tables/14/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 see separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/14/3.8.table b/definitions/grib2/tables/14/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/14/3.8.table +++ b/definitions/grib2/tables/14/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/3.9.table b/definitions/grib2/tables/14/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/14/3.9.table +++ b/definitions/grib2/tables/14/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/14/4.0.table b/definitions/grib2/tables/14/4.0.table index b24b6fb11..7627a2a3d 100644 --- a/definitions/grib2/tables/14/4.0.table +++ b/definitions/grib2/tables/14/4.0.table @@ -1,62 +1,62 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time -8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -# 35-39 Reserved +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +# 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol -46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -# 49-50 Reserved -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time -52 52 Reserved -53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time -54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters -# 55-59 Reserved -60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +# 49-50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +52 52 Reserved +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +# 55-59 Reserved +60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time 61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 62-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +# 62-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/14/4.1.0.table b/definitions/grib2/tables/14/4.1.0.table index 04cfd7802..df58636d6 100644 --- a/definitions/grib2/tables/14/4.1.0.table +++ b/definitions/grib2/tables/14/4.1.0.table @@ -1,27 +1,27 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.1.1.table b/definitions/grib2/tables/14/4.1.1.table index 7b22b6fed..05a854da0 100644 --- a/definitions/grib2/tables/14/4.1.1.table +++ b/definitions/grib2/tables/14/4.1.1.table @@ -1,7 +1,7 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.1.10.table b/definitions/grib2/tables/14/4.1.10.table index b97dcd355..e9663f391 100644 --- a/definitions/grib2/tables/14/4.1.10.table +++ b/definitions/grib2/tables/14/4.1.10.table @@ -1,10 +1,10 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Sub-surface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Sub-surface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.1.2.table b/definitions/grib2/tables/14/4.1.2.table index 5b488fe9e..e74126645 100644 --- a/definitions/grib2/tables/14/4.1.2.table +++ b/definitions/grib2/tables/14/4.1.2.table @@ -1,9 +1,9 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.1.3.table b/definitions/grib2/tables/14/4.1.3.table index 5096a166e..c1a1e267a 100644 --- a/definitions/grib2/tables/14/4.1.3.table +++ b/definitions/grib2/tables/14/4.1.3.table @@ -1,6 +1,6 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Image format products -1 1 Quantitative products -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.10.table b/definitions/grib2/tables/14/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/14/4.10.table +++ b/definitions/grib2/tables/14/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/14/4.11.table b/definitions/grib2/tables/14/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/14/4.11.table +++ b/definitions/grib2/tables/14/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.12.table b/definitions/grib2/tables/14/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/14/4.12.table +++ b/definitions/grib2/tables/14/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.13.table b/definitions/grib2/tables/14/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/14/4.13.table +++ b/definitions/grib2/tables/14/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.14.table b/definitions/grib2/tables/14/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/14/4.14.table +++ b/definitions/grib2/tables/14/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.15.table b/definitions/grib2/tables/14/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/14/4.15.table +++ b/definitions/grib2/tables/14/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.0.table b/definitions/grib2/tables/14/4.2.0.0.table index 41e5291a9..24d21959d 100644 --- a/definitions/grib2/tables/14/4.2.0.0.table +++ b/definitions/grib2/tables/14/4.2.0.0.table @@ -21,6 +21,6 @@ 19 19 Turbulent transfer coefficient for heat (Numeric) 20 20 Turbulent diffusion coefficient for heat (m2/s) 21 21 Apparent temperature (K) -# 22-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 22-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.1.table b/definitions/grib2/tables/14/4.2.0.1.table index 4c624e74a..bd0214c77 100644 --- a/definitions/grib2/tables/14/4.2.0.1.table +++ b/definitions/grib2/tables/14/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,12 +86,12 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) 93 93 Relative humidity with respect to water (%) 94 94 Relative humidity with respect to ice (%) -# 95-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 95-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.13.table b/definitions/grib2/tables/14/4.2.0.13.table index 5086101ad..3f5c30675 100644 --- a/definitions/grib2/tables/14/4.2.0.13.table +++ b/definitions/grib2/tables/14/4.2.0.13.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.14.table b/definitions/grib2/tables/14/4.2.0.14.table index 215884737..97fb38c8b 100644 --- a/definitions/grib2/tables/14/4.2.0.14.table +++ b/definitions/grib2/tables/14/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.15.table b/definitions/grib2/tables/14/4.2.0.15.table index d74fa7234..bb0b9ab46 100644 --- a/definitions/grib2/tables/14/4.2.0.15.table +++ b/definitions/grib2/tables/14/4.2.0.15.table @@ -14,6 +14,6 @@ 12 12 Reflectivity of rain (dB) 13 13 Reflectivity of graupel (dB) 14 14 Reflectivity of hail (dB) -# 15-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 15-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.16.table b/definitions/grib2/tables/14/4.2.0.16.table index 0c240a853..9499d9333 100644 --- a/definitions/grib2/tables/14/4.2.0.16.table +++ b/definitions/grib2/tables/14/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.18.table b/definitions/grib2/tables/14/4.2.0.18.table index 18c41aa48..7e0a736eb 100644 --- a/definitions/grib2/tables/14/4.2.0.18.table +++ b/definitions/grib2/tables/14/4.2.0.18.table @@ -8,11 +8,11 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) 13 13 Total deposition (wet + dry) (Bq m-2) -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.19.table b/definitions/grib2/tables/14/4.2.0.19.table index 75101bd37..d2beef083 100644 --- a/definitions/grib2/tables/14/4.2.0.19.table +++ b/definitions/grib2/tables/14/4.2.0.19.table @@ -27,6 +27,6 @@ 25 25 Weather (Code table 4.225) 26 26 Convective outlook (Code table 4.224) 27 27 Icing scenario (Code table 4.227) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.190.table b/definitions/grib2/tables/14/4.2.0.190.table index de621a924..a0d6ba0ac 100644 --- a/definitions/grib2/tables/14/4.2.0.190.table +++ b/definitions/grib2/tables/14/4.2.0.190.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.191.table b/definitions/grib2/tables/14/4.2.0.191.table index e3bba0ebe..b3a7092ea 100644 --- a/definitions/grib2/tables/14/4.2.0.191.table +++ b/definitions/grib2/tables/14/4.2.0.191.table @@ -3,6 +3,6 @@ 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.2.table b/definitions/grib2/tables/14/4.2.0.2.table index c83b07300..7bd1509f5 100644 --- a/definitions/grib2/tables/14/4.2.0.2.table +++ b/definitions/grib2/tables/14/4.2.0.2.table @@ -38,6 +38,6 @@ 36 36 Amplitude function for Rossby wave envelope for meridional wind (m/s) 37 37 Northward turbulent surface stress (N m-2 s) 38 38 Eastward turbulent surface stress (N m-2 s) -# 39-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 39-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.20.table b/definitions/grib2/tables/14/4.2.0.20.table index 9584f7c7f..df9ccc184 100644 --- a/definitions/grib2/tables/14/4.2.0.20.table +++ b/definitions/grib2/tables/14/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -25,7 +25,7 @@ 57 57 Total yearly average burden of the atmosphere (mol) 58 58 Total yearly averaged atmospheric loss (mol/s) 59 59 Aerosol number concentration (m-3) -# 60-99 Reserved +# 60-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -37,6 +37,6 @@ 108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) 109 109 Aerosol lidar extinction from satellite (/m) 110 110 Aerosol lidar extinction from the ground (/m) -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.3.table b/definitions/grib2/tables/14/4.2.0.3.table index 9a88e0027..e1a68bfc5 100644 --- a/definitions/grib2/tables/14/4.2.0.3.table +++ b/definitions/grib2/tables/14/4.2.0.3.table @@ -26,6 +26,6 @@ 24 24 Anisotropy of sub-gridscale orography (Numeric) 25 25 Natural logarithm of pressure in Pa (Numeric) 26 26 Exner pressure (Numeric) -# 27-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 27-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.4.table b/definitions/grib2/tables/14/4.2.0.4.table index dbfcbddb7..03b5cea38 100644 --- a/definitions/grib2/tables/14/4.2.0.4.table +++ b/definitions/grib2/tables/14/4.2.0.4.table @@ -12,9 +12,9 @@ 10 10 Photosynthetically active radiation (W m-2) 11 11 Net short-wave radiation flux, clear sky (W m-2) 12 12 Downward UV radiation (W m-2) -# 13-49 Reserved +# 13-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) -# 52-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.5.table b/definitions/grib2/tables/14/4.2.0.5.table index f1c04650d..1bdd6ebee 100644 --- a/definitions/grib2/tables/14/4.2.0.5.table +++ b/definitions/grib2/tables/14/4.2.0.5.table @@ -6,6 +6,6 @@ 4 4 Upward long-wave radiation flux (W m-2) 5 5 Net long-wave radiation flux (W m-2) 6 6 Net long-wave radiation flux, clear sky (W m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.6.table b/definitions/grib2/tables/14/4.2.0.6.table index 702152741..427240b70 100644 --- a/definitions/grib2/tables/14/4.2.0.6.table +++ b/definitions/grib2/tables/14/4.2.0.6.table @@ -37,6 +37,6 @@ 35 35 Surface short-wave effective total cloudiness (Numeric) 36 36 Fraction of stratiform precipitation cover (Proportion) 37 37 Fraction of convective precipitation cover (Proportion) -# 38-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 38-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.0.7.table b/definitions/grib2/tables/14/4.2.0.7.table index db47d0113..8a2b85fb9 100644 --- a/definitions/grib2/tables/14/4.2.0.7.table +++ b/definitions/grib2/tables/14/4.2.0.7.table @@ -13,8 +13,8 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraft helicity (m2 s-2) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.1.0.table b/definitions/grib2/tables/14/4.2.1.0.table index cf56b08ee..f455c3365 100644 --- a/definitions/grib2/tables/14/4.2.1.0.table +++ b/definitions/grib2/tables/14/4.2.1.0.table @@ -7,6 +7,6 @@ 5 5 Baseflow-groundwater runoff (kg m-2) 6 6 Storm surface runoff (kg m-2) 7 7 Discharge from rivers or streams (m3/s) -# 8-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.1.1.table b/definitions/grib2/tables/14/4.2.1.1.table index b488eb0bd..171da3958 100644 --- a/definitions/grib2/tables/14/4.2.1.1.table +++ b/definitions/grib2/tables/14/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.10.0.table b/definitions/grib2/tables/14/4.2.10.0.table index 095f51bdf..3611abd9a 100644 --- a/definitions/grib2/tables/14/4.2.10.0.table +++ b/definitions/grib2/tables/14/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (/s) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.10.1.table b/definitions/grib2/tables/14/4.2.10.1.table index 5959bfa28..f0a073c00 100644 --- a/definitions/grib2/tables/14/4.2.10.1.table +++ b/definitions/grib2/tables/14/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.10.191.table b/definitions/grib2/tables/14/4.2.10.191.table index 524929e78..1ebf85006 100644 --- a/definitions/grib2/tables/14/4.2.10.191.table +++ b/definitions/grib2/tables/14/4.2.10.191.table @@ -1,8 +1,8 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -2 2 Reserved +2 2 Reserved 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.10.2.table b/definitions/grib2/tables/14/4.2.10.2.table index 6797062ac..4633bad4f 100644 --- a/definitions/grib2/tables/14/4.2.10.2.table +++ b/definitions/grib2/tables/14/4.2.10.2.table @@ -12,6 +12,6 @@ 10 10 Zonal vector component of vertically integrated ice internal pressure (Pa m) 11 11 Meridional vector component of vertically integrated ice internal pressure (Pa m) 12 12 Compressive ice strength (N/m) -# 13-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.10.3.table b/definitions/grib2/tables/14/4.2.10.3.table index f951bbe78..937720c93 100644 --- a/definitions/grib2/tables/14/4.2.10.3.table +++ b/definitions/grib2/tables/14/4.2.10.3.table @@ -1,6 +1,6 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.10.4.table b/definitions/grib2/tables/14/4.2.10.4.table index 54774f1b7..d5615ae26 100644 --- a/definitions/grib2/tables/14/4.2.10.4.table +++ b/definitions/grib2/tables/14/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2/s) 6 6 Ocean vertical momentum diffusivity (m2/s) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (/m) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.2.0.table b/definitions/grib2/tables/14/4.2.2.0.table index 1853aa0fc..d61dd05fc 100644 --- a/definitions/grib2/tables/14/4.2.2.0.table +++ b/definitions/grib2/tables/14/4.2.2.0.table @@ -37,6 +37,6 @@ 35 35 Tile class (Code table 4.243) 36 36 Tile fraction (Proportion) 37 37 Tile percentage (%) -# 38-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 38-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.2.3.table b/definitions/grib2/tables/14/4.2.2.3.table index 2f6291077..3d3298c8a 100644 --- a/definitions/grib2/tables/14/4.2.2.3.table +++ b/definitions/grib2/tables/14/4.2.2.3.table @@ -22,6 +22,6 @@ 20 20 Column-integrated soil moisture (kg m-2) 21 21 Soil ice (kg m-3) 22 22 Column-integrated soil ice (kg m-2) -# 23-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 23-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.2.4.table b/definitions/grib2/tables/14/4.2.2.4.table index d4ede2f70..c8b877df6 100644 --- a/definitions/grib2/tables/14/4.2.2.4.table +++ b/definitions/grib2/tables/14/4.2.2.4.table @@ -4,6 +4,6 @@ 2 2 Haines Index (Numeric) 3 3 Fire burned area (%) 4 4 Fosberg index (Numeric) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.3.0.table b/definitions/grib2/tables/14/4.2.3.0.table index c0ffa29f5..80a829673 100644 --- a/definitions/grib2/tables/14/4.2.3.0.table +++ b/definitions/grib2/tables/14/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.2.3.1.table b/definitions/grib2/tables/14/4.2.3.1.table index 0c0fc8d37..bc16d8855 100644 --- a/definitions/grib2/tables/14/4.2.3.1.table +++ b/definitions/grib2/tables/14/4.2.3.1.table @@ -17,12 +17,12 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +23 23 Angstrom coefficient +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.201.table b/definitions/grib2/tables/14/4.201.table index 47f1b486f..fa173c4e0 100644 --- a/definitions/grib2/tables/14/4.201.table +++ b/definitions/grib2/tables/14/4.201.table @@ -1,15 +1,15 @@ # Code table 4.201 - Precipitation type -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow -6 6 Wet snow -7 7 Mixture of rain and snow -8 8 Ice pellets -9 9 Graupel -10 10 Hail -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +6 6 Wet snow +7 7 Mixture of rain and snow +8 8 Ice pellets +9 9 Graupel +10 10 Hail +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.202.table b/definitions/grib2/tables/14/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/14/4.202.table +++ b/definitions/grib2/tables/14/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.203.table b/definitions/grib2/tables/14/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/14/4.203.table +++ b/definitions/grib2/tables/14/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.204.table b/definitions/grib2/tables/14/4.204.table index 91bcf1814..ffbd89502 100644 --- a/definitions/grib2/tables/14/4.204.table +++ b/definitions/grib2/tables/14/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (16-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (16-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.205.table b/definitions/grib2/tables/14/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/14/4.205.table +++ b/definitions/grib2/tables/14/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.206.table b/definitions/grib2/tables/14/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/14/4.206.table +++ b/definitions/grib2/tables/14/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.207.table b/definitions/grib2/tables/14/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/14/4.207.table +++ b/definitions/grib2/tables/14/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.208.table b/definitions/grib2/tables/14/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/14/4.208.table +++ b/definitions/grib2/tables/14/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.209.table b/definitions/grib2/tables/14/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/14/4.209.table +++ b/definitions/grib2/tables/14/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.210.table b/definitions/grib2/tables/14/4.210.table index 524a6ca73..791878469 100644 --- a/definitions/grib2/tables/14/4.210.table +++ b/definitions/grib2/tables/14/4.210.table @@ -1,6 +1,6 @@ # Code table 4.210 - Contrail intensity -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.211.table b/definitions/grib2/tables/14/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/14/4.211.table +++ b/definitions/grib2/tables/14/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.212.table b/definitions/grib2/tables/14/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/14/4.212.table +++ b/definitions/grib2/tables/14/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.213.table b/definitions/grib2/tables/14/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/14/4.213.table +++ b/definitions/grib2/tables/14/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.215.table b/definitions/grib2/tables/14/4.215.table index 88fda8b8c..c264c6722 100644 --- a/definitions/grib2/tables/14/4.215.table +++ b/definitions/grib2/tables/14/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely-sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.216.table b/definitions/grib2/tables/14/4.216.table index 5d1460cef..b51b358f4 100644 --- a/definitions/grib2/tables/14/4.216.table +++ b/definitions/grib2/tables/14/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain -# 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 0-90 Elevation in increments of 100 m +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/14/4.217.table b/definitions/grib2/tables/14/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/14/4.217.table +++ b/definitions/grib2/tables/14/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.218.table b/definitions/grib2/tables/14/4.218.table index 6940a0e41..acf069c32 100644 --- a/definitions/grib2/tables/14/4.218.table +++ b/definitions/grib2/tables/14/4.218.table @@ -1,38 +1,38 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation / crops -15 15 Permanent snow / ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -# 19-96 Reserved -97 97 Snow / ice on land -98 98 Snow / ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud / fog / Stratus -102 102 Low cloud / Stratocumulus -103 103 Low cloud / unknown type -104 104 Medium cloud / Nimbostratus -105 105 Medium cloud / Altostratus -106 106 Medium cloud / unknown type -107 107 High cloud / Cumulus -108 108 High cloud / Cirrus -109 109 High cloud / unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation / crops +15 15 Permanent snow / ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +# 19-96 Reserved +97 97 Snow / ice on land +98 98 Snow / ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud / fog / Stratus +102 102 Low cloud / Stratocumulus +103 103 Low cloud / unknown type +104 104 Medium cloud / Nimbostratus +105 105 Medium cloud / Altostratus +106 106 Medium cloud / unknown type +107 107 High cloud / Cumulus +108 108 High cloud / Cirrus +109 109 High cloud / unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.219.table b/definitions/grib2/tables/14/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/14/4.219.table +++ b/definitions/grib2/tables/14/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.220.table b/definitions/grib2/tables/14/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/14/4.220.table +++ b/definitions/grib2/tables/14/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.221.table b/definitions/grib2/tables/14/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/14/4.221.table +++ b/definitions/grib2/tables/14/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.222.table b/definitions/grib2/tables/14/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/14/4.222.table +++ b/definitions/grib2/tables/14/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.223.table b/definitions/grib2/tables/14/4.223.table index f0deb076a..572c4e7a8 100644 --- a/definitions/grib2/tables/14/4.223.table +++ b/definitions/grib2/tables/14/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/14/4.224.table b/definitions/grib2/tables/14/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/14/4.224.table +++ b/definitions/grib2/tables/14/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/14/4.227.table b/definitions/grib2/tables/14/4.227.table index 27c76553d..48c3b7633 100644 --- a/definitions/grib2/tables/14/4.227.table +++ b/definitions/grib2/tables/14/4.227.table @@ -1,9 +1,9 @@ # Code table 4.227 - Icing scenario (weather/cloud classification) -0 0 None -1 1 General -2 2 Convective -3 3 Stratiform -4 4 Freezing -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/14/4.234.table b/definitions/grib2/tables/14/4.234.table index 9844a91d2..d8b3715b3 100644 --- a/definitions/grib2/tables/14/4.234.table +++ b/definitions/grib2/tables/14/4.234.table @@ -1,21 +1,21 @@ # Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Crops, mixed farming -2 2 Short grass -3 3 Evergreen needleleaf trees -4 4 Deciduous needleleaf trees -5 5 Deciduous broadleaf trees -6 6 Evergreen broadleaf trees -7 7 Tall grass -8 8 Desert -9 9 Tundra -10 10 Irrigated crops -11 11 Semidesert -12 12 Ice caps and glaciers -13 13 Bogs and marshes -14 14 Inland water -15 15 Ocean -16 16 Evergreen shrubs -17 17 Deciduous shrubs -18 18 Mixed forest -19 19 Interrupted forest -20 20 Water and land mixtures +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/14/4.236.table b/definitions/grib2/tables/14/4.236.table index 08c7f8d56..b667b65fc 100644 --- a/definitions/grib2/tables/14/4.236.table +++ b/definitions/grib2/tables/14/4.236.table @@ -1,8 +1,8 @@ # Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Coarse -2 2 Medium -3 3 Medium-fine -4 4 Fine -5 5 Very-fine -6 6 Organic -7 7 Tropical-organic +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/14/4.241.table b/definitions/grib2/tables/14/4.241.table index 21b8b207b..ce6a15f3c 100644 --- a/definitions/grib2/tables/14/4.241.table +++ b/definitions/grib2/tables/14/4.241.table @@ -1,9 +1,9 @@ # Code table 4.241 - Coverage attributes -0 0 Undefined -1 1 Unmodified -2 2 Snow-covered -3 3 Flooded -4 4 Ice covered -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Undefined +1 1 Unmodified +2 2 Snow-covered +3 3 Flooded +4 4 Ice covered +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.242.table b/definitions/grib2/tables/14/4.242.table index 012655df6..ca852339d 100644 --- a/definitions/grib2/tables/14/4.242.table +++ b/definitions/grib2/tables/14/4.242.table @@ -1,7 +1,7 @@ # Code table 4.242 - Tile classification -0 0 Reserved -1 1 Land use classes according to ESA-GLOBCOVER GCV2009 -2 2 Land use classes according to European Commission - Global Land Cover Project GLC2000 -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Land use classes according to ESA-GLOBCOVER GCV2009 +2 2 Land use classes according to European Commission - Global Land Cover Project GLC2000 +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.243.table b/definitions/grib2/tables/14/4.243.table index 9f047be33..8677e6819 100644 --- a/definitions/grib2/tables/14/4.243.table +++ b/definitions/grib2/tables/14/4.243.table @@ -1,43 +1,43 @@ # Code table 4.243 - Tile class -0 0 Reserved -1 1 Evergreen broadleaved forest -2 2 Deciduous broadleaved closed forest -3 3 Deciduous broadleaved open forest -4 4 Evergreen needle-leaf forest -5 5 Deciduous needle-leaf forest -6 6 Mixed leaf trees -7 7 Fresh water flooded trees -8 8 Saline water flooded trees -9 9 Mosaic tree/natural vegetation -10 10 Burnt tree cover -11 11 Evergreen shrubs closed-open -12 12 Deciduous shrubs closed-open -13 13 Herbaceous vegetation closed-open -14 14 Sparse herbaceous or grass -15 15 Flooded shrubs or herbaceous -16 16 Cultivated and managed areas -17 17 Mosaic crop/tree/natural vegetation -18 18 Mosaic crop/shrub/grass -19 19 Bare areas -20 20 Water -21 21 Snow and ice -22 22 Artificial surface -23 23 Ocean -24 24 Irrigated croplands -25 25 Rain fed croplands -26 26 Mosaic cropland (50-70%) - vegetation (20-50%) -27 27 Mosaic vegetation (50-70%) - cropland (20-50%) -28 28 Closed broadleaved evergreen forest -29 29 Closed needle-leaved evergreen forest -30 30 Open needle-leaved deciduous forest -31 31 Mixed broadleaved and needle-leaved forest -32 32 Mosaic shrubland (50-70%) - grassland (20-50%) -33 33 Mosaic grassland (50-70%) - shrubland (20-50%) -34 34 Closed to open shrubland -35 35 Sparse vegetation -36 36 Closed to open forest regularly flooded -37 37 Closed forest or shrubland permanently flooded -38 38 Closed to open grassland regularly flooded -39 39 Undefined -# 40-32767 Reserved -# 32768- Reserved for local use +0 0 Reserved +1 1 Evergreen broadleaved forest +2 2 Deciduous broadleaved closed forest +3 3 Deciduous broadleaved open forest +4 4 Evergreen needle-leaf forest +5 5 Deciduous needle-leaf forest +6 6 Mixed leaf trees +7 7 Fresh water flooded trees +8 8 Saline water flooded trees +9 9 Mosaic tree/natural vegetation +10 10 Burnt tree cover +11 11 Evergreen shrubs closed-open +12 12 Deciduous shrubs closed-open +13 13 Herbaceous vegetation closed-open +14 14 Sparse herbaceous or grass +15 15 Flooded shrubs or herbaceous +16 16 Cultivated and managed areas +17 17 Mosaic crop/tree/natural vegetation +18 18 Mosaic crop/shrub/grass +19 19 Bare areas +20 20 Water +21 21 Snow and ice +22 22 Artificial surface +23 23 Ocean +24 24 Irrigated croplands +25 25 Rain fed croplands +26 26 Mosaic cropland (50-70%) - vegetation (20-50%) +27 27 Mosaic vegetation (50-70%) - cropland (20-50%) +28 28 Closed broadleaved evergreen forest +29 29 Closed needle-leaved evergreen forest +30 30 Open needle-leaved deciduous forest +31 31 Mixed broadleaved and needle-leaved forest +32 32 Mosaic shrubland (50-70%) - grassland (20-50%) +33 33 Mosaic grassland (50-70%) - shrubland (20-50%) +34 34 Closed to open shrubland +35 35 Sparse vegetation +36 36 Closed to open forest regularly flooded +37 37 Closed forest or shrubland permanently flooded +38 38 Closed to open grassland regularly flooded +39 39 Undefined +# 40-32767 Reserved +# 32768- Reserved for local use diff --git a/definitions/grib2/tables/14/4.3.table b/definitions/grib2/tables/14/4.3.table index f423af2bf..46e498c5f 100644 --- a/definitions/grib2/tables/14/4.3.table +++ b/definitions/grib2/tables/14/4.3.table @@ -1,20 +1,20 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -12 12 Post-processed analysis -13 13 Post-processed forecast -14 14 Nowcast -15 15 Hindcast -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +12 12 Post-processed analysis +13 13 Post-processed forecast +14 14 Nowcast +15 15 Hindcast +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.4.table b/definitions/grib2/tables/14/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/14/4.4.table +++ b/definitions/grib2/tables/14/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.5.table b/definitions/grib2/tables/14/4.5.table index e6d6d424c..d61b61c9f 100644 --- a/definitions/grib2/tables/14/4.5.table +++ b/definitions/grib2/tables/14/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface 2 2 Cloud base level 3 3 Level of cloud tops @@ -12,11 +12,11 @@ 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,18 +25,18 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level -112 112 Reserved +112 112 Reserved 113 113 Logarithmic hybrid level 114 114 Snow level (Numeric) -# 115-116 Reserved +# 115-116 Reserved 117 117 Mixed layer depth (m) 118 hhl Hybrid height level 119 hpl Hybrid pressure level -# 120-149 Reserved -150 150 Generalized vertical height coordinate -# 151-159 Reserved +# 120-149 Reserved +150 150 Generalized vertical height coordinate +# 151-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom @@ -45,6 +45,6 @@ 165 165 Bottom of sediment layer penetrated by thermal wave 166 sfc Mixing layer 167 167 Bottom of root zone -# 168-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 168-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.6.table b/definitions/grib2/tables/14/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/14/4.6.table +++ b/definitions/grib2/tables/14/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.7.table b/definitions/grib2/tables/14/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/14/4.7.table +++ b/definitions/grib2/tables/14/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.8.table b/definitions/grib2/tables/14/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/14/4.8.table +++ b/definitions/grib2/tables/14/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.9.table b/definitions/grib2/tables/14/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/14/4.9.table +++ b/definitions/grib2/tables/14/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/4.91.table b/definitions/grib2/tables/14/4.91.table index 44cf25f44..ae31ed61c 100644 --- a/definitions/grib2/tables/14/4.91.table +++ b/definitions/grib2/tables/14/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit -11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/14/5.0.table b/definitions/grib2/tables/14/5.0.table index 5ec77ed0f..2795336df 100644 --- a/definitions/grib2/tables/14/5.0.table +++ b/definitions/grib2/tables/14/5.0.table @@ -1,23 +1,23 @@ # Code table 5.0 - Data representation template number -0 0 Grid point data - simple packing -1 1 Matrix value at grid point - simple packing -2 2 Grid point data - complex packing -3 3 Grid point data - complex packing and spatial differencing -4 4 Grid point data - IEEE floating point data -40 40 Grid point data - JPEG 2000 code stream format -41 41 Grid point data - Portable Network Graphics (PNG) -# 42-49 Reserved -50 50 Spectral data - simple packing -51 51 Spherical harmonics data - complex packing -# 52-60 Reserved -61 61 Grid point data - simple packing with logarithm pre-processing -# 62-199 Reserved -200 200 Run length packing with level values -# 201-49151 Reserved -# 49152-65534 Reserved for local use +0 0 Grid point data - simple packing +1 1 Matrix value at grid point - simple packing +2 2 Grid point data - complex packing +3 3 Grid point data - complex packing and spatial differencing +4 4 Grid point data - IEEE floating point data +40 40 Grid point data - JPEG 2000 code stream format +41 41 Grid point data - Portable Network Graphics (PNG) +# 42-49 Reserved +50 50 Spectral data - simple packing +51 51 Spherical harmonics data - complex packing +# 52-60 Reserved +61 61 Grid point data - simple packing with logarithm pre-processing +# 62-199 Reserved +200 200 Run length packing with level values +# 201-49151 Reserved +# 49152-65534 Reserved for local use 40000 40000 JPEG2000 Packing 40010 40010 PNG pacling 50000 50000 Sperical harmonics ieee packing 50001 50001 Second order packing 50002 50002 Second order packing -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/14/5.1.table b/definitions/grib2/tables/14/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/14/5.1.table +++ b/definitions/grib2/tables/14/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/5.2.table b/definitions/grib2/tables/14/5.2.table index 7a4500ecd..d12b46fbd 100644 --- a/definitions/grib2/tables/14/5.2.table +++ b/definitions/grib2/tables/14/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use +# 12-191 Reserved +# 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/14/5.3.table b/definitions/grib2/tables/14/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/14/5.3.table +++ b/definitions/grib2/tables/14/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/5.4.table b/definitions/grib2/tables/14/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/14/5.4.table +++ b/definitions/grib2/tables/14/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/5.40.table b/definitions/grib2/tables/14/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/14/5.40.table +++ b/definitions/grib2/tables/14/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/14/5.5.table b/definitions/grib2/tables/14/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/14/5.5.table +++ b/definitions/grib2/tables/14/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/5.6.table b/definitions/grib2/tables/14/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/14/5.6.table +++ b/definitions/grib2/tables/14/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/14/5.7.table b/definitions/grib2/tables/14/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/14/5.7.table +++ b/definitions/grib2/tables/14/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/14/6.0.table b/definitions/grib2/tables/14/6.0.table index f539b26d7..a8f30f5a4 100644 --- a/definitions/grib2/tables/14/6.0.table +++ b/definitions/grib2/tables/14/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/15/0.0.table b/definitions/grib2/tables/15/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/15/0.0.table +++ b/definitions/grib2/tables/15/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/1.0.table b/definitions/grib2/tables/15/1.0.table index 1d1bde1dc..9c3abfc0a 100644 --- a/definitions/grib2/tables/15/1.0.table +++ b/definitions/grib2/tables/15/1.0.table @@ -1,20 +1,20 @@ # Code table 1.0 - GRIB master tables version number -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 -6 6 Version implemented on 15 September 2010 -7 7 Version implemented on 4 May 2011 -8 8 Version implemented on 2 November 2011 -9 9 Version implemented on 2 May 2012 -10 10 Version implemented on 7 November 2012 -11 11 Version implemented on 8 May 2013 -12 12 Version implemented on 14 November 2013 -13 13 Version implemented on 7 May 2014 -14 14 Version implemented on 5 November 2014 +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Version implemented on 2 May 2012 +10 10 Version implemented on 7 November 2012 +11 11 Version implemented on 8 May 2013 +12 12 Version implemented on 14 November 2013 +13 13 Version implemented on 7 May 2014 +14 14 Version implemented on 5 November 2014 15 15 Version implemented on 6 May 2015 -16 16 Pre-operational to be implemented by next amendment -# 17-254 Future versions -255 255 Missing +16 16 Pre-operational to be implemented by next amendment +# 17-254 Future versions +255 255 Missing diff --git a/definitions/grib2/tables/15/1.1.table b/definitions/grib2/tables/15/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/15/1.1.table +++ b/definitions/grib2/tables/15/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/15/1.2.table b/definitions/grib2/tables/15/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/15/1.2.table +++ b/definitions/grib2/tables/15/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/1.3.table b/definitions/grib2/tables/15/1.3.table index 6f061bf42..e7197fcb2 100644 --- a/definitions/grib2/tables/15/1.3.table +++ b/definitions/grib2/tables/15/1.3.table @@ -1,14 +1,14 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products 4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) 6 6 S2S operational products 7 7 S2S test products 8 8 Uncertainties in ensembles of regional reanalysis project (UERRA) 9 9 Uncertainties in ensembles of regional reanalysis project test (UERRA) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/1.4.table b/definitions/grib2/tables/15/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/15/1.4.table +++ b/definitions/grib2/tables/15/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/15/1.5.table b/definitions/grib2/tables/15/1.5.table index b2cf9f087..533111959 100644 --- a/definitions/grib2/tables/15/1.5.table +++ b/definitions/grib2/tables/15/1.5.table @@ -1,7 +1,7 @@ # Code table 1.5 - Identification template number -0 0 Calendar definition -1 1 Paleontological offset -2 2 Calendar definition and paleontological offset -# 3-32767 Reserved -# 32768-65534 Reserved for local use -65535 65535 Missing +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/15/1.6.table b/definitions/grib2/tables/15/1.6.table index 5db921990..bd46899a7 100644 --- a/definitions/grib2/tables/15/1.6.table +++ b/definitions/grib2/tables/15/1.6.table @@ -1,8 +1,8 @@ # Code table 1.6 - Type of calendar -0 0 Gregorian -1 1 360-day -2 2 365-day -3 3 Proleptic Gregorian -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/3.0.table b/definitions/grib2/tables/15/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/15/3.0.table +++ b/definitions/grib2/tables/15/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/15/3.10.table b/definitions/grib2/tables/15/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/15/3.10.table +++ b/definitions/grib2/tables/15/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/15/3.11.table b/definitions/grib2/tables/15/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/15/3.11.table +++ b/definitions/grib2/tables/15/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/15/3.15.table b/definitions/grib2/tables/15/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/15/3.15.table +++ b/definitions/grib2/tables/15/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/3.2.table b/definitions/grib2/tables/15/3.2.table index 9238dc2a7..b9574a424 100644 --- a/definitions/grib2/tables/15/3.2.table +++ b/definitions/grib2/tables/15/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/3.20.table b/definitions/grib2/tables/15/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/15/3.20.table +++ b/definitions/grib2/tables/15/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/3.21.table b/definitions/grib2/tables/15/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/15/3.21.table +++ b/definitions/grib2/tables/15/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/3.3.table b/definitions/grib2/tables/15/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/15/3.3.table +++ b/definitions/grib2/tables/15/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/15/3.4.table b/definitions/grib2/tables/15/3.4.table index 897b813d7..43835c014 100644 --- a/definitions/grib2/tables/15/3.4.table +++ b/definitions/grib2/tables/15/3.4.table @@ -1,17 +1,17 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -5 0 Points within odd rows are not offset in i (x) direction -5 1 Points within odd rows are offset by Di/2 in i (x) direction -6 0 Points within even rows are not offset in i (x) direction -6 1 Points within even rows are offset by Di/2 in i (x) direction -7 0 Points are not offset in j (y) direction -7 1 Points are offset by Dj/2 in j (y) direction -8 0 Rows have Ni grid points and columns have Nj grid points -8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +5 0 Points within odd rows are not offset in i (x) direction +5 1 Points within odd rows are offset by Di/2 in i (x) direction +6 0 Points within even rows are not offset in i (x) direction +6 1 Points within even rows are offset by Di/2 in i (x) direction +7 0 Points are not offset in j (y) direction +7 1 Points are offset by Dj/2 in j (y) direction +8 0 Rows have Ni grid points and columns have Nj grid points +8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction diff --git a/definitions/grib2/tables/15/3.5.table b/definitions/grib2/tables/15/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/15/3.5.table +++ b/definitions/grib2/tables/15/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/15/3.7.table b/definitions/grib2/tables/15/3.7.table index 0a7d6efde..34c0de085 100644 --- a/definitions/grib2/tables/15/3.7.table +++ b/definitions/grib2/tables/15/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 see separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/15/3.8.table b/definitions/grib2/tables/15/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/15/3.8.table +++ b/definitions/grib2/tables/15/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/3.9.table b/definitions/grib2/tables/15/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/15/3.9.table +++ b/definitions/grib2/tables/15/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/15/4.0.table b/definitions/grib2/tables/15/4.0.table index b4eff0769..b05d7ef13 100644 --- a/definitions/grib2/tables/15/4.0.table +++ b/definitions/grib2/tables/15/4.0.table @@ -1,64 +1,64 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time -8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -# 35-39 Reserved +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +# 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol -46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -# 49-50 Reserved -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time -52 52 Reserved -53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time -54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters -# 55-56 Reserved -57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function -# 58-59 Reserved -60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +# 49-50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +52 52 Reserved +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +# 55-56 Reserved +57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function +# 58-59 Reserved +60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time 61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 62-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +# 62-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/15/4.1.0.table b/definitions/grib2/tables/15/4.1.0.table index 04cfd7802..df58636d6 100644 --- a/definitions/grib2/tables/15/4.1.0.table +++ b/definitions/grib2/tables/15/4.1.0.table @@ -1,27 +1,27 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.1.1.table b/definitions/grib2/tables/15/4.1.1.table index 7b22b6fed..05a854da0 100644 --- a/definitions/grib2/tables/15/4.1.1.table +++ b/definitions/grib2/tables/15/4.1.1.table @@ -1,7 +1,7 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.1.10.table b/definitions/grib2/tables/15/4.1.10.table index a9b20eb9c..88d3c8743 100644 --- a/definitions/grib2/tables/15/4.1.10.table +++ b/definitions/grib2/tables/15/4.1.10.table @@ -1,10 +1,10 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Subsurface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Subsurface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.1.2.table b/definitions/grib2/tables/15/4.1.2.table index 5b488fe9e..e74126645 100644 --- a/definitions/grib2/tables/15/4.1.2.table +++ b/definitions/grib2/tables/15/4.1.2.table @@ -1,9 +1,9 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.1.3.table b/definitions/grib2/tables/15/4.1.3.table index 5096a166e..c1a1e267a 100644 --- a/definitions/grib2/tables/15/4.1.3.table +++ b/definitions/grib2/tables/15/4.1.3.table @@ -1,6 +1,6 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Image format products -1 1 Quantitative products -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.10.table b/definitions/grib2/tables/15/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/15/4.10.table +++ b/definitions/grib2/tables/15/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/15/4.11.table b/definitions/grib2/tables/15/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/15/4.11.table +++ b/definitions/grib2/tables/15/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.12.table b/definitions/grib2/tables/15/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/15/4.12.table +++ b/definitions/grib2/tables/15/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.13.table b/definitions/grib2/tables/15/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/15/4.13.table +++ b/definitions/grib2/tables/15/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.14.table b/definitions/grib2/tables/15/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/15/4.14.table +++ b/definitions/grib2/tables/15/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.15.table b/definitions/grib2/tables/15/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/15/4.15.table +++ b/definitions/grib2/tables/15/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.0.table b/definitions/grib2/tables/15/4.2.0.0.table index 41e5291a9..24d21959d 100644 --- a/definitions/grib2/tables/15/4.2.0.0.table +++ b/definitions/grib2/tables/15/4.2.0.0.table @@ -21,6 +21,6 @@ 19 19 Turbulent transfer coefficient for heat (Numeric) 20 20 Turbulent diffusion coefficient for heat (m2/s) 21 21 Apparent temperature (K) -# 22-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 22-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.1.table b/definitions/grib2/tables/15/4.2.0.1.table index f2fdd3026..69386bbe2 100644 --- a/definitions/grib2/tables/15/4.2.0.1.table +++ b/definitions/grib2/tables/15/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,7 +86,7 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) @@ -105,6 +105,6 @@ 105 105 Number density of snow (m-3) 106 106 Number density of graupel (m-3) 107 107 Number density of hail (m-3) -# 108-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 108-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.13.table b/definitions/grib2/tables/15/4.2.0.13.table index 5086101ad..3f5c30675 100644 --- a/definitions/grib2/tables/15/4.2.0.13.table +++ b/definitions/grib2/tables/15/4.2.0.13.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.14.table b/definitions/grib2/tables/15/4.2.0.14.table index 215884737..97fb38c8b 100644 --- a/definitions/grib2/tables/15/4.2.0.14.table +++ b/definitions/grib2/tables/15/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.15.table b/definitions/grib2/tables/15/4.2.0.15.table index dfbc4d12f..8df082466 100644 --- a/definitions/grib2/tables/15/4.2.0.15.table +++ b/definitions/grib2/tables/15/4.2.0.15.table @@ -16,6 +16,6 @@ 14 14 Reflectivity of hail (dB) 15 15 Hybrid scan reflectivity (dB) 16 16 Hybrid scan reflectivity height (m) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.16.table b/definitions/grib2/tables/15/4.2.0.16.table index 0c240a853..9499d9333 100644 --- a/definitions/grib2/tables/15/4.2.0.16.table +++ b/definitions/grib2/tables/15/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.18.table b/definitions/grib2/tables/15/4.2.0.18.table index 18c41aa48..7e0a736eb 100644 --- a/definitions/grib2/tables/15/4.2.0.18.table +++ b/definitions/grib2/tables/15/4.2.0.18.table @@ -8,11 +8,11 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) 13 13 Total deposition (wet + dry) (Bq m-2) -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.19.table b/definitions/grib2/tables/15/4.2.0.19.table index 75101bd37..d2beef083 100644 --- a/definitions/grib2/tables/15/4.2.0.19.table +++ b/definitions/grib2/tables/15/4.2.0.19.table @@ -27,6 +27,6 @@ 25 25 Weather (Code table 4.225) 26 26 Convective outlook (Code table 4.224) 27 27 Icing scenario (Code table 4.227) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.190.table b/definitions/grib2/tables/15/4.2.0.190.table index de621a924..a0d6ba0ac 100644 --- a/definitions/grib2/tables/15/4.2.0.190.table +++ b/definitions/grib2/tables/15/4.2.0.190.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.191.table b/definitions/grib2/tables/15/4.2.0.191.table index e3bba0ebe..b3a7092ea 100644 --- a/definitions/grib2/tables/15/4.2.0.191.table +++ b/definitions/grib2/tables/15/4.2.0.191.table @@ -3,6 +3,6 @@ 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.2.table b/definitions/grib2/tables/15/4.2.0.2.table index c83b07300..7bd1509f5 100644 --- a/definitions/grib2/tables/15/4.2.0.2.table +++ b/definitions/grib2/tables/15/4.2.0.2.table @@ -38,6 +38,6 @@ 36 36 Amplitude function for Rossby wave envelope for meridional wind (m/s) 37 37 Northward turbulent surface stress (N m-2 s) 38 38 Eastward turbulent surface stress (N m-2 s) -# 39-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 39-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.20.table b/definitions/grib2/tables/15/4.2.0.20.table index 9584f7c7f..df9ccc184 100644 --- a/definitions/grib2/tables/15/4.2.0.20.table +++ b/definitions/grib2/tables/15/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -25,7 +25,7 @@ 57 57 Total yearly average burden of the atmosphere (mol) 58 58 Total yearly averaged atmospheric loss (mol/s) 59 59 Aerosol number concentration (m-3) -# 60-99 Reserved +# 60-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -37,6 +37,6 @@ 108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) 109 109 Aerosol lidar extinction from satellite (/m) 110 110 Aerosol lidar extinction from the ground (/m) -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.3.table b/definitions/grib2/tables/15/4.2.0.3.table index 9a88e0027..e1a68bfc5 100644 --- a/definitions/grib2/tables/15/4.2.0.3.table +++ b/definitions/grib2/tables/15/4.2.0.3.table @@ -26,6 +26,6 @@ 24 24 Anisotropy of sub-gridscale orography (Numeric) 25 25 Natural logarithm of pressure in Pa (Numeric) 26 26 Exner pressure (Numeric) -# 27-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 27-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.4.table b/definitions/grib2/tables/15/4.2.0.4.table index dbfcbddb7..03b5cea38 100644 --- a/definitions/grib2/tables/15/4.2.0.4.table +++ b/definitions/grib2/tables/15/4.2.0.4.table @@ -12,9 +12,9 @@ 10 10 Photosynthetically active radiation (W m-2) 11 11 Net short-wave radiation flux, clear sky (W m-2) 12 12 Downward UV radiation (W m-2) -# 13-49 Reserved +# 13-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) -# 52-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.5.table b/definitions/grib2/tables/15/4.2.0.5.table index 932a12fbd..b9084509a 100644 --- a/definitions/grib2/tables/15/4.2.0.5.table +++ b/definitions/grib2/tables/15/4.2.0.5.table @@ -7,6 +7,6 @@ 5 5 Net long-wave radiation flux (W m-2) 6 6 Net long-wave radiation flux, clear sky (W m-2) 7 7 Brightness temperature (K) -# 8-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.6.table b/definitions/grib2/tables/15/4.2.0.6.table index e28d8e4db..8f1574d46 100644 --- a/definitions/grib2/tables/15/4.2.0.6.table +++ b/definitions/grib2/tables/15/4.2.0.6.table @@ -39,6 +39,6 @@ 37 37 Fraction of convective precipitation cover (Proportion) 38 38 Mass density of cloud droplets (kg m-3) 39 39 Mass density of cloud ice (kg m-3) -# 40-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 40-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.0.7.table b/definitions/grib2/tables/15/4.2.0.7.table index db47d0113..8a2b85fb9 100644 --- a/definitions/grib2/tables/15/4.2.0.7.table +++ b/definitions/grib2/tables/15/4.2.0.7.table @@ -13,8 +13,8 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraft helicity (m2 s-2) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.1.0.table b/definitions/grib2/tables/15/4.2.1.0.table index cf56b08ee..f455c3365 100644 --- a/definitions/grib2/tables/15/4.2.1.0.table +++ b/definitions/grib2/tables/15/4.2.1.0.table @@ -7,6 +7,6 @@ 5 5 Baseflow-groundwater runoff (kg m-2) 6 6 Storm surface runoff (kg m-2) 7 7 Discharge from rivers or streams (m3/s) -# 8-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.1.1.table b/definitions/grib2/tables/15/4.2.1.1.table index b488eb0bd..171da3958 100644 --- a/definitions/grib2/tables/15/4.2.1.1.table +++ b/definitions/grib2/tables/15/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.10.0.table b/definitions/grib2/tables/15/4.2.10.0.table index 095f51bdf..3611abd9a 100644 --- a/definitions/grib2/tables/15/4.2.10.0.table +++ b/definitions/grib2/tables/15/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (/s) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.10.1.table b/definitions/grib2/tables/15/4.2.10.1.table index 5959bfa28..f0a073c00 100644 --- a/definitions/grib2/tables/15/4.2.10.1.table +++ b/definitions/grib2/tables/15/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.10.191.table b/definitions/grib2/tables/15/4.2.10.191.table index 524929e78..1ebf85006 100644 --- a/definitions/grib2/tables/15/4.2.10.191.table +++ b/definitions/grib2/tables/15/4.2.10.191.table @@ -1,8 +1,8 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -2 2 Reserved +2 2 Reserved 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.10.2.table b/definitions/grib2/tables/15/4.2.10.2.table index 6797062ac..4633bad4f 100644 --- a/definitions/grib2/tables/15/4.2.10.2.table +++ b/definitions/grib2/tables/15/4.2.10.2.table @@ -12,6 +12,6 @@ 10 10 Zonal vector component of vertically integrated ice internal pressure (Pa m) 11 11 Meridional vector component of vertically integrated ice internal pressure (Pa m) 12 12 Compressive ice strength (N/m) -# 13-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.10.3.table b/definitions/grib2/tables/15/4.2.10.3.table index f951bbe78..937720c93 100644 --- a/definitions/grib2/tables/15/4.2.10.3.table +++ b/definitions/grib2/tables/15/4.2.10.3.table @@ -1,6 +1,6 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.10.4.table b/definitions/grib2/tables/15/4.2.10.4.table index 54774f1b7..d5615ae26 100644 --- a/definitions/grib2/tables/15/4.2.10.4.table +++ b/definitions/grib2/tables/15/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2/s) 6 6 Ocean vertical momentum diffusivity (m2/s) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (/m) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.2.0.table b/definitions/grib2/tables/15/4.2.2.0.table index 81548840c..b253cac22 100644 --- a/definitions/grib2/tables/15/4.2.2.0.table +++ b/definitions/grib2/tables/15/4.2.2.0.table @@ -38,6 +38,6 @@ 36 36 Tile fraction (Proportion) 37 37 Tile percentage (%) 38 38 Soil volumetric ice content (water equivalent) (m3 m-3) -# 39-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 39-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.2.3.table b/definitions/grib2/tables/15/4.2.2.3.table index 08ac880fe..2b1d0ac38 100644 --- a/definitions/grib2/tables/15/4.2.2.3.table +++ b/definitions/grib2/tables/15/4.2.2.3.table @@ -23,6 +23,6 @@ 21 21 Soil ice (kg m-3) 22 22 Column-integrated soil ice (kg m-2) 23 23 Liquid water in snow pack (kg m-2) -# 24-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.2.4.table b/definitions/grib2/tables/15/4.2.2.4.table index d4ede2f70..c8b877df6 100644 --- a/definitions/grib2/tables/15/4.2.2.4.table +++ b/definitions/grib2/tables/15/4.2.2.4.table @@ -4,6 +4,6 @@ 2 2 Haines Index (Numeric) 3 3 Fire burned area (%) 4 4 Fosberg index (Numeric) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.3.0.table b/definitions/grib2/tables/15/4.2.3.0.table index c0ffa29f5..80a829673 100644 --- a/definitions/grib2/tables/15/4.2.3.0.table +++ b/definitions/grib2/tables/15/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.2.3.1.table b/definitions/grib2/tables/15/4.2.3.1.table index 0bda53063..bc9eaab0d 100644 --- a/definitions/grib2/tables/15/4.2.3.1.table +++ b/definitions/grib2/tables/15/4.2.3.1.table @@ -17,12 +17,12 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +23 23 Angstrom coefficient +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.201.table b/definitions/grib2/tables/15/4.201.table index 47f1b486f..fa173c4e0 100644 --- a/definitions/grib2/tables/15/4.201.table +++ b/definitions/grib2/tables/15/4.201.table @@ -1,15 +1,15 @@ # Code table 4.201 - Precipitation type -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow -6 6 Wet snow -7 7 Mixture of rain and snow -8 8 Ice pellets -9 9 Graupel -10 10 Hail -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +6 6 Wet snow +7 7 Mixture of rain and snow +8 8 Ice pellets +9 9 Graupel +10 10 Hail +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.202.table b/definitions/grib2/tables/15/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/15/4.202.table +++ b/definitions/grib2/tables/15/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.203.table b/definitions/grib2/tables/15/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/15/4.203.table +++ b/definitions/grib2/tables/15/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.204.table b/definitions/grib2/tables/15/4.204.table index 91bcf1814..ffbd89502 100644 --- a/definitions/grib2/tables/15/4.204.table +++ b/definitions/grib2/tables/15/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (16-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (16-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.205.table b/definitions/grib2/tables/15/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/15/4.205.table +++ b/definitions/grib2/tables/15/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.206.table b/definitions/grib2/tables/15/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/15/4.206.table +++ b/definitions/grib2/tables/15/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.207.table b/definitions/grib2/tables/15/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/15/4.207.table +++ b/definitions/grib2/tables/15/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.208.table b/definitions/grib2/tables/15/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/15/4.208.table +++ b/definitions/grib2/tables/15/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.209.table b/definitions/grib2/tables/15/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/15/4.209.table +++ b/definitions/grib2/tables/15/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.210.table b/definitions/grib2/tables/15/4.210.table index 524a6ca73..791878469 100644 --- a/definitions/grib2/tables/15/4.210.table +++ b/definitions/grib2/tables/15/4.210.table @@ -1,6 +1,6 @@ # Code table 4.210 - Contrail intensity -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.211.table b/definitions/grib2/tables/15/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/15/4.211.table +++ b/definitions/grib2/tables/15/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.212.table b/definitions/grib2/tables/15/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/15/4.212.table +++ b/definitions/grib2/tables/15/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.213.table b/definitions/grib2/tables/15/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/15/4.213.table +++ b/definitions/grib2/tables/15/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.215.table b/definitions/grib2/tables/15/4.215.table index 034db72be..7888772d5 100644 --- a/definitions/grib2/tables/15/4.215.table +++ b/definitions/grib2/tables/15/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.216.table b/definitions/grib2/tables/15/4.216.table index 5d1460cef..b51b358f4 100644 --- a/definitions/grib2/tables/15/4.216.table +++ b/definitions/grib2/tables/15/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain -# 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 0-90 Elevation in increments of 100 m +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/15/4.217.table b/definitions/grib2/tables/15/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/15/4.217.table +++ b/definitions/grib2/tables/15/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.218.table b/definitions/grib2/tables/15/4.218.table index bfca92f95..fdaa3ea31 100644 --- a/definitions/grib2/tables/15/4.218.table +++ b/definitions/grib2/tables/15/4.218.table @@ -1,38 +1,38 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation/crops -15 15 Permanent snow/ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -# 19-96 Reserved -97 97 Snow/ice on land -98 98 Snow/ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud/fog/Stratus -102 102 Low cloud/Stratocumulus -103 103 Low cloud/unknown type -104 104 Medium cloud/Nimbostratus -105 105 Medium cloud/Altostratus -106 106 Medium cloud/unknown type -107 107 High cloud/Cumulus -108 108 High cloud/Cirrus -109 109 High cloud/unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation/crops +15 15 Permanent snow/ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +# 19-96 Reserved +97 97 Snow/ice on land +98 98 Snow/ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud/fog/Stratus +102 102 Low cloud/Stratocumulus +103 103 Low cloud/unknown type +104 104 Medium cloud/Nimbostratus +105 105 Medium cloud/Altostratus +106 106 Medium cloud/unknown type +107 107 High cloud/Cumulus +108 108 High cloud/Cirrus +109 109 High cloud/unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.219.table b/definitions/grib2/tables/15/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/15/4.219.table +++ b/definitions/grib2/tables/15/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.220.table b/definitions/grib2/tables/15/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/15/4.220.table +++ b/definitions/grib2/tables/15/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.221.table b/definitions/grib2/tables/15/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/15/4.221.table +++ b/definitions/grib2/tables/15/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.222.table b/definitions/grib2/tables/15/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/15/4.222.table +++ b/definitions/grib2/tables/15/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.223.table b/definitions/grib2/tables/15/4.223.table index f0deb076a..572c4e7a8 100644 --- a/definitions/grib2/tables/15/4.223.table +++ b/definitions/grib2/tables/15/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/15/4.224.table b/definitions/grib2/tables/15/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/15/4.224.table +++ b/definitions/grib2/tables/15/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/15/4.227.table b/definitions/grib2/tables/15/4.227.table index 27c76553d..48c3b7633 100644 --- a/definitions/grib2/tables/15/4.227.table +++ b/definitions/grib2/tables/15/4.227.table @@ -1,9 +1,9 @@ # Code table 4.227 - Icing scenario (weather/cloud classification) -0 0 None -1 1 General -2 2 Convective -3 3 Stratiform -4 4 Freezing -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/15/4.234.table b/definitions/grib2/tables/15/4.234.table index 9844a91d2..d8b3715b3 100644 --- a/definitions/grib2/tables/15/4.234.table +++ b/definitions/grib2/tables/15/4.234.table @@ -1,21 +1,21 @@ # Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Crops, mixed farming -2 2 Short grass -3 3 Evergreen needleleaf trees -4 4 Deciduous needleleaf trees -5 5 Deciduous broadleaf trees -6 6 Evergreen broadleaf trees -7 7 Tall grass -8 8 Desert -9 9 Tundra -10 10 Irrigated crops -11 11 Semidesert -12 12 Ice caps and glaciers -13 13 Bogs and marshes -14 14 Inland water -15 15 Ocean -16 16 Evergreen shrubs -17 17 Deciduous shrubs -18 18 Mixed forest -19 19 Interrupted forest -20 20 Water and land mixtures +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/15/4.236.table b/definitions/grib2/tables/15/4.236.table index 08c7f8d56..b667b65fc 100644 --- a/definitions/grib2/tables/15/4.236.table +++ b/definitions/grib2/tables/15/4.236.table @@ -1,8 +1,8 @@ # Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Coarse -2 2 Medium -3 3 Medium-fine -4 4 Fine -5 5 Very-fine -6 6 Organic -7 7 Tropical-organic +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/15/4.241.table b/definitions/grib2/tables/15/4.241.table index c0bd3e99e..6ce0a5ea7 100644 --- a/definitions/grib2/tables/15/4.241.table +++ b/definitions/grib2/tables/15/4.241.table @@ -1,9 +1,9 @@ # Code table 4.241 - Coverage attributes -0 0 Undefined -1 1 Unmodified -2 2 Snow covered -3 3 Flooded -4 4 Ice covered -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Undefined +1 1 Unmodified +2 2 Snow covered +3 3 Flooded +4 4 Ice covered +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.242.table b/definitions/grib2/tables/15/4.242.table index 083f88c29..f6865957c 100644 --- a/definitions/grib2/tables/15/4.242.table +++ b/definitions/grib2/tables/15/4.242.table @@ -1,7 +1,7 @@ # Code table 4.242 - Tile classification -0 0 Reserved -1 1 Land use classes according to ESA-GlobCover GCV2009 -2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Reserved +1 1 Land use classes according to ESA-GlobCover GCV2009 +2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/15/4.243.table b/definitions/grib2/tables/15/4.243.table index b39053311..24d21b719 100644 --- a/definitions/grib2/tables/15/4.243.table +++ b/definitions/grib2/tables/15/4.243.table @@ -1,43 +1,43 @@ # Code table 4.243 - Tile class -0 0 Reserved -1 1 Evergreen broadleaved forest -2 2 Deciduous broadleaved closed forest -3 3 Deciduous broadleaved open forest -4 4 Evergreen needle-leaf forest -5 5 Deciduous needle-leaf forest -6 6 Mixed leaf trees -7 7 Freshwater flooded trees -8 8 Saline water flooded trees -9 9 Mosaic tree/natural vegetation -10 10 Burnt tree cover -11 11 Evergreen shrubs closed-open -12 12 Deciduous shrubs closed-open -13 13 Herbaceous vegetation closed-open -14 14 Sparse herbaceous or grass -15 15 Flooded shrubs or herbaceous -16 16 Cultivated and managed areas -17 17 Mosaic crop/tree/natural vegetation -18 18 Mosaic crop/shrub/grass -19 19 Bare areas -20 20 Water -21 21 Snow and ice -22 22 Artificial surface -23 23 Ocean -24 24 Irrigated croplands -25 25 Rainfed croplands -26 26 Mosaic cropland (50-70%) - vegetation (20-50%) -27 27 Mosaic vegetation (50-70%) - cropland (20-50%) -28 28 Closed broadleaved evergreen forest -29 29 Closed needle-leaved evergreen forest -30 30 Open needle-leaved deciduous forest -31 31 Mixed broadleaved and needle-leaved forest -32 32 Mosaic shrubland (50-70%) - grassland (20-50%) -33 33 Mosaic grassland (50-70%) - shrubland (20-50%) -34 34 Closed to open shrubland -35 35 Sparse vegetation -36 36 Closed to open forest regularly flooded -37 37 Closed forest or shrubland permanently flooded -38 38 Closed to open grassland regularly flooded -39 39 Undefined -# 40-32767 Reserved -# 32768- Reserved for local use +0 0 Reserved +1 1 Evergreen broadleaved forest +2 2 Deciduous broadleaved closed forest +3 3 Deciduous broadleaved open forest +4 4 Evergreen needle-leaf forest +5 5 Deciduous needle-leaf forest +6 6 Mixed leaf trees +7 7 Freshwater flooded trees +8 8 Saline water flooded trees +9 9 Mosaic tree/natural vegetation +10 10 Burnt tree cover +11 11 Evergreen shrubs closed-open +12 12 Deciduous shrubs closed-open +13 13 Herbaceous vegetation closed-open +14 14 Sparse herbaceous or grass +15 15 Flooded shrubs or herbaceous +16 16 Cultivated and managed areas +17 17 Mosaic crop/tree/natural vegetation +18 18 Mosaic crop/shrub/grass +19 19 Bare areas +20 20 Water +21 21 Snow and ice +22 22 Artificial surface +23 23 Ocean +24 24 Irrigated croplands +25 25 Rainfed croplands +26 26 Mosaic cropland (50-70%) - vegetation (20-50%) +27 27 Mosaic vegetation (50-70%) - cropland (20-50%) +28 28 Closed broadleaved evergreen forest +29 29 Closed needle-leaved evergreen forest +30 30 Open needle-leaved deciduous forest +31 31 Mixed broadleaved and needle-leaved forest +32 32 Mosaic shrubland (50-70%) - grassland (20-50%) +33 33 Mosaic grassland (50-70%) - shrubland (20-50%) +34 34 Closed to open shrubland +35 35 Sparse vegetation +36 36 Closed to open forest regularly flooded +37 37 Closed forest or shrubland permanently flooded +38 38 Closed to open grassland regularly flooded +39 39 Undefined +# 40-32767 Reserved +# 32768- Reserved for local use diff --git a/definitions/grib2/tables/15/4.3.table b/definitions/grib2/tables/15/4.3.table index f423af2bf..46e498c5f 100644 --- a/definitions/grib2/tables/15/4.3.table +++ b/definitions/grib2/tables/15/4.3.table @@ -1,20 +1,20 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -12 12 Post-processed analysis -13 13 Post-processed forecast -14 14 Nowcast -15 15 Hindcast -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +12 12 Post-processed analysis +13 13 Post-processed forecast +14 14 Nowcast +15 15 Hindcast +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.4.table b/definitions/grib2/tables/15/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/15/4.4.table +++ b/definitions/grib2/tables/15/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.5.table b/definitions/grib2/tables/15/4.5.table index f73733e88..d1a76825a 100644 --- a/definitions/grib2/tables/15/4.5.table +++ b/definitions/grib2/tables/15/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface 2 2 Cloud base level 3 3 Level of cloud tops @@ -12,11 +12,11 @@ 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,18 +25,18 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level -112 112 Reserved -113 113 Logarithmic hybrid level +112 112 Reserved +113 113 Logarithmic hybrid level 114 114 Snow level (Numeric) -# 115-116 Reserved +# 115-116 Reserved 117 117 Mixed layer depth (m) 118 hhl Hybrid height level 119 hpl Hybrid pressure level -# 120-149 Reserved -150 150 Generalized vertical height coordinate -# 151-159 Reserved +# 120-149 Reserved +150 150 Generalized vertical height coordinate +# 151-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom @@ -47,17 +47,17 @@ 167 167 Bottom of root zone # 168-173 Reserved # 168-169 Reserved -174 sfc Top surface of ice on sea, lake or river -175 175 Top surface of ice, under snow cover, on sea, lake or river -176 176 Bottom surface (underside) ice on sea, lake or river -177 sfc Deep soil (of indefinite depth) -178 178 Reserved -179 179 Top surface of glacier ice and inland ice -180 180 Deep inland or glacier ice (of indefinite depth) -181 181 Grid tile land fraction as a model surface -182 182 Grid tile water fraction as a model surface -183 183 Grid tile ice fraction on sea, lake or river as a model surface -184 184 Grid tile glacier ice and inland ice fraction as a model surface -# 185-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +174 sfc Top surface of ice on sea, lake or river +175 175 Top surface of ice, under snow cover, on sea, lake or river +176 176 Bottom surface (underside) ice on sea, lake or river +177 sfc Deep soil (of indefinite depth) +178 178 Reserved +179 179 Top surface of glacier ice and inland ice +180 180 Deep inland or glacier ice (of indefinite depth) +181 181 Grid tile land fraction as a model surface +182 182 Grid tile water fraction as a model surface +183 183 Grid tile ice fraction on sea, lake or river as a model surface +184 184 Grid tile glacier ice and inland ice fraction as a model surface +# 185-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.6.table b/definitions/grib2/tables/15/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/15/4.6.table +++ b/definitions/grib2/tables/15/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.7.table b/definitions/grib2/tables/15/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/15/4.7.table +++ b/definitions/grib2/tables/15/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.8.table b/definitions/grib2/tables/15/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/15/4.8.table +++ b/definitions/grib2/tables/15/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.9.table b/definitions/grib2/tables/15/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/15/4.9.table +++ b/definitions/grib2/tables/15/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/4.91.table b/definitions/grib2/tables/15/4.91.table index 44cf25f44..ae31ed61c 100644 --- a/definitions/grib2/tables/15/4.91.table +++ b/definitions/grib2/tables/15/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit -11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/15/5.0.table b/definitions/grib2/tables/15/5.0.table index 5ec77ed0f..2795336df 100644 --- a/definitions/grib2/tables/15/5.0.table +++ b/definitions/grib2/tables/15/5.0.table @@ -1,23 +1,23 @@ # Code table 5.0 - Data representation template number -0 0 Grid point data - simple packing -1 1 Matrix value at grid point - simple packing -2 2 Grid point data - complex packing -3 3 Grid point data - complex packing and spatial differencing -4 4 Grid point data - IEEE floating point data -40 40 Grid point data - JPEG 2000 code stream format -41 41 Grid point data - Portable Network Graphics (PNG) -# 42-49 Reserved -50 50 Spectral data - simple packing -51 51 Spherical harmonics data - complex packing -# 52-60 Reserved -61 61 Grid point data - simple packing with logarithm pre-processing -# 62-199 Reserved -200 200 Run length packing with level values -# 201-49151 Reserved -# 49152-65534 Reserved for local use +0 0 Grid point data - simple packing +1 1 Matrix value at grid point - simple packing +2 2 Grid point data - complex packing +3 3 Grid point data - complex packing and spatial differencing +4 4 Grid point data - IEEE floating point data +40 40 Grid point data - JPEG 2000 code stream format +41 41 Grid point data - Portable Network Graphics (PNG) +# 42-49 Reserved +50 50 Spectral data - simple packing +51 51 Spherical harmonics data - complex packing +# 52-60 Reserved +61 61 Grid point data - simple packing with logarithm pre-processing +# 62-199 Reserved +200 200 Run length packing with level values +# 201-49151 Reserved +# 49152-65534 Reserved for local use 40000 40000 JPEG2000 Packing 40010 40010 PNG pacling 50000 50000 Sperical harmonics ieee packing 50001 50001 Second order packing 50002 50002 Second order packing -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/15/5.1.table b/definitions/grib2/tables/15/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/15/5.1.table +++ b/definitions/grib2/tables/15/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/5.2.table b/definitions/grib2/tables/15/5.2.table index 7a4500ecd..d12b46fbd 100644 --- a/definitions/grib2/tables/15/5.2.table +++ b/definitions/grib2/tables/15/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use +# 12-191 Reserved +# 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/15/5.3.table b/definitions/grib2/tables/15/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/15/5.3.table +++ b/definitions/grib2/tables/15/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/5.4.table b/definitions/grib2/tables/15/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/15/5.4.table +++ b/definitions/grib2/tables/15/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/5.40.table b/definitions/grib2/tables/15/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/15/5.40.table +++ b/definitions/grib2/tables/15/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/15/5.5.table b/definitions/grib2/tables/15/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/15/5.5.table +++ b/definitions/grib2/tables/15/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/5.6.table b/definitions/grib2/tables/15/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/15/5.6.table +++ b/definitions/grib2/tables/15/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/15/5.7.table b/definitions/grib2/tables/15/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/15/5.7.table +++ b/definitions/grib2/tables/15/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/15/6.0.table b/definitions/grib2/tables/15/6.0.table index f539b26d7..a8f30f5a4 100644 --- a/definitions/grib2/tables/15/6.0.table +++ b/definitions/grib2/tables/15/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/16/0.0.table b/definitions/grib2/tables/16/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/16/0.0.table +++ b/definitions/grib2/tables/16/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/1.1.table b/definitions/grib2/tables/16/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/16/1.1.table +++ b/definitions/grib2/tables/16/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/16/1.2.table b/definitions/grib2/tables/16/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/16/1.2.table +++ b/definitions/grib2/tables/16/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/1.3.table b/definitions/grib2/tables/16/1.3.table index 6f061bf42..e7197fcb2 100644 --- a/definitions/grib2/tables/16/1.3.table +++ b/definitions/grib2/tables/16/1.3.table @@ -1,14 +1,14 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products 4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) 6 6 S2S operational products 7 7 S2S test products 8 8 Uncertainties in ensembles of regional reanalysis project (UERRA) 9 9 Uncertainties in ensembles of regional reanalysis project test (UERRA) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/1.4.table b/definitions/grib2/tables/16/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/16/1.4.table +++ b/definitions/grib2/tables/16/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/16/1.5.table b/definitions/grib2/tables/16/1.5.table index b2cf9f087..533111959 100644 --- a/definitions/grib2/tables/16/1.5.table +++ b/definitions/grib2/tables/16/1.5.table @@ -1,7 +1,7 @@ # Code table 1.5 - Identification template number -0 0 Calendar definition -1 1 Paleontological offset -2 2 Calendar definition and paleontological offset -# 3-32767 Reserved -# 32768-65534 Reserved for local use -65535 65535 Missing +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/16/1.6.table b/definitions/grib2/tables/16/1.6.table index 5db921990..bd46899a7 100644 --- a/definitions/grib2/tables/16/1.6.table +++ b/definitions/grib2/tables/16/1.6.table @@ -1,8 +1,8 @@ # Code table 1.6 - Type of calendar -0 0 Gregorian -1 1 360-day -2 2 365-day -3 3 Proleptic Gregorian -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/3.0.table b/definitions/grib2/tables/16/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/16/3.0.table +++ b/definitions/grib2/tables/16/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/16/3.10.table b/definitions/grib2/tables/16/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/16/3.10.table +++ b/definitions/grib2/tables/16/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/16/3.11.table b/definitions/grib2/tables/16/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/16/3.11.table +++ b/definitions/grib2/tables/16/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/16/3.15.table b/definitions/grib2/tables/16/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/16/3.15.table +++ b/definitions/grib2/tables/16/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/3.2.table b/definitions/grib2/tables/16/3.2.table index 9238dc2a7..b9574a424 100644 --- a/definitions/grib2/tables/16/3.2.table +++ b/definitions/grib2/tables/16/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/3.20.table b/definitions/grib2/tables/16/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/16/3.20.table +++ b/definitions/grib2/tables/16/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/3.21.table b/definitions/grib2/tables/16/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/16/3.21.table +++ b/definitions/grib2/tables/16/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/3.3.table b/definitions/grib2/tables/16/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/16/3.3.table +++ b/definitions/grib2/tables/16/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/16/3.4.table b/definitions/grib2/tables/16/3.4.table index 897b813d7..43835c014 100644 --- a/definitions/grib2/tables/16/3.4.table +++ b/definitions/grib2/tables/16/3.4.table @@ -1,17 +1,17 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -5 0 Points within odd rows are not offset in i (x) direction -5 1 Points within odd rows are offset by Di/2 in i (x) direction -6 0 Points within even rows are not offset in i (x) direction -6 1 Points within even rows are offset by Di/2 in i (x) direction -7 0 Points are not offset in j (y) direction -7 1 Points are offset by Dj/2 in j (y) direction -8 0 Rows have Ni grid points and columns have Nj grid points -8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +5 0 Points within odd rows are not offset in i (x) direction +5 1 Points within odd rows are offset by Di/2 in i (x) direction +6 0 Points within even rows are not offset in i (x) direction +6 1 Points within even rows are offset by Di/2 in i (x) direction +7 0 Points are not offset in j (y) direction +7 1 Points are offset by Dj/2 in j (y) direction +8 0 Rows have Ni grid points and columns have Nj grid points +8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction diff --git a/definitions/grib2/tables/16/3.5.table b/definitions/grib2/tables/16/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/16/3.5.table +++ b/definitions/grib2/tables/16/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/16/3.7.table b/definitions/grib2/tables/16/3.7.table index 0a7d6efde..34c0de085 100644 --- a/definitions/grib2/tables/16/3.7.table +++ b/definitions/grib2/tables/16/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 see separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/16/3.8.table b/definitions/grib2/tables/16/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/16/3.8.table +++ b/definitions/grib2/tables/16/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/3.9.table b/definitions/grib2/tables/16/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/16/3.9.table +++ b/definitions/grib2/tables/16/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/16/4.0.table b/definitions/grib2/tables/16/4.0.table index 05bf24330..eef83c7c3 100644 --- a/definitions/grib2/tables/16/4.0.table +++ b/definitions/grib2/tables/16/4.0.table @@ -1,65 +1,65 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time -8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -# 35-39 Reserved +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +# 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol -46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -# 49-50 Reserved -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time -52 52 Reserved -53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time -54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters -55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time -56 56 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters -57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function -# 58-59 Reserved -60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval -# 62-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +# 49-50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +52 52 Reserved +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time +56 56 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters +57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function +# 58-59 Reserved +60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval +# 62-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/16/4.1.0.table b/definitions/grib2/tables/16/4.1.0.table index 04cfd7802..df58636d6 100644 --- a/definitions/grib2/tables/16/4.1.0.table +++ b/definitions/grib2/tables/16/4.1.0.table @@ -1,27 +1,27 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.1.1.table b/definitions/grib2/tables/16/4.1.1.table index 7b22b6fed..05a854da0 100644 --- a/definitions/grib2/tables/16/4.1.1.table +++ b/definitions/grib2/tables/16/4.1.1.table @@ -1,7 +1,7 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.1.10.table b/definitions/grib2/tables/16/4.1.10.table index a9b20eb9c..88d3c8743 100644 --- a/definitions/grib2/tables/16/4.1.10.table +++ b/definitions/grib2/tables/16/4.1.10.table @@ -1,10 +1,10 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Subsurface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Subsurface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.1.2.table b/definitions/grib2/tables/16/4.1.2.table index 5b488fe9e..e74126645 100644 --- a/definitions/grib2/tables/16/4.1.2.table +++ b/definitions/grib2/tables/16/4.1.2.table @@ -1,9 +1,9 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.1.3.table b/definitions/grib2/tables/16/4.1.3.table index d2baa1362..210b39fd5 100644 --- a/definitions/grib2/tables/16/4.1.3.table +++ b/definitions/grib2/tables/16/4.1.3.table @@ -1,11 +1,11 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Image format products -1 1 Quantitative products -2 2 Cloud properties -3 3 Flight rules conditions -4 4 Volcanic ash -5 5 Sea surface temperature -6 6 Solar radiation -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +2 2 Cloud properties +3 3 Flight rules conditions +4 4 Volcanic ash +5 5 Sea surface temperature +6 6 Solar radiation +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.10.table b/definitions/grib2/tables/16/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/16/4.10.table +++ b/definitions/grib2/tables/16/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/16/4.11.table b/definitions/grib2/tables/16/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/16/4.11.table +++ b/definitions/grib2/tables/16/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.12.table b/definitions/grib2/tables/16/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/16/4.12.table +++ b/definitions/grib2/tables/16/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.13.table b/definitions/grib2/tables/16/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/16/4.13.table +++ b/definitions/grib2/tables/16/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.14.table b/definitions/grib2/tables/16/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/16/4.14.table +++ b/definitions/grib2/tables/16/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.15.table b/definitions/grib2/tables/16/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/16/4.15.table +++ b/definitions/grib2/tables/16/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.0.table b/definitions/grib2/tables/16/4.2.0.0.table index cfadd2d07..3a285255f 100644 --- a/definitions/grib2/tables/16/4.2.0.0.table +++ b/definitions/grib2/tables/16/4.2.0.0.table @@ -27,6 +27,6 @@ 25 25 Temperature tendency due to long-wave radiation, clear sky (K s-1) 26 26 Temperature tendency due to parameterizations (K s-1) 27 27 Wet bulb temperature (K) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.1.table b/definitions/grib2/tables/16/4.2.0.1.table index 775cfe54f..1ecbf240a 100644 --- a/definitions/grib2/tables/16/4.2.0.1.table +++ b/definitions/grib2/tables/16/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,7 +86,7 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) @@ -106,6 +106,6 @@ 106 106 Number density of graupel (m-3) 107 107 Number density of hail (m-3) 108 108 Specific humidity tendency due to parameterizations (kg kg-1 s-1) -# 109-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 109-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.13.table b/definitions/grib2/tables/16/4.2.0.13.table index 5086101ad..3f5c30675 100644 --- a/definitions/grib2/tables/16/4.2.0.13.table +++ b/definitions/grib2/tables/16/4.2.0.13.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.14.table b/definitions/grib2/tables/16/4.2.0.14.table index 215884737..97fb38c8b 100644 --- a/definitions/grib2/tables/16/4.2.0.14.table +++ b/definitions/grib2/tables/16/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.15.table b/definitions/grib2/tables/16/4.2.0.15.table index dfbc4d12f..8df082466 100644 --- a/definitions/grib2/tables/16/4.2.0.15.table +++ b/definitions/grib2/tables/16/4.2.0.15.table @@ -16,6 +16,6 @@ 14 14 Reflectivity of hail (dB) 15 15 Hybrid scan reflectivity (dB) 16 16 Hybrid scan reflectivity height (m) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.16.table b/definitions/grib2/tables/16/4.2.0.16.table index 0c240a853..9499d9333 100644 --- a/definitions/grib2/tables/16/4.2.0.16.table +++ b/definitions/grib2/tables/16/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.18.table b/definitions/grib2/tables/16/4.2.0.18.table index 18c41aa48..7e0a736eb 100644 --- a/definitions/grib2/tables/16/4.2.0.18.table +++ b/definitions/grib2/tables/16/4.2.0.18.table @@ -8,11 +8,11 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) 13 13 Total deposition (wet + dry) (Bq m-2) -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.19.table b/definitions/grib2/tables/16/4.2.0.19.table index ec2b9823d..e51b670a0 100644 --- a/definitions/grib2/tables/16/4.2.0.19.table +++ b/definitions/grib2/tables/16/4.2.0.19.table @@ -28,6 +28,6 @@ 26 26 Convective outlook (Code table 4.224) 27 27 Icing scenario (Code table 4.227) 28 28 Mountain wave turbulence (eddy dissipation rate) (m2/3 s-1) -# 29-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 29-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.190.table b/definitions/grib2/tables/16/4.2.0.190.table index de621a924..a0d6ba0ac 100644 --- a/definitions/grib2/tables/16/4.2.0.190.table +++ b/definitions/grib2/tables/16/4.2.0.190.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.191.table b/definitions/grib2/tables/16/4.2.0.191.table index e3bba0ebe..b3a7092ea 100644 --- a/definitions/grib2/tables/16/4.2.0.191.table +++ b/definitions/grib2/tables/16/4.2.0.191.table @@ -3,6 +3,6 @@ 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.2.table b/definitions/grib2/tables/16/4.2.0.2.table index 46b0774aa..906cf6205 100644 --- a/definitions/grib2/tables/16/4.2.0.2.table +++ b/definitions/grib2/tables/16/4.2.0.2.table @@ -44,6 +44,6 @@ 42 42 v-component of geostrophic wind (m s-1) 43 43 Geostrophic wind direction (degree true) 44 44 Geostrophic wind speed (m s-1) -# 45-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 45-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.20.table b/definitions/grib2/tables/16/4.2.0.20.table index 9584f7c7f..df9ccc184 100644 --- a/definitions/grib2/tables/16/4.2.0.20.table +++ b/definitions/grib2/tables/16/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -25,7 +25,7 @@ 57 57 Total yearly average burden of the atmosphere (mol) 58 58 Total yearly averaged atmospheric loss (mol/s) 59 59 Aerosol number concentration (m-3) -# 60-99 Reserved +# 60-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -37,6 +37,6 @@ 108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) 109 109 Aerosol lidar extinction from satellite (/m) 110 110 Aerosol lidar extinction from the ground (/m) -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.3.table b/definitions/grib2/tables/16/4.2.0.3.table index c7c6359d4..17e7f204f 100644 --- a/definitions/grib2/tables/16/4.2.0.3.table +++ b/definitions/grib2/tables/16/4.2.0.3.table @@ -30,6 +30,6 @@ 28 28 Downdraught mass flux (kg m-2 s-1) 29 29 Updraught detrainment rate (kg m-3 s-1) 30 30 Downdraught detrainment rate (kg m-3 s-1) -# 31-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 31-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.4.table b/definitions/grib2/tables/16/4.2.0.4.table index bd37ea3f5..da327a450 100644 --- a/definitions/grib2/tables/16/4.2.0.4.table +++ b/definitions/grib2/tables/16/4.2.0.4.table @@ -14,9 +14,9 @@ 12 12 Downward UV radiation (W m-2) 13 13 Direct short wave radiation flux (W m-2) 14 14 Diffuse short wave radiation flux (W m-2) -# 15-49 Reserved +# 15-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) -# 52-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.5.table b/definitions/grib2/tables/16/4.2.0.5.table index 932a12fbd..b9084509a 100644 --- a/definitions/grib2/tables/16/4.2.0.5.table +++ b/definitions/grib2/tables/16/4.2.0.5.table @@ -7,6 +7,6 @@ 5 5 Net long-wave radiation flux (W m-2) 6 6 Net long-wave radiation flux, clear sky (W m-2) 7 7 Brightness temperature (K) -# 8-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.6.table b/definitions/grib2/tables/16/4.2.0.6.table index 4cec0c8aa..0450ec194 100644 --- a/definitions/grib2/tables/16/4.2.0.6.table +++ b/definitions/grib2/tables/16/4.2.0.6.table @@ -40,10 +40,10 @@ 38 38 Mass density of cloud droplets (kg m-3) 39 39 Mass density of cloud ice (kg m-3) 40 40 Mass density of convective cloud water droplets (kg m-3) -# 41-46 Reserved +# 41-46 Reserved 47 47 Volume fraction of cloud water droplets (Numeric) 48 48 Volume fraction of cloud ice particles (Numeric) 49 49 Volume fraction of cloud (ice and/or water) (Numeric) -# 50-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 50-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.0.7.table b/definitions/grib2/tables/16/4.2.0.7.table index 23a1a82da..2bf21255d 100644 --- a/definitions/grib2/tables/16/4.2.0.7.table +++ b/definitions/grib2/tables/16/4.2.0.7.table @@ -13,11 +13,11 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraft helicity (m2 s-2) 16 16 Bulk Richardson number (Numeric) 17 17 Gradient Richardson number (Numeric) 18 18 Flux Richardson number (Numeric) -# 19-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 19-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.1.0.table b/definitions/grib2/tables/16/4.2.1.0.table index 74c95f57b..e6f23655a 100644 --- a/definitions/grib2/tables/16/4.2.1.0.table +++ b/definitions/grib2/tables/16/4.2.1.0.table @@ -15,6 +15,6 @@ 13 13 Depth of water on soil surface (kg m-2) 14 14 Upstream accumulated precipitation (kg m-2) 15 15 Upstream accumulated snow melt (kg m-2) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.1.1.table b/definitions/grib2/tables/16/4.2.1.1.table index b488eb0bd..171da3958 100644 --- a/definitions/grib2/tables/16/4.2.1.1.table +++ b/definitions/grib2/tables/16/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.10.0.table b/definitions/grib2/tables/16/4.2.10.0.table index 095f51bdf..3611abd9a 100644 --- a/definitions/grib2/tables/16/4.2.10.0.table +++ b/definitions/grib2/tables/16/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (/s) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.10.1.table b/definitions/grib2/tables/16/4.2.10.1.table index 5959bfa28..f0a073c00 100644 --- a/definitions/grib2/tables/16/4.2.10.1.table +++ b/definitions/grib2/tables/16/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.10.191.table b/definitions/grib2/tables/16/4.2.10.191.table index 524929e78..1ebf85006 100644 --- a/definitions/grib2/tables/16/4.2.10.191.table +++ b/definitions/grib2/tables/16/4.2.10.191.table @@ -1,8 +1,8 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -2 2 Reserved +2 2 Reserved 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.10.2.table b/definitions/grib2/tables/16/4.2.10.2.table index 6797062ac..4633bad4f 100644 --- a/definitions/grib2/tables/16/4.2.10.2.table +++ b/definitions/grib2/tables/16/4.2.10.2.table @@ -12,6 +12,6 @@ 10 10 Zonal vector component of vertically integrated ice internal pressure (Pa m) 11 11 Meridional vector component of vertically integrated ice internal pressure (Pa m) 12 12 Compressive ice strength (N/m) -# 13-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.10.3.table b/definitions/grib2/tables/16/4.2.10.3.table index f951bbe78..937720c93 100644 --- a/definitions/grib2/tables/16/4.2.10.3.table +++ b/definitions/grib2/tables/16/4.2.10.3.table @@ -1,6 +1,6 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.10.4.table b/definitions/grib2/tables/16/4.2.10.4.table index 54774f1b7..d5615ae26 100644 --- a/definitions/grib2/tables/16/4.2.10.4.table +++ b/definitions/grib2/tables/16/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2/s) 6 6 Ocean vertical momentum diffusivity (m2/s) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (/m) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.2.0.table b/definitions/grib2/tables/16/4.2.2.0.table index 81548840c..b253cac22 100644 --- a/definitions/grib2/tables/16/4.2.2.0.table +++ b/definitions/grib2/tables/16/4.2.2.0.table @@ -38,6 +38,6 @@ 36 36 Tile fraction (Proportion) 37 37 Tile percentage (%) 38 38 Soil volumetric ice content (water equivalent) (m3 m-3) -# 39-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 39-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.2.3.table b/definitions/grib2/tables/16/4.2.2.3.table index dff2f7953..6cb8eb7af 100644 --- a/definitions/grib2/tables/16/4.2.2.3.table +++ b/definitions/grib2/tables/16/4.2.2.3.table @@ -25,6 +25,6 @@ 23 23 Liquid water in snow pack (kg m-2) 24 24 Frost index (K day-1) 25 25 Snow depth at elevation bands (kg m-2) -# 26-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 26-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.2.4.table b/definitions/grib2/tables/16/4.2.2.4.table index b9383fe10..cb3db6f78 100644 --- a/definitions/grib2/tables/16/4.2.2.4.table +++ b/definitions/grib2/tables/16/4.2.2.4.table @@ -11,6 +11,6 @@ 9 9 Initial fire spread index (Canadian forest service) (Numeric) 10 10 Fire build up index (Canadian forest service) (Numeric) 11 11 Fire daily severity rating (Canadian forest service) (Numeric) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.3.0.table b/definitions/grib2/tables/16/4.2.3.0.table index c0ffa29f5..80a829673 100644 --- a/definitions/grib2/tables/16/4.2.3.0.table +++ b/definitions/grib2/tables/16/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.2.3.1.table b/definitions/grib2/tables/16/4.2.3.1.table index 75911ee32..04cdde1f1 100644 --- a/definitions/grib2/tables/16/4.2.3.1.table +++ b/definitions/grib2/tables/16/4.2.3.1.table @@ -17,16 +17,16 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) -20 20 Aerosol optical thickness at 0.635 um -21 21 Aerosol optical thickness at 0.810 um -22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-26 Reserved +20 20 Aerosol optical thickness at 0.635 um +21 21 Aerosol optical thickness at 0.810 um +22 22 Aerosol optical thickness at 1.640 um +23 23 Angstrom coefficient +# 24-26 Reserved 27 27 Bidirectional reflectance factor (Numeric) 28 28 Brightness temperature (K) 29 29 Scaled radiance (Numeric) -# 30-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 30-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.201.table b/definitions/grib2/tables/16/4.201.table index 47f1b486f..fa173c4e0 100644 --- a/definitions/grib2/tables/16/4.201.table +++ b/definitions/grib2/tables/16/4.201.table @@ -1,15 +1,15 @@ # Code table 4.201 - Precipitation type -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow -6 6 Wet snow -7 7 Mixture of rain and snow -8 8 Ice pellets -9 9 Graupel -10 10 Hail -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +6 6 Wet snow +7 7 Mixture of rain and snow +8 8 Ice pellets +9 9 Graupel +10 10 Hail +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.202.table b/definitions/grib2/tables/16/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/16/4.202.table +++ b/definitions/grib2/tables/16/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.203.table b/definitions/grib2/tables/16/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/16/4.203.table +++ b/definitions/grib2/tables/16/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.204.table b/definitions/grib2/tables/16/4.204.table index 91bcf1814..ffbd89502 100644 --- a/definitions/grib2/tables/16/4.204.table +++ b/definitions/grib2/tables/16/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (16-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (16-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.205.table b/definitions/grib2/tables/16/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/16/4.205.table +++ b/definitions/grib2/tables/16/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.206.table b/definitions/grib2/tables/16/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/16/4.206.table +++ b/definitions/grib2/tables/16/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.207.table b/definitions/grib2/tables/16/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/16/4.207.table +++ b/definitions/grib2/tables/16/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.208.table b/definitions/grib2/tables/16/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/16/4.208.table +++ b/definitions/grib2/tables/16/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.209.table b/definitions/grib2/tables/16/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/16/4.209.table +++ b/definitions/grib2/tables/16/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.210.table b/definitions/grib2/tables/16/4.210.table index 524a6ca73..791878469 100644 --- a/definitions/grib2/tables/16/4.210.table +++ b/definitions/grib2/tables/16/4.210.table @@ -1,6 +1,6 @@ # Code table 4.210 - Contrail intensity -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.211.table b/definitions/grib2/tables/16/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/16/4.211.table +++ b/definitions/grib2/tables/16/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.212.table b/definitions/grib2/tables/16/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/16/4.212.table +++ b/definitions/grib2/tables/16/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.213.table b/definitions/grib2/tables/16/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/16/4.213.table +++ b/definitions/grib2/tables/16/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.215.table b/definitions/grib2/tables/16/4.215.table index 034db72be..7888772d5 100644 --- a/definitions/grib2/tables/16/4.215.table +++ b/definitions/grib2/tables/16/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.216.table b/definitions/grib2/tables/16/4.216.table index 5d1460cef..b51b358f4 100644 --- a/definitions/grib2/tables/16/4.216.table +++ b/definitions/grib2/tables/16/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain -# 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 0-90 Elevation in increments of 100 m +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/16/4.217.table b/definitions/grib2/tables/16/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/16/4.217.table +++ b/definitions/grib2/tables/16/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.218.table b/definitions/grib2/tables/16/4.218.table index c585bed96..0ad5f49ee 100644 --- a/definitions/grib2/tables/16/4.218.table +++ b/definitions/grib2/tables/16/4.218.table @@ -1,44 +1,44 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation/crops -15 15 Permanent snow/ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -19 19 Warm liquid water cloud -20 20 Supercooled liquid water cloud -21 21 Mixed phase cloud -22 22 Optically thin ice cloud -23 23 Optically thick ice cloud -24 24 Multi-layered cloud -# 25-96 Reserved -97 97 Snow/ice on land -98 98 Snow/ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud/fog/Stratus -102 102 Low cloud/Stratocumulus -103 103 Low cloud/unknown type -104 104 Medium cloud/Nimbostratus -105 105 Medium cloud/Altostratus -106 106 Medium cloud/unknown type -107 107 High cloud/Cumulus -108 108 High cloud/Cirrus -109 109 High cloud/unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation/crops +15 15 Permanent snow/ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +19 19 Warm liquid water cloud +20 20 Supercooled liquid water cloud +21 21 Mixed phase cloud +22 22 Optically thin ice cloud +23 23 Optically thick ice cloud +24 24 Multi-layered cloud +# 25-96 Reserved +97 97 Snow/ice on land +98 98 Snow/ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud/fog/Stratus +102 102 Low cloud/Stratocumulus +103 103 Low cloud/unknown type +104 104 Medium cloud/Nimbostratus +105 105 Medium cloud/Altostratus +106 106 Medium cloud/unknown type +107 107 High cloud/Cumulus +108 108 High cloud/Cirrus +109 109 High cloud/unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.219.table b/definitions/grib2/tables/16/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/16/4.219.table +++ b/definitions/grib2/tables/16/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.220.table b/definitions/grib2/tables/16/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/16/4.220.table +++ b/definitions/grib2/tables/16/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.221.table b/definitions/grib2/tables/16/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/16/4.221.table +++ b/definitions/grib2/tables/16/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.222.table b/definitions/grib2/tables/16/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/16/4.222.table +++ b/definitions/grib2/tables/16/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.223.table b/definitions/grib2/tables/16/4.223.table index f0deb076a..572c4e7a8 100644 --- a/definitions/grib2/tables/16/4.223.table +++ b/definitions/grib2/tables/16/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/16/4.224.table b/definitions/grib2/tables/16/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/16/4.224.table +++ b/definitions/grib2/tables/16/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/16/4.227.table b/definitions/grib2/tables/16/4.227.table index 27c76553d..48c3b7633 100644 --- a/definitions/grib2/tables/16/4.227.table +++ b/definitions/grib2/tables/16/4.227.table @@ -1,9 +1,9 @@ # Code table 4.227 - Icing scenario (weather/cloud classification) -0 0 None -1 1 General -2 2 Convective -3 3 Stratiform -4 4 Freezing -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/16/4.234.table b/definitions/grib2/tables/16/4.234.table index 9844a91d2..d8b3715b3 100644 --- a/definitions/grib2/tables/16/4.234.table +++ b/definitions/grib2/tables/16/4.234.table @@ -1,21 +1,21 @@ # Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Crops, mixed farming -2 2 Short grass -3 3 Evergreen needleleaf trees -4 4 Deciduous needleleaf trees -5 5 Deciduous broadleaf trees -6 6 Evergreen broadleaf trees -7 7 Tall grass -8 8 Desert -9 9 Tundra -10 10 Irrigated crops -11 11 Semidesert -12 12 Ice caps and glaciers -13 13 Bogs and marshes -14 14 Inland water -15 15 Ocean -16 16 Evergreen shrubs -17 17 Deciduous shrubs -18 18 Mixed forest -19 19 Interrupted forest -20 20 Water and land mixtures +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/16/4.236.table b/definitions/grib2/tables/16/4.236.table index 08c7f8d56..b667b65fc 100644 --- a/definitions/grib2/tables/16/4.236.table +++ b/definitions/grib2/tables/16/4.236.table @@ -1,8 +1,8 @@ # Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in PDT 4.53 or 4.54) -1 1 Coarse -2 2 Medium -3 3 Medium-fine -4 4 Fine -5 5 Very-fine -6 6 Organic -7 7 Tropical-organic +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/16/4.240.table b/definitions/grib2/tables/16/4.240.table index c12ebbb77..1838acfc0 100644 --- a/definitions/grib2/tables/16/4.240.table +++ b/definitions/grib2/tables/16/4.240.table @@ -1,12 +1,12 @@ # Code table 4.240 - Type of distribution function -0 0 No specific distribution function given -1 1 Delta functions with spatially variable concentration and fixed diameters Dl (p1) in meter -2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg -3 3 Gaussian (Normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) -4 4 Gaussian (Normal) distribution with spatially variable concentration, mean diameter and variance -5 5 Log-normal distribution with spatially variable number density, mean diameter and variance +0 0 No specific distribution function given +1 1 Delta functions with spatially variable concentration and fixed diameters Dl (p1) in meter +2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg +3 3 Gaussian (Normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) +4 4 Gaussian (Normal) distribution with spatially variable concentration, mean diameter and variance +5 5 Log-normal distribution with spatially variable number density, mean diameter and variance 6 6 Log-normal distribution with spatially variable number density, mean diameter and fixed variance(p1) 7 7 Log-normal distribution with spatially variable number density and mass density and fixed variance(p1) and fixed particle density(p2) -# 8-49151 Reserved -# 49152-65534 Reserved for local use -65535 65535 Missing value +# 8-49151 Reserved +# 49152-65534 Reserved for local use +65535 65535 Missing value diff --git a/definitions/grib2/tables/16/4.241.table b/definitions/grib2/tables/16/4.241.table index a037b4ba5..5ea7f775a 100644 --- a/definitions/grib2/tables/16/4.241.table +++ b/definitions/grib2/tables/16/4.241.table @@ -1,9 +1,9 @@ # Code table 4.241 - Coverage attributes -0 0 Undefined -1 1 Unmodified -2 2 Snow covered -3 3 Flooded -4 4 Ice covered -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Undefined +1 1 Unmodified +2 2 Snow covered +3 3 Flooded +4 4 Ice covered +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/16/4.242.table b/definitions/grib2/tables/16/4.242.table index 083f88c29..f6865957c 100644 --- a/definitions/grib2/tables/16/4.242.table +++ b/definitions/grib2/tables/16/4.242.table @@ -1,7 +1,7 @@ # Code table 4.242 - Tile classification -0 0 Reserved -1 1 Land use classes according to ESA-GlobCover GCV2009 -2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Reserved +1 1 Land use classes according to ESA-GlobCover GCV2009 +2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/16/4.243.table b/definitions/grib2/tables/16/4.243.table index b39053311..24d21b719 100644 --- a/definitions/grib2/tables/16/4.243.table +++ b/definitions/grib2/tables/16/4.243.table @@ -1,43 +1,43 @@ # Code table 4.243 - Tile class -0 0 Reserved -1 1 Evergreen broadleaved forest -2 2 Deciduous broadleaved closed forest -3 3 Deciduous broadleaved open forest -4 4 Evergreen needle-leaf forest -5 5 Deciduous needle-leaf forest -6 6 Mixed leaf trees -7 7 Freshwater flooded trees -8 8 Saline water flooded trees -9 9 Mosaic tree/natural vegetation -10 10 Burnt tree cover -11 11 Evergreen shrubs closed-open -12 12 Deciduous shrubs closed-open -13 13 Herbaceous vegetation closed-open -14 14 Sparse herbaceous or grass -15 15 Flooded shrubs or herbaceous -16 16 Cultivated and managed areas -17 17 Mosaic crop/tree/natural vegetation -18 18 Mosaic crop/shrub/grass -19 19 Bare areas -20 20 Water -21 21 Snow and ice -22 22 Artificial surface -23 23 Ocean -24 24 Irrigated croplands -25 25 Rainfed croplands -26 26 Mosaic cropland (50-70%) - vegetation (20-50%) -27 27 Mosaic vegetation (50-70%) - cropland (20-50%) -28 28 Closed broadleaved evergreen forest -29 29 Closed needle-leaved evergreen forest -30 30 Open needle-leaved deciduous forest -31 31 Mixed broadleaved and needle-leaved forest -32 32 Mosaic shrubland (50-70%) - grassland (20-50%) -33 33 Mosaic grassland (50-70%) - shrubland (20-50%) -34 34 Closed to open shrubland -35 35 Sparse vegetation -36 36 Closed to open forest regularly flooded -37 37 Closed forest or shrubland permanently flooded -38 38 Closed to open grassland regularly flooded -39 39 Undefined -# 40-32767 Reserved -# 32768- Reserved for local use +0 0 Reserved +1 1 Evergreen broadleaved forest +2 2 Deciduous broadleaved closed forest +3 3 Deciduous broadleaved open forest +4 4 Evergreen needle-leaf forest +5 5 Deciduous needle-leaf forest +6 6 Mixed leaf trees +7 7 Freshwater flooded trees +8 8 Saline water flooded trees +9 9 Mosaic tree/natural vegetation +10 10 Burnt tree cover +11 11 Evergreen shrubs closed-open +12 12 Deciduous shrubs closed-open +13 13 Herbaceous vegetation closed-open +14 14 Sparse herbaceous or grass +15 15 Flooded shrubs or herbaceous +16 16 Cultivated and managed areas +17 17 Mosaic crop/tree/natural vegetation +18 18 Mosaic crop/shrub/grass +19 19 Bare areas +20 20 Water +21 21 Snow and ice +22 22 Artificial surface +23 23 Ocean +24 24 Irrigated croplands +25 25 Rainfed croplands +26 26 Mosaic cropland (50-70%) - vegetation (20-50%) +27 27 Mosaic vegetation (50-70%) - cropland (20-50%) +28 28 Closed broadleaved evergreen forest +29 29 Closed needle-leaved evergreen forest +30 30 Open needle-leaved deciduous forest +31 31 Mixed broadleaved and needle-leaved forest +32 32 Mosaic shrubland (50-70%) - grassland (20-50%) +33 33 Mosaic grassland (50-70%) - shrubland (20-50%) +34 34 Closed to open shrubland +35 35 Sparse vegetation +36 36 Closed to open forest regularly flooded +37 37 Closed forest or shrubland permanently flooded +38 38 Closed to open grassland regularly flooded +39 39 Undefined +# 40-32767 Reserved +# 32768- Reserved for local use diff --git a/definitions/grib2/tables/16/4.3.table b/definitions/grib2/tables/16/4.3.table index f205ea0c2..bcf8102a1 100644 --- a/definitions/grib2/tables/16/4.3.table +++ b/definitions/grib2/tables/16/4.3.table @@ -1,22 +1,22 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -12 12 Post-processed analysis -13 13 Post-processed forecast -14 14 Nowcast -15 15 Hindcast -16 16 Physical retrieval -17 17 Regression analysis -# 18-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +12 12 Post-processed analysis +13 13 Post-processed forecast +14 14 Nowcast +15 15 Hindcast +16 16 Physical retrieval +17 17 Regression analysis +# 18-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.4.table b/definitions/grib2/tables/16/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/16/4.4.table +++ b/definitions/grib2/tables/16/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.5.table b/definitions/grib2/tables/16/4.5.table index 73c6eb7bf..8d4ae8d1a 100644 --- a/definitions/grib2/tables/16/4.5.table +++ b/definitions/grib2/tables/16/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface (-) 2 2 Cloud base level (-) 3 3 Level of cloud tops (-) @@ -12,11 +12,11 @@ 10 10 Entire atmosphere (-) 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,18 +25,18 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level (-) -112 112 Reserved -113 113 Logarithmic hybrid level +112 112 Reserved +113 113 Logarithmic hybrid level 114 114 Snow level (Numeric) -# 115-116 Reserved +# 115-116 Reserved 117 117 Mixed layer depth (m) 118 hhl Hybrid height level (-) 119 hpl Hybrid pressure level (-) -# 120-149 Reserved -150 150 Generalized vertical height coordinate -# 151-159 Reserved +# 120-149 Reserved +150 150 Generalized vertical height coordinate +# 151-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom (-) @@ -45,18 +45,18 @@ 165 165 Bottom of sediment layer penetrated by thermal wave (-) 166 sfc Mixing layer (-) 167 167 Bottom of root zone (-) -# 168-173 Reserved -174 sfc Top surface of ice on sea, lake or river -175 175 Top surface of ice, under snow cover, on sea, lake or river -176 176 Bottom surface (underside) ice on sea, lake or river -177 sfc Deep soil (of indefinite depth) -178 178 Reserved -179 179 Top surface of glacier ice and inland ice -180 180 Deep inland or glacier ice (of indefinite depth) -181 181 Grid tile land fraction as a model surface -182 182 Grid tile water fraction as a model surface -183 183 Grid tile ice fraction on sea, lake or river as a model surface -184 184 Grid tile glacier ice and inland ice fraction as a model surface -# 185-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 168-173 Reserved +174 sfc Top surface of ice on sea, lake or river +175 175 Top surface of ice, under snow cover, on sea, lake or river +176 176 Bottom surface (underside) ice on sea, lake or river +177 sfc Deep soil (of indefinite depth) +178 178 Reserved +179 179 Top surface of glacier ice and inland ice +180 180 Deep inland or glacier ice (of indefinite depth) +181 181 Grid tile land fraction as a model surface +182 182 Grid tile water fraction as a model surface +183 183 Grid tile ice fraction on sea, lake or river as a model surface +184 184 Grid tile glacier ice and inland ice fraction as a model surface +# 185-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.6.table b/definitions/grib2/tables/16/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/16/4.6.table +++ b/definitions/grib2/tables/16/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.7.table b/definitions/grib2/tables/16/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/16/4.7.table +++ b/definitions/grib2/tables/16/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.8.table b/definitions/grib2/tables/16/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/16/4.8.table +++ b/definitions/grib2/tables/16/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.9.table b/definitions/grib2/tables/16/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/16/4.9.table +++ b/definitions/grib2/tables/16/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/4.91.table b/definitions/grib2/tables/16/4.91.table index 44cf25f44..ae31ed61c 100644 --- a/definitions/grib2/tables/16/4.91.table +++ b/definitions/grib2/tables/16/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit -11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/16/5.0.table b/definitions/grib2/tables/16/5.0.table index 5ec77ed0f..2795336df 100644 --- a/definitions/grib2/tables/16/5.0.table +++ b/definitions/grib2/tables/16/5.0.table @@ -1,23 +1,23 @@ # Code table 5.0 - Data representation template number -0 0 Grid point data - simple packing -1 1 Matrix value at grid point - simple packing -2 2 Grid point data - complex packing -3 3 Grid point data - complex packing and spatial differencing -4 4 Grid point data - IEEE floating point data -40 40 Grid point data - JPEG 2000 code stream format -41 41 Grid point data - Portable Network Graphics (PNG) -# 42-49 Reserved -50 50 Spectral data - simple packing -51 51 Spherical harmonics data - complex packing -# 52-60 Reserved -61 61 Grid point data - simple packing with logarithm pre-processing -# 62-199 Reserved -200 200 Run length packing with level values -# 201-49151 Reserved -# 49152-65534 Reserved for local use +0 0 Grid point data - simple packing +1 1 Matrix value at grid point - simple packing +2 2 Grid point data - complex packing +3 3 Grid point data - complex packing and spatial differencing +4 4 Grid point data - IEEE floating point data +40 40 Grid point data - JPEG 2000 code stream format +41 41 Grid point data - Portable Network Graphics (PNG) +# 42-49 Reserved +50 50 Spectral data - simple packing +51 51 Spherical harmonics data - complex packing +# 52-60 Reserved +61 61 Grid point data - simple packing with logarithm pre-processing +# 62-199 Reserved +200 200 Run length packing with level values +# 201-49151 Reserved +# 49152-65534 Reserved for local use 40000 40000 JPEG2000 Packing 40010 40010 PNG pacling 50000 50000 Sperical harmonics ieee packing 50001 50001 Second order packing 50002 50002 Second order packing -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/16/5.1.table b/definitions/grib2/tables/16/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/16/5.1.table +++ b/definitions/grib2/tables/16/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/5.2.table b/definitions/grib2/tables/16/5.2.table index 40586a131..d77fdf4e7 100644 --- a/definitions/grib2/tables/16/5.2.table +++ b/definitions/grib2/tables/16/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/5.3.table b/definitions/grib2/tables/16/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/16/5.3.table +++ b/definitions/grib2/tables/16/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/5.4.table b/definitions/grib2/tables/16/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/16/5.4.table +++ b/definitions/grib2/tables/16/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/5.40.table b/definitions/grib2/tables/16/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/16/5.40.table +++ b/definitions/grib2/tables/16/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/16/5.5.table b/definitions/grib2/tables/16/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/16/5.5.table +++ b/definitions/grib2/tables/16/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/5.6.table b/definitions/grib2/tables/16/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/16/5.6.table +++ b/definitions/grib2/tables/16/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/16/5.7.table b/definitions/grib2/tables/16/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/16/5.7.table +++ b/definitions/grib2/tables/16/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/16/6.0.table b/definitions/grib2/tables/16/6.0.table index f539b26d7..a8f30f5a4 100644 --- a/definitions/grib2/tables/16/6.0.table +++ b/definitions/grib2/tables/16/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/17/0.0.table b/definitions/grib2/tables/17/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/17/0.0.table +++ b/definitions/grib2/tables/17/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/1.0.table b/definitions/grib2/tables/17/1.0.table index d1134399b..893633977 100644 --- a/definitions/grib2/tables/17/1.0.table +++ b/definitions/grib2/tables/17/1.0.table @@ -1,22 +1,22 @@ # Code table 1.0 - GRIB master tables version number -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 -6 6 Version implemented on 15 September 2010 -7 7 Version implemented on 4 May 2011 -8 8 Version implemented on 2 November 2011 -9 9 Version implemented on 2 May 2012 -10 10 Version implemented on 7 November 2012 -11 11 Version implemented on 8 May 2013 -12 12 Version implemented on 14 November 2013 -13 13 Version implemented on 7 May 2014 -14 14 Version implemented on 5 November 2014 -15 15 Version implemented on 6 May 2015 -16 16 Version implemented on 11 November 2015 +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Version implemented on 2 May 2012 +10 10 Version implemented on 7 November 2012 +11 11 Version implemented on 8 May 2013 +12 12 Version implemented on 14 November 2013 +13 13 Version implemented on 7 May 2014 +14 14 Version implemented on 5 November 2014 +15 15 Version implemented on 6 May 2015 +16 16 Version implemented on 11 November 2015 17 17 Version implemented on 4 May 2016 18 18 Pre-operational to be implemented by next amendment -# 19-254 Future versions -255 255 Missing +# 19-254 Future versions +255 255 Missing diff --git a/definitions/grib2/tables/17/1.1.table b/definitions/grib2/tables/17/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/17/1.1.table +++ b/definitions/grib2/tables/17/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/17/1.2.table b/definitions/grib2/tables/17/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/17/1.2.table +++ b/definitions/grib2/tables/17/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/1.3.table b/definitions/grib2/tables/17/1.3.table index 0c95269d5..c1a9a7b9d 100644 --- a/definitions/grib2/tables/17/1.3.table +++ b/definitions/grib2/tables/17/1.3.table @@ -1,14 +1,14 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products -4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products +4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) -6 6 S2S operational products -7 7 S2S test products +6 6 S2S operational products +7 7 S2S test products 8 8 Uncertainties in Ensembles of Regional ReAnalyses project (UERRA) 9 9 Uncertainties in Ensembles of Regional ReAnalyses project test (UERRA) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/1.4.table b/definitions/grib2/tables/17/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/17/1.4.table +++ b/definitions/grib2/tables/17/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/17/1.5.table b/definitions/grib2/tables/17/1.5.table index b2cf9f087..533111959 100644 --- a/definitions/grib2/tables/17/1.5.table +++ b/definitions/grib2/tables/17/1.5.table @@ -1,7 +1,7 @@ # Code table 1.5 - Identification template number -0 0 Calendar definition -1 1 Paleontological offset -2 2 Calendar definition and paleontological offset -# 3-32767 Reserved -# 32768-65534 Reserved for local use -65535 65535 Missing +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/17/1.6.table b/definitions/grib2/tables/17/1.6.table index 5db921990..bd46899a7 100644 --- a/definitions/grib2/tables/17/1.6.table +++ b/definitions/grib2/tables/17/1.6.table @@ -1,8 +1,8 @@ # Code table 1.6 - Type of calendar -0 0 Gregorian -1 1 360-day -2 2 365-day -3 3 Proleptic Gregorian -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/3.0.table b/definitions/grib2/tables/17/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/17/3.0.table +++ b/definitions/grib2/tables/17/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/17/3.10.table b/definitions/grib2/tables/17/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/17/3.10.table +++ b/definitions/grib2/tables/17/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/17/3.11.table b/definitions/grib2/tables/17/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/17/3.11.table +++ b/definitions/grib2/tables/17/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/17/3.15.table b/definitions/grib2/tables/17/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/17/3.15.table +++ b/definitions/grib2/tables/17/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/3.2.table b/definitions/grib2/tables/17/3.2.table index 9238dc2a7..b9574a424 100644 --- a/definitions/grib2/tables/17/3.2.table +++ b/definitions/grib2/tables/17/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/3.20.table b/definitions/grib2/tables/17/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/17/3.20.table +++ b/definitions/grib2/tables/17/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/3.21.table b/definitions/grib2/tables/17/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/17/3.21.table +++ b/definitions/grib2/tables/17/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/3.3.table b/definitions/grib2/tables/17/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/17/3.3.table +++ b/definitions/grib2/tables/17/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/17/3.4.table b/definitions/grib2/tables/17/3.4.table index 897b813d7..43835c014 100644 --- a/definitions/grib2/tables/17/3.4.table +++ b/definitions/grib2/tables/17/3.4.table @@ -1,17 +1,17 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -5 0 Points within odd rows are not offset in i (x) direction -5 1 Points within odd rows are offset by Di/2 in i (x) direction -6 0 Points within even rows are not offset in i (x) direction -6 1 Points within even rows are offset by Di/2 in i (x) direction -7 0 Points are not offset in j (y) direction -7 1 Points are offset by Dj/2 in j (y) direction -8 0 Rows have Ni grid points and columns have Nj grid points -8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +5 0 Points within odd rows are not offset in i (x) direction +5 1 Points within odd rows are offset by Di/2 in i (x) direction +6 0 Points within even rows are not offset in i (x) direction +6 1 Points within even rows are offset by Di/2 in i (x) direction +7 0 Points are not offset in j (y) direction +7 1 Points are offset by Dj/2 in j (y) direction +8 0 Rows have Ni grid points and columns have Nj grid points +8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction diff --git a/definitions/grib2/tables/17/3.5.table b/definitions/grib2/tables/17/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/17/3.5.table +++ b/definitions/grib2/tables/17/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/17/3.7.table b/definitions/grib2/tables/17/3.7.table index 0a7d6efde..34c0de085 100644 --- a/definitions/grib2/tables/17/3.7.table +++ b/definitions/grib2/tables/17/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 see separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/17/3.8.table b/definitions/grib2/tables/17/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/17/3.8.table +++ b/definitions/grib2/tables/17/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/3.9.table b/definitions/grib2/tables/17/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/17/3.9.table +++ b/definitions/grib2/tables/17/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/17/4.0.table b/definitions/grib2/tables/17/4.0.table index 802eca6bf..ff8a54b04 100644 --- a/definitions/grib2/tables/17/4.0.table +++ b/definitions/grib2/tables/17/4.0.table @@ -1,65 +1,65 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time -8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -# 35-39 Reserved +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +# 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol -46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol 47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -# 49-50 Reserved -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time -52 52 Reserved -53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time -54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters -55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time -56 56 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters -57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function -# 58-59 Reserved -60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval -# 62-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +# 49-50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +52 52 Reserved +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time +56 56 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters +57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function +# 58-59 Reserved +60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval +# 62-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/17/4.1.0.table b/definitions/grib2/tables/17/4.1.0.table index 04cfd7802..df58636d6 100644 --- a/definitions/grib2/tables/17/4.1.0.table +++ b/definitions/grib2/tables/17/4.1.0.table @@ -1,27 +1,27 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.1.1.table b/definitions/grib2/tables/17/4.1.1.table index 7b22b6fed..05a854da0 100644 --- a/definitions/grib2/tables/17/4.1.1.table +++ b/definitions/grib2/tables/17/4.1.1.table @@ -1,7 +1,7 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.1.10.table b/definitions/grib2/tables/17/4.1.10.table index a9b20eb9c..88d3c8743 100644 --- a/definitions/grib2/tables/17/4.1.10.table +++ b/definitions/grib2/tables/17/4.1.10.table @@ -1,10 +1,10 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Subsurface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Subsurface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.1.2.table b/definitions/grib2/tables/17/4.1.2.table index 5b488fe9e..e74126645 100644 --- a/definitions/grib2/tables/17/4.1.2.table +++ b/definitions/grib2/tables/17/4.1.2.table @@ -1,9 +1,9 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.1.3.table b/definitions/grib2/tables/17/4.1.3.table index 7bf60d4a7..ba38c9301 100644 --- a/definitions/grib2/tables/17/4.1.3.table +++ b/definitions/grib2/tables/17/4.1.3.table @@ -1,11 +1,11 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Image format products -1 1 Quantitative products -2 2 Cloud properties -3 3 Flight rule conditions -4 4 Volcanic ash -5 5 Sea-surface temperature -6 6 Solar radiation -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +2 2 Cloud properties +3 3 Flight rule conditions +4 4 Volcanic ash +5 5 Sea-surface temperature +6 6 Solar radiation +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.10.table b/definitions/grib2/tables/17/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/17/4.10.table +++ b/definitions/grib2/tables/17/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/17/4.11.table b/definitions/grib2/tables/17/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/17/4.11.table +++ b/definitions/grib2/tables/17/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.12.table b/definitions/grib2/tables/17/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/17/4.12.table +++ b/definitions/grib2/tables/17/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.13.table b/definitions/grib2/tables/17/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/17/4.13.table +++ b/definitions/grib2/tables/17/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.14.table b/definitions/grib2/tables/17/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/17/4.14.table +++ b/definitions/grib2/tables/17/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.15.table b/definitions/grib2/tables/17/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/17/4.15.table +++ b/definitions/grib2/tables/17/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.0.table b/definitions/grib2/tables/17/4.2.0.0.table index f24b8832c..4e2cf578e 100644 --- a/definitions/grib2/tables/17/4.2.0.0.table +++ b/definitions/grib2/tables/17/4.2.0.0.table @@ -27,6 +27,6 @@ 25 25 Temperature tendency due to long-wave radiation, clear sky (K s-1) 26 26 Temperature tendency due to parameterization (K s-1) 27 27 Wet-bulb temperature (K) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.1.table b/definitions/grib2/tables/17/4.2.0.1.table index 70001f746..004d11d25 100644 --- a/definitions/grib2/tables/17/4.2.0.1.table +++ b/definitions/grib2/tables/17/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,7 +86,7 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) @@ -115,6 +115,6 @@ 115 115 Mass density of liquid water coating on snow expressed as mass of liquid water per unit volume of air (kg m-3) 116 116 Specific mass of liquid water coating on snow expressed as mass of liquid water per unit mass of moist air (kg kg-1) 117 117 Mass mixing ratio of liquid water coating on snow expressed as mass of liquid water per unit mass of dry air (kg kg-1) -# 118-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 118-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.13.table b/definitions/grib2/tables/17/4.2.0.13.table index 5086101ad..3f5c30675 100644 --- a/definitions/grib2/tables/17/4.2.0.13.table +++ b/definitions/grib2/tables/17/4.2.0.13.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.14.table b/definitions/grib2/tables/17/4.2.0.14.table index 215884737..97fb38c8b 100644 --- a/definitions/grib2/tables/17/4.2.0.14.table +++ b/definitions/grib2/tables/17/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.15.table b/definitions/grib2/tables/17/4.2.0.15.table index dfbc4d12f..8df082466 100644 --- a/definitions/grib2/tables/17/4.2.0.15.table +++ b/definitions/grib2/tables/17/4.2.0.15.table @@ -16,6 +16,6 @@ 14 14 Reflectivity of hail (dB) 15 15 Hybrid scan reflectivity (dB) 16 16 Hybrid scan reflectivity height (m) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.16.table b/definitions/grib2/tables/17/4.2.0.16.table index 0c240a853..9499d9333 100644 --- a/definitions/grib2/tables/17/4.2.0.16.table +++ b/definitions/grib2/tables/17/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.18.table b/definitions/grib2/tables/17/4.2.0.18.table index 9ae3539ca..16cfa489d 100644 --- a/definitions/grib2/tables/17/4.2.0.18.table +++ b/definitions/grib2/tables/17/4.2.0.18.table @@ -8,7 +8,7 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) @@ -16,6 +16,6 @@ 14 14 Specific activity concentration (Bq kg-1) 15 15 Maximum of air concentration in layer (Bq m-3) 16 16 Height of maximum air concentration (m) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.19.table b/definitions/grib2/tables/17/4.2.0.19.table index 8705082c5..e4db36249 100644 --- a/definitions/grib2/tables/17/4.2.0.19.table +++ b/definitions/grib2/tables/17/4.2.0.19.table @@ -31,6 +31,6 @@ 29 29 Clear air turbulence (CAT) (m2/3 s-1) 30 30 Eddy dissipation parameter (m2/3 s-1) 31 31 Maximum of Eddy dissipation parameter in layer (m2/3 s-1) -# 32-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 32-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.190.table b/definitions/grib2/tables/17/4.2.0.190.table index de621a924..a0d6ba0ac 100644 --- a/definitions/grib2/tables/17/4.2.0.190.table +++ b/definitions/grib2/tables/17/4.2.0.190.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.191.table b/definitions/grib2/tables/17/4.2.0.191.table index e3bba0ebe..b3a7092ea 100644 --- a/definitions/grib2/tables/17/4.2.0.191.table +++ b/definitions/grib2/tables/17/4.2.0.191.table @@ -3,6 +3,6 @@ 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.2.table b/definitions/grib2/tables/17/4.2.0.2.table index 8ebc75124..7967bf7bf 100644 --- a/definitions/grib2/tables/17/4.2.0.2.table +++ b/definitions/grib2/tables/17/4.2.0.2.table @@ -44,6 +44,6 @@ 42 42 v-component of geostrophic wind (m s-1) 43 43 Geostrophic wind direction (degree true) 44 44 Geostrophic wind speed (m s-1) -# 45-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 45-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.20.table b/definitions/grib2/tables/17/4.2.0.20.table index 983539bd2..38479b834 100644 --- a/definitions/grib2/tables/17/4.2.0.20.table +++ b/definitions/grib2/tables/17/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -28,7 +28,7 @@ 60 60 Aerosol specific number concentration (kg-1) 61 61 Maximum of mass density in layer (kg m-3) 62 62 Height of maximum mass density (m) -# 63-99 Reserved +# 63-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -41,6 +41,6 @@ 109 109 Aerosol lidar extinction from satellite (/m) 110 110 Aerosol lidar extinction from the ground (/m) 111 111 Angstrom exponent (Numeric) -# 112-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 112-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.3.table b/definitions/grib2/tables/17/4.2.0.3.table index c7c6359d4..17e7f204f 100644 --- a/definitions/grib2/tables/17/4.2.0.3.table +++ b/definitions/grib2/tables/17/4.2.0.3.table @@ -30,6 +30,6 @@ 28 28 Downdraught mass flux (kg m-2 s-1) 29 29 Updraught detrainment rate (kg m-3 s-1) 30 30 Downdraught detrainment rate (kg m-3 s-1) -# 31-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 31-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.4.table b/definitions/grib2/tables/17/4.2.0.4.table index 0a5ded2b5..f97270456 100644 --- a/definitions/grib2/tables/17/4.2.0.4.table +++ b/definitions/grib2/tables/17/4.2.0.4.table @@ -14,11 +14,11 @@ 12 12 Downward UV radiation (W m-2) 13 13 Direct short-wave radiation flux (W m-2) 14 14 Diffuse short-wave radiation flux (W m-2) -# 15-49 Reserved +# 15-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) 52 52 Downward short-wave radiation flux, clear sky (W m-2) 53 53 Upward short-wave radiation flux, clear sky (W m-2) -# 54-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 54-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.5.table b/definitions/grib2/tables/17/4.2.0.5.table index 4550220b6..ddfa634ce 100644 --- a/definitions/grib2/tables/17/4.2.0.5.table +++ b/definitions/grib2/tables/17/4.2.0.5.table @@ -8,6 +8,6 @@ 6 6 Net long-wave radiation flux, clear sky (W m-2) 7 7 Brightness temperature (K) 8 8 Downward long-wave radiation flux, clear sky (W m-2) -# 9-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 9-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.6.table b/definitions/grib2/tables/17/4.2.0.6.table index 4cec0c8aa..0450ec194 100644 --- a/definitions/grib2/tables/17/4.2.0.6.table +++ b/definitions/grib2/tables/17/4.2.0.6.table @@ -40,10 +40,10 @@ 38 38 Mass density of cloud droplets (kg m-3) 39 39 Mass density of cloud ice (kg m-3) 40 40 Mass density of convective cloud water droplets (kg m-3) -# 41-46 Reserved +# 41-46 Reserved 47 47 Volume fraction of cloud water droplets (Numeric) 48 48 Volume fraction of cloud ice particles (Numeric) 49 49 Volume fraction of cloud (ice and/or water) (Numeric) -# 50-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 50-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.0.7.table b/definitions/grib2/tables/17/4.2.0.7.table index 6d0d87a46..3e653431f 100644 --- a/definitions/grib2/tables/17/4.2.0.7.table +++ b/definitions/grib2/tables/17/4.2.0.7.table @@ -13,11 +13,11 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraught helicity (m2 s-2) 16 16 Bulk Richardson number (Numeric) 17 17 Gradient Richardson number (Numeric) 18 18 Flux Richardson number (Numeric) -# 19-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 19-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.1.0.table b/definitions/grib2/tables/17/4.2.1.0.table index bcd849c2e..a2660f4f3 100644 --- a/definitions/grib2/tables/17/4.2.1.0.table +++ b/definitions/grib2/tables/17/4.2.1.0.table @@ -16,6 +16,6 @@ 14 14 Upstream accumulated precipitation (kg m-2) 15 15 Upstream accumulated snow melt (kg m-2) 16 16 Percolation rate (kg m-2 s-1) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.1.1.table b/definitions/grib2/tables/17/4.2.1.1.table index b488eb0bd..171da3958 100644 --- a/definitions/grib2/tables/17/4.2.1.1.table +++ b/definitions/grib2/tables/17/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.10.0.table b/definitions/grib2/tables/17/4.2.10.0.table index 095f51bdf..3611abd9a 100644 --- a/definitions/grib2/tables/17/4.2.10.0.table +++ b/definitions/grib2/tables/17/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (/s) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.10.1.table b/definitions/grib2/tables/17/4.2.10.1.table index 5959bfa28..f0a073c00 100644 --- a/definitions/grib2/tables/17/4.2.10.1.table +++ b/definitions/grib2/tables/17/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.10.191.table b/definitions/grib2/tables/17/4.2.10.191.table index 524929e78..1ebf85006 100644 --- a/definitions/grib2/tables/17/4.2.10.191.table +++ b/definitions/grib2/tables/17/4.2.10.191.table @@ -1,8 +1,8 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -2 2 Reserved +2 2 Reserved 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.10.2.table b/definitions/grib2/tables/17/4.2.10.2.table index 6797062ac..4633bad4f 100644 --- a/definitions/grib2/tables/17/4.2.10.2.table +++ b/definitions/grib2/tables/17/4.2.10.2.table @@ -12,6 +12,6 @@ 10 10 Zonal vector component of vertically integrated ice internal pressure (Pa m) 11 11 Meridional vector component of vertically integrated ice internal pressure (Pa m) 12 12 Compressive ice strength (N/m) -# 13-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.10.3.table b/definitions/grib2/tables/17/4.2.10.3.table index f951bbe78..937720c93 100644 --- a/definitions/grib2/tables/17/4.2.10.3.table +++ b/definitions/grib2/tables/17/4.2.10.3.table @@ -1,6 +1,6 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.10.4.table b/definitions/grib2/tables/17/4.2.10.4.table index 54774f1b7..d5615ae26 100644 --- a/definitions/grib2/tables/17/4.2.10.4.table +++ b/definitions/grib2/tables/17/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2/s) 6 6 Ocean vertical momentum diffusivity (m2/s) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (/m) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.2.0.table b/definitions/grib2/tables/17/4.2.2.0.table index 81548840c..b253cac22 100644 --- a/definitions/grib2/tables/17/4.2.2.0.table +++ b/definitions/grib2/tables/17/4.2.2.0.table @@ -38,6 +38,6 @@ 36 36 Tile fraction (Proportion) 37 37 Tile percentage (%) 38 38 Soil volumetric ice content (water equivalent) (m3 m-3) -# 39-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 39-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.2.3.table b/definitions/grib2/tables/17/4.2.2.3.table index 690fab42b..2674e9f42 100644 --- a/definitions/grib2/tables/17/4.2.2.3.table +++ b/definitions/grib2/tables/17/4.2.2.3.table @@ -27,6 +27,6 @@ 25 25 Snow depth at elevation bands (kg m-2) 26 26 Soil heat flux (W m-2) 27 27 Soil depth (m) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.2.4.table b/definitions/grib2/tables/17/4.2.2.4.table index bb54fac22..ceb761557 100644 --- a/definitions/grib2/tables/17/4.2.2.4.table +++ b/definitions/grib2/tables/17/4.2.2.4.table @@ -11,6 +11,6 @@ 9 9 Initial Fire Spread Index (Canadian Forest Service) (Numeric) 10 10 Fire Buildup Index (Canadian Forest Service) (Numeric) 11 11 Fire Daily Severity Rating (Canadian Forest Service) (Numeric) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.3.0.table b/definitions/grib2/tables/17/4.2.3.0.table index c0ffa29f5..80a829673 100644 --- a/definitions/grib2/tables/17/4.2.3.0.table +++ b/definitions/grib2/tables/17/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.2.3.1.table b/definitions/grib2/tables/17/4.2.3.1.table index 8e0793fe0..04cdde1f1 100644 --- a/definitions/grib2/tables/17/4.2.3.1.table +++ b/definitions/grib2/tables/17/4.2.3.1.table @@ -17,16 +17,16 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-26 Reserved +23 23 Angstrom coefficient +# 24-26 Reserved 27 27 Bidirectional reflectance factor (Numeric) 28 28 Brightness temperature (K) 29 29 Scaled radiance (Numeric) -# 30-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 30-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.201.table b/definitions/grib2/tables/17/4.201.table index 47f1b486f..fa173c4e0 100644 --- a/definitions/grib2/tables/17/4.201.table +++ b/definitions/grib2/tables/17/4.201.table @@ -1,15 +1,15 @@ # Code table 4.201 - Precipitation type -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow -6 6 Wet snow -7 7 Mixture of rain and snow -8 8 Ice pellets -9 9 Graupel -10 10 Hail -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +6 6 Wet snow +7 7 Mixture of rain and snow +8 8 Ice pellets +9 9 Graupel +10 10 Hail +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.202.table b/definitions/grib2/tables/17/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/17/4.202.table +++ b/definitions/grib2/tables/17/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.203.table b/definitions/grib2/tables/17/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/17/4.203.table +++ b/definitions/grib2/tables/17/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.204.table b/definitions/grib2/tables/17/4.204.table index 481372936..8e0be1f8c 100644 --- a/definitions/grib2/tables/17/4.204.table +++ b/definitions/grib2/tables/17/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (6-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (6-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.205.table b/definitions/grib2/tables/17/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/17/4.205.table +++ b/definitions/grib2/tables/17/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.206.table b/definitions/grib2/tables/17/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/17/4.206.table +++ b/definitions/grib2/tables/17/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.207.table b/definitions/grib2/tables/17/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/17/4.207.table +++ b/definitions/grib2/tables/17/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.208.table b/definitions/grib2/tables/17/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/17/4.208.table +++ b/definitions/grib2/tables/17/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.209.table b/definitions/grib2/tables/17/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/17/4.209.table +++ b/definitions/grib2/tables/17/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.210.table b/definitions/grib2/tables/17/4.210.table index c01f4bcca..791878469 100644 --- a/definitions/grib2/tables/17/4.210.table +++ b/definitions/grib2/tables/17/4.210.table @@ -1,6 +1,6 @@ # Code table 4.210 - Contrail intensity 0 0 Contrail not present 1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.211.table b/definitions/grib2/tables/17/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/17/4.211.table +++ b/definitions/grib2/tables/17/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.212.table b/definitions/grib2/tables/17/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/17/4.212.table +++ b/definitions/grib2/tables/17/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.213.table b/definitions/grib2/tables/17/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/17/4.213.table +++ b/definitions/grib2/tables/17/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.215.table b/definitions/grib2/tables/17/4.215.table index 034db72be..7888772d5 100644 --- a/definitions/grib2/tables/17/4.215.table +++ b/definitions/grib2/tables/17/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.216.table b/definitions/grib2/tables/17/4.216.table index 5d1460cef..b51b358f4 100644 --- a/definitions/grib2/tables/17/4.216.table +++ b/definitions/grib2/tables/17/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain -# 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 0-90 Elevation in increments of 100 m +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/17/4.217.table b/definitions/grib2/tables/17/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/17/4.217.table +++ b/definitions/grib2/tables/17/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.218.table b/definitions/grib2/tables/17/4.218.table index 7e3a69578..b5b15150b 100644 --- a/definitions/grib2/tables/17/4.218.table +++ b/definitions/grib2/tables/17/4.218.table @@ -1,44 +1,44 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation/crops -15 15 Permanent snow/ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -19 19 Warm liquid water cloud -20 20 Supercooled liquid water cloud -21 21 Mixed-phase cloud -22 22 Optically thin ice cloud -23 23 Optically thick ice cloud -24 24 Multilayered cloud -# 25-96 Reserved -97 97 Snow/ice on land -98 98 Snow/ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud/fog/Stratus -102 102 Low cloud/Stratocumulus -103 103 Low cloud/unknown type -104 104 Medium cloud/Nimbostratus -105 105 Medium cloud/Altostratus -106 106 Medium cloud/unknown type -107 107 High cloud/Cumulus -108 108 High cloud/Cirrus -109 109 High cloud/unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation/crops +15 15 Permanent snow/ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +19 19 Warm liquid water cloud +20 20 Supercooled liquid water cloud +21 21 Mixed-phase cloud +22 22 Optically thin ice cloud +23 23 Optically thick ice cloud +24 24 Multilayered cloud +# 25-96 Reserved +97 97 Snow/ice on land +98 98 Snow/ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud/fog/Stratus +102 102 Low cloud/Stratocumulus +103 103 Low cloud/unknown type +104 104 Medium cloud/Nimbostratus +105 105 Medium cloud/Altostratus +106 106 Medium cloud/unknown type +107 107 High cloud/Cumulus +108 108 High cloud/Cirrus +109 109 High cloud/unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.219.table b/definitions/grib2/tables/17/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/17/4.219.table +++ b/definitions/grib2/tables/17/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.220.table b/definitions/grib2/tables/17/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/17/4.220.table +++ b/definitions/grib2/tables/17/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.221.table b/definitions/grib2/tables/17/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/17/4.221.table +++ b/definitions/grib2/tables/17/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.222.table b/definitions/grib2/tables/17/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/17/4.222.table +++ b/definitions/grib2/tables/17/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.223.table b/definitions/grib2/tables/17/4.223.table index f0deb076a..572c4e7a8 100644 --- a/definitions/grib2/tables/17/4.223.table +++ b/definitions/grib2/tables/17/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/17/4.224.table b/definitions/grib2/tables/17/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/17/4.224.table +++ b/definitions/grib2/tables/17/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/17/4.227.table b/definitions/grib2/tables/17/4.227.table index 27c76553d..48c3b7633 100644 --- a/definitions/grib2/tables/17/4.227.table +++ b/definitions/grib2/tables/17/4.227.table @@ -1,9 +1,9 @@ # Code table 4.227 - Icing scenario (weather/cloud classification) -0 0 None -1 1 General -2 2 Convective -3 3 Stratiform -4 4 Freezing -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/17/4.234.table b/definitions/grib2/tables/17/4.234.table index 816541ce9..3b05b4515 100644 --- a/definitions/grib2/tables/17/4.234.table +++ b/definitions/grib2/tables/17/4.234.table @@ -1,21 +1,21 @@ # Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in product definition template 4.53 or 4.54) -1 1 Crops, mixed farming -2 2 Short grass -3 3 Evergreen needleleaf trees -4 4 Deciduous needleleaf trees -5 5 Deciduous broadleaf trees -6 6 Evergreen broadleaf trees -7 7 Tall grass -8 8 Desert -9 9 Tundra -10 10 Irrigated crops -11 11 Semidesert -12 12 Ice caps and glaciers -13 13 Bogs and marshes -14 14 Inland water -15 15 Ocean -16 16 Evergreen shrubs -17 17 Deciduous shrubs -18 18 Mixed forest -19 19 Interrupted forest -20 20 Water and land mixtures +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/17/4.236.table b/definitions/grib2/tables/17/4.236.table index fbe093ce9..9c58b488c 100644 --- a/definitions/grib2/tables/17/4.236.table +++ b/definitions/grib2/tables/17/4.236.table @@ -1,8 +1,8 @@ # Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in product definition template 4.53 or 4.54) -1 1 Coarse -2 2 Medium -3 3 Medium-fine -4 4 Fine -5 5 Very-fine -6 6 Organic -7 7 Tropical-organic +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/17/4.240.table b/definitions/grib2/tables/17/4.240.table index ca335fea8..986557483 100644 --- a/definitions/grib2/tables/17/4.240.table +++ b/definitions/grib2/tables/17/4.240.table @@ -1,12 +1,12 @@ # Code table 4.240 - Type of distribution function -0 0 No specific distribution function given +0 0 No specific distribution function given 1 1 Delta functions with spatially variable concentration and fixed diameters Dl (p1) in metre -2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg -3 3 Gaussian (normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) -4 4 Gaussian (normal) distribution with spatially variable concentration, mean diameter and variance -5 5 Log-normal distribution with spatially variable number density, mean diameter and variance -6 6 Log-normal distribution with spatially variable number density, mean diameter and fixed variance(p1) +2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg +3 3 Gaussian (normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) +4 4 Gaussian (normal) distribution with spatially variable concentration, mean diameter and variance +5 5 Log-normal distribution with spatially variable number density, mean diameter and variance +6 6 Log-normal distribution with spatially variable number density, mean diameter and fixed variance(p1) 7 7 Log-normal distribution with spatially variable number density and mass density and fixed variance(p1) and fixed particle density(p2) -# 8-49151 Reserved -# 49152-65534 Reserved for local use -65535 65535 Missing value +# 8-49151 Reserved +# 49152-65534 Reserved for local use +65535 65535 Missing value diff --git a/definitions/grib2/tables/17/4.241.table b/definitions/grib2/tables/17/4.241.table index a037b4ba5..5ea7f775a 100644 --- a/definitions/grib2/tables/17/4.241.table +++ b/definitions/grib2/tables/17/4.241.table @@ -1,9 +1,9 @@ # Code table 4.241 - Coverage attributes -0 0 Undefined -1 1 Unmodified -2 2 Snow covered -3 3 Flooded -4 4 Ice covered -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Undefined +1 1 Unmodified +2 2 Snow covered +3 3 Flooded +4 4 Ice covered +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/17/4.242.table b/definitions/grib2/tables/17/4.242.table index 083f88c29..f6865957c 100644 --- a/definitions/grib2/tables/17/4.242.table +++ b/definitions/grib2/tables/17/4.242.table @@ -1,7 +1,7 @@ # Code table 4.242 - Tile classification -0 0 Reserved -1 1 Land use classes according to ESA-GlobCover GCV2009 -2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Reserved +1 1 Land use classes according to ESA-GlobCover GCV2009 +2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/17/4.243.table b/definitions/grib2/tables/17/4.243.table index b39053311..24d21b719 100644 --- a/definitions/grib2/tables/17/4.243.table +++ b/definitions/grib2/tables/17/4.243.table @@ -1,43 +1,43 @@ # Code table 4.243 - Tile class -0 0 Reserved -1 1 Evergreen broadleaved forest -2 2 Deciduous broadleaved closed forest -3 3 Deciduous broadleaved open forest -4 4 Evergreen needle-leaf forest -5 5 Deciduous needle-leaf forest -6 6 Mixed leaf trees -7 7 Freshwater flooded trees -8 8 Saline water flooded trees -9 9 Mosaic tree/natural vegetation -10 10 Burnt tree cover -11 11 Evergreen shrubs closed-open -12 12 Deciduous shrubs closed-open -13 13 Herbaceous vegetation closed-open -14 14 Sparse herbaceous or grass -15 15 Flooded shrubs or herbaceous -16 16 Cultivated and managed areas -17 17 Mosaic crop/tree/natural vegetation -18 18 Mosaic crop/shrub/grass -19 19 Bare areas -20 20 Water -21 21 Snow and ice -22 22 Artificial surface -23 23 Ocean -24 24 Irrigated croplands -25 25 Rainfed croplands -26 26 Mosaic cropland (50-70%) - vegetation (20-50%) -27 27 Mosaic vegetation (50-70%) - cropland (20-50%) -28 28 Closed broadleaved evergreen forest -29 29 Closed needle-leaved evergreen forest -30 30 Open needle-leaved deciduous forest -31 31 Mixed broadleaved and needle-leaved forest -32 32 Mosaic shrubland (50-70%) - grassland (20-50%) -33 33 Mosaic grassland (50-70%) - shrubland (20-50%) -34 34 Closed to open shrubland -35 35 Sparse vegetation -36 36 Closed to open forest regularly flooded -37 37 Closed forest or shrubland permanently flooded -38 38 Closed to open grassland regularly flooded -39 39 Undefined -# 40-32767 Reserved -# 32768- Reserved for local use +0 0 Reserved +1 1 Evergreen broadleaved forest +2 2 Deciduous broadleaved closed forest +3 3 Deciduous broadleaved open forest +4 4 Evergreen needle-leaf forest +5 5 Deciduous needle-leaf forest +6 6 Mixed leaf trees +7 7 Freshwater flooded trees +8 8 Saline water flooded trees +9 9 Mosaic tree/natural vegetation +10 10 Burnt tree cover +11 11 Evergreen shrubs closed-open +12 12 Deciduous shrubs closed-open +13 13 Herbaceous vegetation closed-open +14 14 Sparse herbaceous or grass +15 15 Flooded shrubs or herbaceous +16 16 Cultivated and managed areas +17 17 Mosaic crop/tree/natural vegetation +18 18 Mosaic crop/shrub/grass +19 19 Bare areas +20 20 Water +21 21 Snow and ice +22 22 Artificial surface +23 23 Ocean +24 24 Irrigated croplands +25 25 Rainfed croplands +26 26 Mosaic cropland (50-70%) - vegetation (20-50%) +27 27 Mosaic vegetation (50-70%) - cropland (20-50%) +28 28 Closed broadleaved evergreen forest +29 29 Closed needle-leaved evergreen forest +30 30 Open needle-leaved deciduous forest +31 31 Mixed broadleaved and needle-leaved forest +32 32 Mosaic shrubland (50-70%) - grassland (20-50%) +33 33 Mosaic grassland (50-70%) - shrubland (20-50%) +34 34 Closed to open shrubland +35 35 Sparse vegetation +36 36 Closed to open forest regularly flooded +37 37 Closed forest or shrubland permanently flooded +38 38 Closed to open grassland regularly flooded +39 39 Undefined +# 40-32767 Reserved +# 32768- Reserved for local use diff --git a/definitions/grib2/tables/17/4.3.table b/definitions/grib2/tables/17/4.3.table index f205ea0c2..bcf8102a1 100644 --- a/definitions/grib2/tables/17/4.3.table +++ b/definitions/grib2/tables/17/4.3.table @@ -1,22 +1,22 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -12 12 Post-processed analysis -13 13 Post-processed forecast -14 14 Nowcast -15 15 Hindcast -16 16 Physical retrieval -17 17 Regression analysis -# 18-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +12 12 Post-processed analysis +13 13 Post-processed forecast +14 14 Nowcast +15 15 Hindcast +16 16 Physical retrieval +17 17 Regression analysis +# 18-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.4.table b/definitions/grib2/tables/17/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/17/4.4.table +++ b/definitions/grib2/tables/17/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.5.table b/definitions/grib2/tables/17/4.5.table index e70520c3b..c2771c9c6 100644 --- a/definitions/grib2/tables/17/4.5.table +++ b/definitions/grib2/tables/17/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface (-) 2 2 Cloud base level (-) 3 3 Level of cloud tops (-) @@ -16,11 +16,11 @@ 14 14 Level of free convection (LFC) 15 15 Convective condensation level (CCL) 16 16 Level of neutral buoyancy or equilibrium level (LNB) -# 17-19 Reserved +# 17-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -29,19 +29,19 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level (-) -112 112 Reserved -113 113 Logarithmic hybrid level +112 112 Reserved +113 113 Logarithmic hybrid level 114 114 Snow level (Numeric) -# 115-116 Reserved +# 115-116 Reserved 117 117 Mixed layer depth (m) 118 hhl Hybrid height level (-) 119 hpl Hybrid pressure level (-) -# 120-149 Reserved -150 150 Generalized vertical height coordinate +# 120-149 Reserved +150 150 Generalized vertical height coordinate 151 sol Soil level (Numeric) -# 152-159 Reserved +# 152-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom (-) @@ -50,7 +50,7 @@ 165 165 Bottom of sediment layer penetrated by thermal wave (-) 166 sfc Mixing layer (-) 167 167 Bottom of root zone (-) -# 168-173 Reserved +# 168-173 Reserved 174 sfc Top surface of ice on sea, lake or river 175 175 Top surface of ice, under snow cover, on sea, lake or river 176 176 Bottom surface (underside) ice on sea, lake or river @@ -62,6 +62,6 @@ 182 182 Grid tile water fraction as a model surface 183 183 Grid tile ice fraction on sea, lake or river as a model surface 184 184 Grid tile glacier ice and inland ice fraction as a model surface -# 185-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 185-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.6.table b/definitions/grib2/tables/17/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/17/4.6.table +++ b/definitions/grib2/tables/17/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.7.table b/definitions/grib2/tables/17/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/17/4.7.table +++ b/definitions/grib2/tables/17/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.8.table b/definitions/grib2/tables/17/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/17/4.8.table +++ b/definitions/grib2/tables/17/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.9.table b/definitions/grib2/tables/17/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/17/4.9.table +++ b/definitions/grib2/tables/17/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/4.91.table b/definitions/grib2/tables/17/4.91.table index 44cf25f44..ae31ed61c 100644 --- a/definitions/grib2/tables/17/4.91.table +++ b/definitions/grib2/tables/17/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit -11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/17/5.0.table b/definitions/grib2/tables/17/5.0.table index 5ec77ed0f..2795336df 100644 --- a/definitions/grib2/tables/17/5.0.table +++ b/definitions/grib2/tables/17/5.0.table @@ -1,23 +1,23 @@ # Code table 5.0 - Data representation template number -0 0 Grid point data - simple packing -1 1 Matrix value at grid point - simple packing -2 2 Grid point data - complex packing -3 3 Grid point data - complex packing and spatial differencing -4 4 Grid point data - IEEE floating point data -40 40 Grid point data - JPEG 2000 code stream format -41 41 Grid point data - Portable Network Graphics (PNG) -# 42-49 Reserved -50 50 Spectral data - simple packing -51 51 Spherical harmonics data - complex packing -# 52-60 Reserved -61 61 Grid point data - simple packing with logarithm pre-processing -# 62-199 Reserved -200 200 Run length packing with level values -# 201-49151 Reserved -# 49152-65534 Reserved for local use +0 0 Grid point data - simple packing +1 1 Matrix value at grid point - simple packing +2 2 Grid point data - complex packing +3 3 Grid point data - complex packing and spatial differencing +4 4 Grid point data - IEEE floating point data +40 40 Grid point data - JPEG 2000 code stream format +41 41 Grid point data - Portable Network Graphics (PNG) +# 42-49 Reserved +50 50 Spectral data - simple packing +51 51 Spherical harmonics data - complex packing +# 52-60 Reserved +61 61 Grid point data - simple packing with logarithm pre-processing +# 62-199 Reserved +200 200 Run length packing with level values +# 201-49151 Reserved +# 49152-65534 Reserved for local use 40000 40000 JPEG2000 Packing 40010 40010 PNG pacling 50000 50000 Sperical harmonics ieee packing 50001 50001 Second order packing 50002 50002 Second order packing -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/17/5.1.table b/definitions/grib2/tables/17/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/17/5.1.table +++ b/definitions/grib2/tables/17/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/5.2.table b/definitions/grib2/tables/17/5.2.table index 40586a131..d77fdf4e7 100644 --- a/definitions/grib2/tables/17/5.2.table +++ b/definitions/grib2/tables/17/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/5.3.table b/definitions/grib2/tables/17/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/17/5.3.table +++ b/definitions/grib2/tables/17/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/5.4.table b/definitions/grib2/tables/17/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/17/5.4.table +++ b/definitions/grib2/tables/17/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/5.40.table b/definitions/grib2/tables/17/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/17/5.40.table +++ b/definitions/grib2/tables/17/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/17/5.5.table b/definitions/grib2/tables/17/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/17/5.5.table +++ b/definitions/grib2/tables/17/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/5.6.table b/definitions/grib2/tables/17/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/17/5.6.table +++ b/definitions/grib2/tables/17/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/17/5.7.table b/definitions/grib2/tables/17/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/17/5.7.table +++ b/definitions/grib2/tables/17/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/17/6.0.table b/definitions/grib2/tables/17/6.0.table index 2a29aa285..a8f30f5a4 100644 --- a/definitions/grib2/tables/17/6.0.table +++ b/definitions/grib2/tables/17/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator -0 0 A bit map applies to this product and is specified in this Section +0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/18/0.0.table b/definitions/grib2/tables/18/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/18/0.0.table +++ b/definitions/grib2/tables/18/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/1.0.table b/definitions/grib2/tables/18/1.0.table index 8829485d9..0e6f26f8e 100644 --- a/definitions/grib2/tables/18/1.0.table +++ b/definitions/grib2/tables/18/1.0.table @@ -1,22 +1,22 @@ # Code table 1.0 - GRIB master tables version number -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 -6 6 Version implemented on 15 September 2010 -7 7 Version implemented on 4 May 2011 -8 8 Version implemented on 2 November 2011 -9 9 Version implemented on 2 May 2012 -10 10 Version implemented on 7 November 2012 -11 11 Version implemented on 8 May 2013 -12 12 Version implemented on 14 November 2013 -13 13 Version implemented on 7 May 2014 -14 14 Version implemented on 5 November 2014 -15 15 Version implemented on 6 May 2015 -16 16 Version implemented on 11 November 2015 -17 17 Version implemented on 4 May 2016 +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Version implemented on 2 May 2012 +10 10 Version implemented on 7 November 2012 +11 11 Version implemented on 8 May 2013 +12 12 Version implemented on 14 November 2013 +13 13 Version implemented on 7 May 2014 +14 14 Version implemented on 5 November 2014 +15 15 Version implemented on 6 May 2015 +16 16 Version implemented on 11 November 2015 +17 17 Version implemented on 4 May 2016 18 18 Version implemented on 2 November 2016 19 19 Pre-operational to be implemented by next amendment # 20-254 Future versions diff --git a/definitions/grib2/tables/18/1.1.table b/definitions/grib2/tables/18/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/18/1.1.table +++ b/definitions/grib2/tables/18/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/18/1.2.table b/definitions/grib2/tables/18/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/18/1.2.table +++ b/definitions/grib2/tables/18/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/1.3.table b/definitions/grib2/tables/18/1.3.table index 0c95269d5..c1a9a7b9d 100644 --- a/definitions/grib2/tables/18/1.3.table +++ b/definitions/grib2/tables/18/1.3.table @@ -1,14 +1,14 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products -4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products +4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) -6 6 S2S operational products -7 7 S2S test products +6 6 S2S operational products +7 7 S2S test products 8 8 Uncertainties in Ensembles of Regional ReAnalyses project (UERRA) 9 9 Uncertainties in Ensembles of Regional ReAnalyses project test (UERRA) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/1.4.table b/definitions/grib2/tables/18/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/18/1.4.table +++ b/definitions/grib2/tables/18/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/18/1.5.table b/definitions/grib2/tables/18/1.5.table index b2cf9f087..533111959 100644 --- a/definitions/grib2/tables/18/1.5.table +++ b/definitions/grib2/tables/18/1.5.table @@ -1,7 +1,7 @@ # Code table 1.5 - Identification template number -0 0 Calendar definition -1 1 Paleontological offset -2 2 Calendar definition and paleontological offset -# 3-32767 Reserved -# 32768-65534 Reserved for local use -65535 65535 Missing +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/18/1.6.table b/definitions/grib2/tables/18/1.6.table index 5db921990..bd46899a7 100644 --- a/definitions/grib2/tables/18/1.6.table +++ b/definitions/grib2/tables/18/1.6.table @@ -1,8 +1,8 @@ # Code table 1.6 - Type of calendar -0 0 Gregorian -1 1 360-day -2 2 365-day -3 3 Proleptic Gregorian -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/3.0.table b/definitions/grib2/tables/18/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/18/3.0.table +++ b/definitions/grib2/tables/18/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/18/3.10.table b/definitions/grib2/tables/18/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/18/3.10.table +++ b/definitions/grib2/tables/18/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/18/3.11.table b/definitions/grib2/tables/18/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/18/3.11.table +++ b/definitions/grib2/tables/18/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/18/3.15.table b/definitions/grib2/tables/18/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/18/3.15.table +++ b/definitions/grib2/tables/18/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/3.2.table b/definitions/grib2/tables/18/3.2.table index 9238dc2a7..b9574a424 100644 --- a/definitions/grib2/tables/18/3.2.table +++ b/definitions/grib2/tables/18/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/3.20.table b/definitions/grib2/tables/18/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/18/3.20.table +++ b/definitions/grib2/tables/18/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/3.21.table b/definitions/grib2/tables/18/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/18/3.21.table +++ b/definitions/grib2/tables/18/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/3.3.table b/definitions/grib2/tables/18/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/18/3.3.table +++ b/definitions/grib2/tables/18/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/18/3.4.table b/definitions/grib2/tables/18/3.4.table index 897b813d7..43835c014 100644 --- a/definitions/grib2/tables/18/3.4.table +++ b/definitions/grib2/tables/18/3.4.table @@ -1,17 +1,17 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -5 0 Points within odd rows are not offset in i (x) direction -5 1 Points within odd rows are offset by Di/2 in i (x) direction -6 0 Points within even rows are not offset in i (x) direction -6 1 Points within even rows are offset by Di/2 in i (x) direction -7 0 Points are not offset in j (y) direction -7 1 Points are offset by Dj/2 in j (y) direction -8 0 Rows have Ni grid points and columns have Nj grid points -8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +5 0 Points within odd rows are not offset in i (x) direction +5 1 Points within odd rows are offset by Di/2 in i (x) direction +6 0 Points within even rows are not offset in i (x) direction +6 1 Points within even rows are offset by Di/2 in i (x) direction +7 0 Points are not offset in j (y) direction +7 1 Points are offset by Dj/2 in j (y) direction +8 0 Rows have Ni grid points and columns have Nj grid points +8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction diff --git a/definitions/grib2/tables/18/3.5.table b/definitions/grib2/tables/18/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/18/3.5.table +++ b/definitions/grib2/tables/18/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/18/3.7.table b/definitions/grib2/tables/18/3.7.table index 0a7d6efde..34c0de085 100644 --- a/definitions/grib2/tables/18/3.7.table +++ b/definitions/grib2/tables/18/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 see separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/18/3.8.table b/definitions/grib2/tables/18/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/18/3.8.table +++ b/definitions/grib2/tables/18/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/3.9.table b/definitions/grib2/tables/18/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/18/3.9.table +++ b/definitions/grib2/tables/18/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/18/4.0.table b/definitions/grib2/tables/18/4.0.table index 5ad2ed89a..aceff01af 100644 --- a/definitions/grib2/tables/18/4.0.table +++ b/definitions/grib2/tables/18/4.0.table @@ -1,72 +1,72 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time -8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time # 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data # 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol -46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol 49 49 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -# 50 Reserved -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +# 50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time # 52 Reserved -53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time -54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters -55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time 56 56 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters (deprecated) -57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function +57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function 58 58 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function 59 59 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters (corrected version of template 4.56) -60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval +60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval # 62-69 Reserved 70 70 Post-processing analysis or forecast at a horizontal level or in a horizontal layer at a point in time 71 71 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time 72 72 Post-processing average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval 73 73 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval # 74-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval # 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/18/4.1.0.table b/definitions/grib2/tables/18/4.1.0.table index 04cfd7802..df58636d6 100644 --- a/definitions/grib2/tables/18/4.1.0.table +++ b/definitions/grib2/tables/18/4.1.0.table @@ -1,27 +1,27 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.1.1.table b/definitions/grib2/tables/18/4.1.1.table index 7b22b6fed..05a854da0 100644 --- a/definitions/grib2/tables/18/4.1.1.table +++ b/definitions/grib2/tables/18/4.1.1.table @@ -1,7 +1,7 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.1.10.table b/definitions/grib2/tables/18/4.1.10.table index a9b20eb9c..88d3c8743 100644 --- a/definitions/grib2/tables/18/4.1.10.table +++ b/definitions/grib2/tables/18/4.1.10.table @@ -1,10 +1,10 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Subsurface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Subsurface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.1.2.table b/definitions/grib2/tables/18/4.1.2.table index 5b488fe9e..e74126645 100644 --- a/definitions/grib2/tables/18/4.1.2.table +++ b/definitions/grib2/tables/18/4.1.2.table @@ -1,9 +1,9 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.1.3.table b/definitions/grib2/tables/18/4.1.3.table index 7bf60d4a7..ba38c9301 100644 --- a/definitions/grib2/tables/18/4.1.3.table +++ b/definitions/grib2/tables/18/4.1.3.table @@ -1,11 +1,11 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Image format products -1 1 Quantitative products -2 2 Cloud properties -3 3 Flight rule conditions -4 4 Volcanic ash -5 5 Sea-surface temperature -6 6 Solar radiation -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +2 2 Cloud properties +3 3 Flight rule conditions +4 4 Volcanic ash +5 5 Sea-surface temperature +6 6 Solar radiation +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.10.table b/definitions/grib2/tables/18/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/18/4.10.table +++ b/definitions/grib2/tables/18/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/18/4.11.table b/definitions/grib2/tables/18/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/18/4.11.table +++ b/definitions/grib2/tables/18/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.12.table b/definitions/grib2/tables/18/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/18/4.12.table +++ b/definitions/grib2/tables/18/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.13.table b/definitions/grib2/tables/18/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/18/4.13.table +++ b/definitions/grib2/tables/18/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.14.table b/definitions/grib2/tables/18/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/18/4.14.table +++ b/definitions/grib2/tables/18/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.15.table b/definitions/grib2/tables/18/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/18/4.15.table +++ b/definitions/grib2/tables/18/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.0.table b/definitions/grib2/tables/18/4.2.0.0.table index 7201a8667..83b3e8ef1 100644 --- a/definitions/grib2/tables/18/4.2.0.0.table +++ b/definitions/grib2/tables/18/4.2.0.0.table @@ -29,6 +29,6 @@ 27 27 Wet-bulb temperature (K) 28 28 Unbalanced component of temperature (K) 29 29 Temperature advection (K s-1) -# 30-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 30-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.1.table b/definitions/grib2/tables/18/4.2.0.1.table index c38d6a053..7d43684d3 100644 --- a/definitions/grib2/tables/18/4.2.0.1.table +++ b/definitions/grib2/tables/18/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,7 +86,7 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) @@ -118,6 +118,6 @@ 118 118 Unbalanced component of specific humidity (kg kg-1) 119 119 Unbalanced component of specific cloud liquid water content (kg kg-1) 120 120 Unbalanced component of specific cloud ice water content (kg kg-1) -# 121-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 121-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.13.table b/definitions/grib2/tables/18/4.2.0.13.table index 5086101ad..3f5c30675 100644 --- a/definitions/grib2/tables/18/4.2.0.13.table +++ b/definitions/grib2/tables/18/4.2.0.13.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.14.table b/definitions/grib2/tables/18/4.2.0.14.table index 215884737..97fb38c8b 100644 --- a/definitions/grib2/tables/18/4.2.0.14.table +++ b/definitions/grib2/tables/18/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.15.table b/definitions/grib2/tables/18/4.2.0.15.table index dfbc4d12f..8df082466 100644 --- a/definitions/grib2/tables/18/4.2.0.15.table +++ b/definitions/grib2/tables/18/4.2.0.15.table @@ -16,6 +16,6 @@ 14 14 Reflectivity of hail (dB) 15 15 Hybrid scan reflectivity (dB) 16 16 Hybrid scan reflectivity height (m) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.16.table b/definitions/grib2/tables/18/4.2.0.16.table index 0c240a853..9499d9333 100644 --- a/definitions/grib2/tables/18/4.2.0.16.table +++ b/definitions/grib2/tables/18/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.18.table b/definitions/grib2/tables/18/4.2.0.18.table index 9d106f419..9ca6db61e 100644 --- a/definitions/grib2/tables/18/4.2.0.18.table +++ b/definitions/grib2/tables/18/4.2.0.18.table @@ -8,7 +8,7 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) @@ -18,6 +18,6 @@ 16 16 Height of maximum air concentration (m) 17 17 Column-integrated air concentration (Bq m-2) 18 18 Column-averaged air concentration in layer (Bq m-3) -# 19-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 19-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.19.table b/definitions/grib2/tables/18/4.2.0.19.table index 8705082c5..e4db36249 100644 --- a/definitions/grib2/tables/18/4.2.0.19.table +++ b/definitions/grib2/tables/18/4.2.0.19.table @@ -31,6 +31,6 @@ 29 29 Clear air turbulence (CAT) (m2/3 s-1) 30 30 Eddy dissipation parameter (m2/3 s-1) 31 31 Maximum of Eddy dissipation parameter in layer (m2/3 s-1) -# 32-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 32-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.190.table b/definitions/grib2/tables/18/4.2.0.190.table index de621a924..a0d6ba0ac 100644 --- a/definitions/grib2/tables/18/4.2.0.190.table +++ b/definitions/grib2/tables/18/4.2.0.190.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.191.table b/definitions/grib2/tables/18/4.2.0.191.table index e3bba0ebe..b3a7092ea 100644 --- a/definitions/grib2/tables/18/4.2.0.191.table +++ b/definitions/grib2/tables/18/4.2.0.191.table @@ -3,6 +3,6 @@ 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.2.table b/definitions/grib2/tables/18/4.2.0.2.table index 5446262e6..8a70b2591 100644 --- a/definitions/grib2/tables/18/4.2.0.2.table +++ b/definitions/grib2/tables/18/4.2.0.2.table @@ -46,6 +46,6 @@ 44 44 Geostrophic wind speed (m s-1) 45 45 Unbalanced component of divergence (s-1) 46 46 Vorticity advection (s-2) -# 47-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 47-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.20.table b/definitions/grib2/tables/18/4.2.0.20.table index efc427a19..bbdeef5b1 100644 --- a/definitions/grib2/tables/18/4.2.0.20.table +++ b/definitions/grib2/tables/18/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -29,7 +29,7 @@ 61 61 Maximum of mass density in layer (kg m-3) 62 62 Height of maximum mass density (m) 63 63 Column-averaged mass density in layer (kg m-3) -# 64-99 Reserved +# 64-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -42,6 +42,6 @@ 109 109 Aerosol lidar extinction from satellite (/m) 110 110 Aerosol lidar extinction from the ground (/m) 111 111 Angstrom exponent (Numeric) -# 112-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 112-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.3.table b/definitions/grib2/tables/18/4.2.0.3.table index 34941dcab..52c421b97 100644 --- a/definitions/grib2/tables/18/4.2.0.3.table +++ b/definitions/grib2/tables/18/4.2.0.3.table @@ -31,6 +31,6 @@ 29 29 Updraught detrainment rate (kg m-3 s-1) 30 30 Downdraught detrainment rate (kg m-3 s-1) 31 31 Unbalanced component of logarithm of surface pressure (-) -# 32-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 32-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.4.table b/definitions/grib2/tables/18/4.2.0.4.table index 0a5ded2b5..f97270456 100644 --- a/definitions/grib2/tables/18/4.2.0.4.table +++ b/definitions/grib2/tables/18/4.2.0.4.table @@ -14,11 +14,11 @@ 12 12 Downward UV radiation (W m-2) 13 13 Direct short-wave radiation flux (W m-2) 14 14 Diffuse short-wave radiation flux (W m-2) -# 15-49 Reserved +# 15-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) 52 52 Downward short-wave radiation flux, clear sky (W m-2) 53 53 Upward short-wave radiation flux, clear sky (W m-2) -# 54-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 54-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.5.table b/definitions/grib2/tables/18/4.2.0.5.table index 4550220b6..ddfa634ce 100644 --- a/definitions/grib2/tables/18/4.2.0.5.table +++ b/definitions/grib2/tables/18/4.2.0.5.table @@ -8,6 +8,6 @@ 6 6 Net long-wave radiation flux, clear sky (W m-2) 7 7 Brightness temperature (K) 8 8 Downward long-wave radiation flux, clear sky (W m-2) -# 9-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 9-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.6.table b/definitions/grib2/tables/18/4.2.0.6.table index 4cec0c8aa..0450ec194 100644 --- a/definitions/grib2/tables/18/4.2.0.6.table +++ b/definitions/grib2/tables/18/4.2.0.6.table @@ -40,10 +40,10 @@ 38 38 Mass density of cloud droplets (kg m-3) 39 39 Mass density of cloud ice (kg m-3) 40 40 Mass density of convective cloud water droplets (kg m-3) -# 41-46 Reserved +# 41-46 Reserved 47 47 Volume fraction of cloud water droplets (Numeric) 48 48 Volume fraction of cloud ice particles (Numeric) 49 49 Volume fraction of cloud (ice and/or water) (Numeric) -# 50-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 50-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.0.7.table b/definitions/grib2/tables/18/4.2.0.7.table index 6d0d87a46..3e653431f 100644 --- a/definitions/grib2/tables/18/4.2.0.7.table +++ b/definitions/grib2/tables/18/4.2.0.7.table @@ -13,11 +13,11 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraught helicity (m2 s-2) 16 16 Bulk Richardson number (Numeric) 17 17 Gradient Richardson number (Numeric) 18 18 Flux Richardson number (Numeric) -# 19-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 19-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.1.0.table b/definitions/grib2/tables/18/4.2.1.0.table index bcd849c2e..a2660f4f3 100644 --- a/definitions/grib2/tables/18/4.2.1.0.table +++ b/definitions/grib2/tables/18/4.2.1.0.table @@ -16,6 +16,6 @@ 14 14 Upstream accumulated precipitation (kg m-2) 15 15 Upstream accumulated snow melt (kg m-2) 16 16 Percolation rate (kg m-2 s-1) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.1.1.table b/definitions/grib2/tables/18/4.2.1.1.table index b488eb0bd..171da3958 100644 --- a/definitions/grib2/tables/18/4.2.1.1.table +++ b/definitions/grib2/tables/18/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.10.0.table b/definitions/grib2/tables/18/4.2.10.0.table index 095f51bdf..3611abd9a 100644 --- a/definitions/grib2/tables/18/4.2.10.0.table +++ b/definitions/grib2/tables/18/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (/s) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.10.1.table b/definitions/grib2/tables/18/4.2.10.1.table index 5959bfa28..f0a073c00 100644 --- a/definitions/grib2/tables/18/4.2.10.1.table +++ b/definitions/grib2/tables/18/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.10.191.table b/definitions/grib2/tables/18/4.2.10.191.table index 524929e78..1ebf85006 100644 --- a/definitions/grib2/tables/18/4.2.10.191.table +++ b/definitions/grib2/tables/18/4.2.10.191.table @@ -1,8 +1,8 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -2 2 Reserved +2 2 Reserved 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.10.2.table b/definitions/grib2/tables/18/4.2.10.2.table index 6797062ac..4633bad4f 100644 --- a/definitions/grib2/tables/18/4.2.10.2.table +++ b/definitions/grib2/tables/18/4.2.10.2.table @@ -12,6 +12,6 @@ 10 10 Zonal vector component of vertically integrated ice internal pressure (Pa m) 11 11 Meridional vector component of vertically integrated ice internal pressure (Pa m) 12 12 Compressive ice strength (N/m) -# 13-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.10.3.table b/definitions/grib2/tables/18/4.2.10.3.table index de7afd61c..b01d7ae46 100644 --- a/definitions/grib2/tables/18/4.2.10.3.table +++ b/definitions/grib2/tables/18/4.2.10.3.table @@ -2,6 +2,6 @@ 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) 2 2 Heat exchange coefficient (-) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.10.4.table b/definitions/grib2/tables/18/4.2.10.4.table index 54774f1b7..d5615ae26 100644 --- a/definitions/grib2/tables/18/4.2.10.4.table +++ b/definitions/grib2/tables/18/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2/s) 6 6 Ocean vertical momentum diffusivity (m2/s) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (/m) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.2.0.table b/definitions/grib2/tables/18/4.2.2.0.table index 81548840c..b253cac22 100644 --- a/definitions/grib2/tables/18/4.2.2.0.table +++ b/definitions/grib2/tables/18/4.2.2.0.table @@ -38,6 +38,6 @@ 36 36 Tile fraction (Proportion) 37 37 Tile percentage (%) 38 38 Soil volumetric ice content (water equivalent) (m3 m-3) -# 39-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 39-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.2.3.table b/definitions/grib2/tables/18/4.2.2.3.table index 690fab42b..2674e9f42 100644 --- a/definitions/grib2/tables/18/4.2.2.3.table +++ b/definitions/grib2/tables/18/4.2.2.3.table @@ -27,6 +27,6 @@ 25 25 Snow depth at elevation bands (kg m-2) 26 26 Soil heat flux (W m-2) 27 27 Soil depth (m) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.2.4.table b/definitions/grib2/tables/18/4.2.2.4.table index bb54fac22..ceb761557 100644 --- a/definitions/grib2/tables/18/4.2.2.4.table +++ b/definitions/grib2/tables/18/4.2.2.4.table @@ -11,6 +11,6 @@ 9 9 Initial Fire Spread Index (Canadian Forest Service) (Numeric) 10 10 Fire Buildup Index (Canadian Forest Service) (Numeric) 11 11 Fire Daily Severity Rating (Canadian Forest Service) (Numeric) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.3.0.table b/definitions/grib2/tables/18/4.2.3.0.table index c0ffa29f5..80a829673 100644 --- a/definitions/grib2/tables/18/4.2.3.0.table +++ b/definitions/grib2/tables/18/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.2.3.1.table b/definitions/grib2/tables/18/4.2.3.1.table index 8e0793fe0..04cdde1f1 100644 --- a/definitions/grib2/tables/18/4.2.3.1.table +++ b/definitions/grib2/tables/18/4.2.3.1.table @@ -17,16 +17,16 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-26 Reserved +23 23 Angstrom coefficient +# 24-26 Reserved 27 27 Bidirectional reflectance factor (Numeric) 28 28 Brightness temperature (K) 29 29 Scaled radiance (Numeric) -# 30-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 30-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.201.table b/definitions/grib2/tables/18/4.201.table index 47f1b486f..fa173c4e0 100644 --- a/definitions/grib2/tables/18/4.201.table +++ b/definitions/grib2/tables/18/4.201.table @@ -1,15 +1,15 @@ # Code table 4.201 - Precipitation type -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow -6 6 Wet snow -7 7 Mixture of rain and snow -8 8 Ice pellets -9 9 Graupel -10 10 Hail -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +6 6 Wet snow +7 7 Mixture of rain and snow +8 8 Ice pellets +9 9 Graupel +10 10 Hail +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.202.table b/definitions/grib2/tables/18/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/18/4.202.table +++ b/definitions/grib2/tables/18/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.203.table b/definitions/grib2/tables/18/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/18/4.203.table +++ b/definitions/grib2/tables/18/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.204.table b/definitions/grib2/tables/18/4.204.table index 481372936..8e0be1f8c 100644 --- a/definitions/grib2/tables/18/4.204.table +++ b/definitions/grib2/tables/18/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (6-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (6-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.205.table b/definitions/grib2/tables/18/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/18/4.205.table +++ b/definitions/grib2/tables/18/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.206.table b/definitions/grib2/tables/18/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/18/4.206.table +++ b/definitions/grib2/tables/18/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.207.table b/definitions/grib2/tables/18/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/18/4.207.table +++ b/definitions/grib2/tables/18/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.208.table b/definitions/grib2/tables/18/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/18/4.208.table +++ b/definitions/grib2/tables/18/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.209.table b/definitions/grib2/tables/18/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/18/4.209.table +++ b/definitions/grib2/tables/18/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.210.table b/definitions/grib2/tables/18/4.210.table index c01f4bcca..791878469 100644 --- a/definitions/grib2/tables/18/4.210.table +++ b/definitions/grib2/tables/18/4.210.table @@ -1,6 +1,6 @@ # Code table 4.210 - Contrail intensity 0 0 Contrail not present 1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.211.table b/definitions/grib2/tables/18/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/18/4.211.table +++ b/definitions/grib2/tables/18/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.212.table b/definitions/grib2/tables/18/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/18/4.212.table +++ b/definitions/grib2/tables/18/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.213.table b/definitions/grib2/tables/18/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/18/4.213.table +++ b/definitions/grib2/tables/18/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.215.table b/definitions/grib2/tables/18/4.215.table index 034db72be..7888772d5 100644 --- a/definitions/grib2/tables/18/4.215.table +++ b/definitions/grib2/tables/18/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.216.table b/definitions/grib2/tables/18/4.216.table index 5d1460cef..b51b358f4 100644 --- a/definitions/grib2/tables/18/4.216.table +++ b/definitions/grib2/tables/18/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain -# 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 0-90 Elevation in increments of 100 m +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/18/4.217.table b/definitions/grib2/tables/18/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/18/4.217.table +++ b/definitions/grib2/tables/18/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.218.table b/definitions/grib2/tables/18/4.218.table index 7e3a69578..b5b15150b 100644 --- a/definitions/grib2/tables/18/4.218.table +++ b/definitions/grib2/tables/18/4.218.table @@ -1,44 +1,44 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation/crops -15 15 Permanent snow/ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -19 19 Warm liquid water cloud -20 20 Supercooled liquid water cloud -21 21 Mixed-phase cloud -22 22 Optically thin ice cloud -23 23 Optically thick ice cloud -24 24 Multilayered cloud -# 25-96 Reserved -97 97 Snow/ice on land -98 98 Snow/ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud/fog/Stratus -102 102 Low cloud/Stratocumulus -103 103 Low cloud/unknown type -104 104 Medium cloud/Nimbostratus -105 105 Medium cloud/Altostratus -106 106 Medium cloud/unknown type -107 107 High cloud/Cumulus -108 108 High cloud/Cirrus -109 109 High cloud/unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation/crops +15 15 Permanent snow/ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +19 19 Warm liquid water cloud +20 20 Supercooled liquid water cloud +21 21 Mixed-phase cloud +22 22 Optically thin ice cloud +23 23 Optically thick ice cloud +24 24 Multilayered cloud +# 25-96 Reserved +97 97 Snow/ice on land +98 98 Snow/ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud/fog/Stratus +102 102 Low cloud/Stratocumulus +103 103 Low cloud/unknown type +104 104 Medium cloud/Nimbostratus +105 105 Medium cloud/Altostratus +106 106 Medium cloud/unknown type +107 107 High cloud/Cumulus +108 108 High cloud/Cirrus +109 109 High cloud/unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.219.table b/definitions/grib2/tables/18/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/18/4.219.table +++ b/definitions/grib2/tables/18/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.220.table b/definitions/grib2/tables/18/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/18/4.220.table +++ b/definitions/grib2/tables/18/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.221.table b/definitions/grib2/tables/18/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/18/4.221.table +++ b/definitions/grib2/tables/18/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.222.table b/definitions/grib2/tables/18/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/18/4.222.table +++ b/definitions/grib2/tables/18/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.223.table b/definitions/grib2/tables/18/4.223.table index f0deb076a..572c4e7a8 100644 --- a/definitions/grib2/tables/18/4.223.table +++ b/definitions/grib2/tables/18/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/18/4.224.table b/definitions/grib2/tables/18/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/18/4.224.table +++ b/definitions/grib2/tables/18/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/18/4.227.table b/definitions/grib2/tables/18/4.227.table index 27c76553d..48c3b7633 100644 --- a/definitions/grib2/tables/18/4.227.table +++ b/definitions/grib2/tables/18/4.227.table @@ -1,9 +1,9 @@ # Code table 4.227 - Icing scenario (weather/cloud classification) -0 0 None -1 1 General -2 2 Convective -3 3 Stratiform -4 4 Freezing -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/18/4.234.table b/definitions/grib2/tables/18/4.234.table index 816541ce9..3b05b4515 100644 --- a/definitions/grib2/tables/18/4.234.table +++ b/definitions/grib2/tables/18/4.234.table @@ -1,21 +1,21 @@ # Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in product definition template 4.53 or 4.54) -1 1 Crops, mixed farming -2 2 Short grass -3 3 Evergreen needleleaf trees -4 4 Deciduous needleleaf trees -5 5 Deciduous broadleaf trees -6 6 Evergreen broadleaf trees -7 7 Tall grass -8 8 Desert -9 9 Tundra -10 10 Irrigated crops -11 11 Semidesert -12 12 Ice caps and glaciers -13 13 Bogs and marshes -14 14 Inland water -15 15 Ocean -16 16 Evergreen shrubs -17 17 Deciduous shrubs -18 18 Mixed forest -19 19 Interrupted forest -20 20 Water and land mixtures +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/18/4.236.table b/definitions/grib2/tables/18/4.236.table index fbe093ce9..9c58b488c 100644 --- a/definitions/grib2/tables/18/4.236.table +++ b/definitions/grib2/tables/18/4.236.table @@ -1,8 +1,8 @@ # Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in product definition template 4.53 or 4.54) -1 1 Coarse -2 2 Medium -3 3 Medium-fine -4 4 Fine -5 5 Very-fine -6 6 Organic -7 7 Tropical-organic +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/18/4.240.table b/definitions/grib2/tables/18/4.240.table index 7313e6eec..986557483 100644 --- a/definitions/grib2/tables/18/4.240.table +++ b/definitions/grib2/tables/18/4.240.table @@ -1,12 +1,12 @@ # Code table 4.240 - Type of distribution function -0 0 No specific distribution function given -1 1 Delta functions with spatially variable concentration and fixed diameters Dl (p1) in metre -2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg -3 3 Gaussian (normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) -4 4 Gaussian (normal) distribution with spatially variable concentration, mean diameter and variance -5 5 Log-normal distribution with spatially variable number density, mean diameter and variance -6 6 Log-normal distribution with spatially variable number density, mean diameter and fixed variance(p1) +0 0 No specific distribution function given +1 1 Delta functions with spatially variable concentration and fixed diameters Dl (p1) in metre +2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg +3 3 Gaussian (normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) +4 4 Gaussian (normal) distribution with spatially variable concentration, mean diameter and variance +5 5 Log-normal distribution with spatially variable number density, mean diameter and variance +6 6 Log-normal distribution with spatially variable number density, mean diameter and fixed variance(p1) 7 7 Log-normal distribution with spatially variable number density and mass density and fixed variance(p1) and fixed particle density(p2) -# 8-49151 Reserved -# 49152-65534 Reserved for local use -65535 65535 Missing value +# 8-49151 Reserved +# 49152-65534 Reserved for local use +65535 65535 Missing value diff --git a/definitions/grib2/tables/18/4.241.table b/definitions/grib2/tables/18/4.241.table index a037b4ba5..5ea7f775a 100644 --- a/definitions/grib2/tables/18/4.241.table +++ b/definitions/grib2/tables/18/4.241.table @@ -1,9 +1,9 @@ # Code table 4.241 - Coverage attributes -0 0 Undefined -1 1 Unmodified -2 2 Snow covered -3 3 Flooded -4 4 Ice covered -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Undefined +1 1 Unmodified +2 2 Snow covered +3 3 Flooded +4 4 Ice covered +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/18/4.242.table b/definitions/grib2/tables/18/4.242.table index 083f88c29..f6865957c 100644 --- a/definitions/grib2/tables/18/4.242.table +++ b/definitions/grib2/tables/18/4.242.table @@ -1,7 +1,7 @@ # Code table 4.242 - Tile classification -0 0 Reserved -1 1 Land use classes according to ESA-GlobCover GCV2009 -2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Reserved +1 1 Land use classes according to ESA-GlobCover GCV2009 +2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/18/4.243.table b/definitions/grib2/tables/18/4.243.table index b39053311..24d21b719 100644 --- a/definitions/grib2/tables/18/4.243.table +++ b/definitions/grib2/tables/18/4.243.table @@ -1,43 +1,43 @@ # Code table 4.243 - Tile class -0 0 Reserved -1 1 Evergreen broadleaved forest -2 2 Deciduous broadleaved closed forest -3 3 Deciduous broadleaved open forest -4 4 Evergreen needle-leaf forest -5 5 Deciduous needle-leaf forest -6 6 Mixed leaf trees -7 7 Freshwater flooded trees -8 8 Saline water flooded trees -9 9 Mosaic tree/natural vegetation -10 10 Burnt tree cover -11 11 Evergreen shrubs closed-open -12 12 Deciduous shrubs closed-open -13 13 Herbaceous vegetation closed-open -14 14 Sparse herbaceous or grass -15 15 Flooded shrubs or herbaceous -16 16 Cultivated and managed areas -17 17 Mosaic crop/tree/natural vegetation -18 18 Mosaic crop/shrub/grass -19 19 Bare areas -20 20 Water -21 21 Snow and ice -22 22 Artificial surface -23 23 Ocean -24 24 Irrigated croplands -25 25 Rainfed croplands -26 26 Mosaic cropland (50-70%) - vegetation (20-50%) -27 27 Mosaic vegetation (50-70%) - cropland (20-50%) -28 28 Closed broadleaved evergreen forest -29 29 Closed needle-leaved evergreen forest -30 30 Open needle-leaved deciduous forest -31 31 Mixed broadleaved and needle-leaved forest -32 32 Mosaic shrubland (50-70%) - grassland (20-50%) -33 33 Mosaic grassland (50-70%) - shrubland (20-50%) -34 34 Closed to open shrubland -35 35 Sparse vegetation -36 36 Closed to open forest regularly flooded -37 37 Closed forest or shrubland permanently flooded -38 38 Closed to open grassland regularly flooded -39 39 Undefined -# 40-32767 Reserved -# 32768- Reserved for local use +0 0 Reserved +1 1 Evergreen broadleaved forest +2 2 Deciduous broadleaved closed forest +3 3 Deciduous broadleaved open forest +4 4 Evergreen needle-leaf forest +5 5 Deciduous needle-leaf forest +6 6 Mixed leaf trees +7 7 Freshwater flooded trees +8 8 Saline water flooded trees +9 9 Mosaic tree/natural vegetation +10 10 Burnt tree cover +11 11 Evergreen shrubs closed-open +12 12 Deciduous shrubs closed-open +13 13 Herbaceous vegetation closed-open +14 14 Sparse herbaceous or grass +15 15 Flooded shrubs or herbaceous +16 16 Cultivated and managed areas +17 17 Mosaic crop/tree/natural vegetation +18 18 Mosaic crop/shrub/grass +19 19 Bare areas +20 20 Water +21 21 Snow and ice +22 22 Artificial surface +23 23 Ocean +24 24 Irrigated croplands +25 25 Rainfed croplands +26 26 Mosaic cropland (50-70%) - vegetation (20-50%) +27 27 Mosaic vegetation (50-70%) - cropland (20-50%) +28 28 Closed broadleaved evergreen forest +29 29 Closed needle-leaved evergreen forest +30 30 Open needle-leaved deciduous forest +31 31 Mixed broadleaved and needle-leaved forest +32 32 Mosaic shrubland (50-70%) - grassland (20-50%) +33 33 Mosaic grassland (50-70%) - shrubland (20-50%) +34 34 Closed to open shrubland +35 35 Sparse vegetation +36 36 Closed to open forest regularly flooded +37 37 Closed forest or shrubland permanently flooded +38 38 Closed to open grassland regularly flooded +39 39 Undefined +# 40-32767 Reserved +# 32768- Reserved for local use diff --git a/definitions/grib2/tables/18/4.3.table b/definitions/grib2/tables/18/4.3.table index 8ba9e08ab..cea1bef4f 100644 --- a/definitions/grib2/tables/18/4.3.table +++ b/definitions/grib2/tables/18/4.3.table @@ -1,23 +1,23 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -12 12 Post-processed analysis -13 13 Post-processed forecast -14 14 Nowcast -15 15 Hindcast -16 16 Physical retrieval -17 17 Regression analysis -18 18 Difference between two forecasts -# 19-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +12 12 Post-processed analysis +13 13 Post-processed forecast +14 14 Nowcast +15 15 Hindcast +16 16 Physical retrieval +17 17 Regression analysis +18 18 Difference between two forecasts +# 19-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.4.table b/definitions/grib2/tables/18/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/18/4.4.table +++ b/definitions/grib2/tables/18/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.5.table b/definitions/grib2/tables/18/4.5.table index 2f1a8a8b7..33abd6293 100644 --- a/definitions/grib2/tables/18/4.5.table +++ b/definitions/grib2/tables/18/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface (-) 2 2 Cloud base level (-) 3 3 Level of cloud tops (-) @@ -16,15 +16,15 @@ 14 14 Level of free convection (LFC) 15 15 Convective condensation level (CCL) 16 16 Level of neutral buoyancy or equilibrium level (LNB) -# 17-19 Reserved +# 17-19 Reserved 20 20 Isothermal level (K) 21 21 Lowest level where mass density exceeds the specified value (base for a given threshold of mass density) (kg m-3) 22 22 Highest level where mass density exceeds the specified value (top for a given threshold of mass density) (kg m-3) 23 23 Lowest level where air concentration exceeds the specified value (base for a given threshold of air concentration) (Bq m-3) 24 24 Highest level where air concentration exceeds the specified value (top for a given threshold of air concentration) (Bq m-3) -# 25-99 Reserved +# 25-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -33,20 +33,20 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level (-) -112 112 Reserved -113 113 Logarithmic hybrid level +112 112 Reserved +113 113 Logarithmic hybrid level 114 114 Snow level (Numeric) 115 115 Sigma height level # 116 Reserved 117 117 Mixed layer depth (m) 118 hhl Hybrid height level (-) 119 hpl Hybrid pressure level (-) -# 120-149 Reserved -150 150 Generalized vertical height coordinate +# 120-149 Reserved +150 150 Generalized vertical height coordinate 151 sol Soil level (Numeric) -# 152-159 Reserved +# 152-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom (-) @@ -55,7 +55,7 @@ 165 165 Bottom of sediment layer penetrated by thermal wave (-) 166 sfc Mixing layer (-) 167 167 Bottom of root zone (-) -# 168-173 Reserved +# 168-173 Reserved 174 sfc Top surface of ice on sea, lake or river 175 175 Top surface of ice, under snow cover, on sea, lake or river 176 176 Bottom surface (underside) ice on sea, lake or river @@ -67,6 +67,6 @@ 182 182 Grid tile water fraction as a model surface 183 183 Grid tile ice fraction on sea, lake or river as a model surface 184 184 Grid tile glacier ice and inland ice fraction as a model surface -# 185-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 185-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.6.table b/definitions/grib2/tables/18/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/18/4.6.table +++ b/definitions/grib2/tables/18/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.7.table b/definitions/grib2/tables/18/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/18/4.7.table +++ b/definitions/grib2/tables/18/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.8.table b/definitions/grib2/tables/18/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/18/4.8.table +++ b/definitions/grib2/tables/18/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.9.table b/definitions/grib2/tables/18/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/18/4.9.table +++ b/definitions/grib2/tables/18/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/4.91.table b/definitions/grib2/tables/18/4.91.table index 44cf25f44..ae31ed61c 100644 --- a/definitions/grib2/tables/18/4.91.table +++ b/definitions/grib2/tables/18/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit -11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/18/5.0.table b/definitions/grib2/tables/18/5.0.table index 33597681b..4d6cc68c8 100644 --- a/definitions/grib2/tables/18/5.0.table +++ b/definitions/grib2/tables/18/5.0.table @@ -1,24 +1,24 @@ # Code table 5.0 - Data representation template number -0 0 Grid point data - simple packing -1 1 Matrix value at grid point - simple packing -2 2 Grid point data - complex packing -3 3 Grid point data - complex packing and spatial differencing -4 4 Grid point data - IEEE floating point data -40 40 Grid point data - JPEG 2000 code stream format -41 41 Grid point data - Portable Network Graphics (PNG) +0 0 Grid point data - simple packing +1 1 Matrix value at grid point - simple packing +2 2 Grid point data - complex packing +3 3 Grid point data - complex packing and spatial differencing +4 4 Grid point data - IEEE floating point data +40 40 Grid point data - JPEG 2000 code stream format +41 41 Grid point data - Portable Network Graphics (PNG) 42 42 Grid point data - CCSDS recommended lossless compression -# 43-49 Reserved -50 50 Spectral data - simple packing -51 51 Spherical harmonics data - complex packing -# 52-60 Reserved -61 61 Grid point data - simple packing with logarithm pre-processing -# 62-199 Reserved -200 200 Run length packing with level values -# 201-49151 Reserved -# 49152-65534 Reserved for local use +# 43-49 Reserved +50 50 Spectral data - simple packing +51 51 Spherical harmonics data - complex packing +# 52-60 Reserved +61 61 Grid point data - simple packing with logarithm pre-processing +# 62-199 Reserved +200 200 Run length packing with level values +# 201-49151 Reserved +# 49152-65534 Reserved for local use 40000 40000 JPEG2000 Packing 40010 40010 PNG pacling 50000 50000 Sperical harmonics ieee packing 50001 50001 Second order packing 50002 50002 Second order packing -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/18/5.1.table b/definitions/grib2/tables/18/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/18/5.1.table +++ b/definitions/grib2/tables/18/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/5.2.table b/definitions/grib2/tables/18/5.2.table index 40586a131..d77fdf4e7 100644 --- a/definitions/grib2/tables/18/5.2.table +++ b/definitions/grib2/tables/18/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/5.3.table b/definitions/grib2/tables/18/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/18/5.3.table +++ b/definitions/grib2/tables/18/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/5.4.table b/definitions/grib2/tables/18/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/18/5.4.table +++ b/definitions/grib2/tables/18/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/5.40.table b/definitions/grib2/tables/18/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/18/5.40.table +++ b/definitions/grib2/tables/18/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/18/5.5.table b/definitions/grib2/tables/18/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/18/5.5.table +++ b/definitions/grib2/tables/18/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/5.6.table b/definitions/grib2/tables/18/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/18/5.6.table +++ b/definitions/grib2/tables/18/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/18/5.7.table b/definitions/grib2/tables/18/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/18/5.7.table +++ b/definitions/grib2/tables/18/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/18/6.0.table b/definitions/grib2/tables/18/6.0.table index 2a29aa285..a8f30f5a4 100644 --- a/definitions/grib2/tables/18/6.0.table +++ b/definitions/grib2/tables/18/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator -0 0 A bit map applies to this product and is specified in this Section +0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/19/0.0.table b/definitions/grib2/tables/19/0.0.table index b24c50564..2c5afceb4 100644 --- a/definitions/grib2/tables/19/0.0.table +++ b/definitions/grib2/tables/19/0.0.table @@ -1,10 +1,10 @@ # Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/1.0.table b/definitions/grib2/tables/19/1.0.table index bd54828ee..06710c183 100644 --- a/definitions/grib2/tables/19/1.0.table +++ b/definitions/grib2/tables/19/1.0.table @@ -1,22 +1,22 @@ # Code table 1.0 - GRIB master tables version number -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 -6 6 Version implemented on 15 September 2010 -7 7 Version implemented on 4 May 2011 -8 8 Version implemented on 2 November 2011 -9 9 Version implemented on 2 May 2012 -10 10 Version implemented on 7 November 2012 -11 11 Version implemented on 8 May 2013 -12 12 Version implemented on 14 November 2013 -13 13 Version implemented on 7 May 2014 -14 14 Version implemented on 5 November 2014 -15 15 Version implemented on 6 May 2015 -16 16 Version implemented on 11 November 2015 -17 17 Version implemented on 4 May 2016 +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Version implemented on 2 May 2012 +10 10 Version implemented on 7 November 2012 +11 11 Version implemented on 8 May 2013 +12 12 Version implemented on 14 November 2013 +13 13 Version implemented on 7 May 2014 +14 14 Version implemented on 5 November 2014 +15 15 Version implemented on 6 May 2015 +16 16 Version implemented on 11 November 2015 +17 17 Version implemented on 4 May 2016 18 18 Version implemented on 2 November 2016 19 19 Version implemented on 3 May 2017 20 20 Pre-operational to be implemented by next amendment diff --git a/definitions/grib2/tables/19/1.1.table b/definitions/grib2/tables/19/1.1.table index d50f8fd72..f6d332005 100644 --- a/definitions/grib2/tables/19/1.1.table +++ b/definitions/grib2/tables/19/1.1.table @@ -1,4 +1,4 @@ # Code table 1.1 - GRIB local tables version number -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/19/1.2.table b/definitions/grib2/tables/19/1.2.table index 934b70455..638f1efbb 100644 --- a/definitions/grib2/tables/19/1.2.table +++ b/definitions/grib2/tables/19/1.2.table @@ -1,8 +1,8 @@ # Code table 1.2 - Significance of reference time -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/1.3.table b/definitions/grib2/tables/19/1.3.table index 0c95269d5..c1a9a7b9d 100644 --- a/definitions/grib2/tables/19/1.3.table +++ b/definitions/grib2/tables/19/1.3.table @@ -1,14 +1,14 @@ # Code table 1.3 - Production status of data -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products -4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products +4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) 5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) -6 6 S2S operational products -7 7 S2S test products +6 6 S2S operational products +7 7 S2S test products 8 8 Uncertainties in Ensembles of Regional ReAnalyses project (UERRA) 9 9 Uncertainties in Ensembles of Regional ReAnalyses project test (UERRA) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/1.4.table b/definitions/grib2/tables/19/1.4.table index 03203d874..877288c0e 100644 --- a/definitions/grib2/tables/19/1.4.table +++ b/definitions/grib2/tables/19/1.4.table @@ -1,13 +1,13 @@ # Code table 1.4 - Type of data -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/19/1.5.table b/definitions/grib2/tables/19/1.5.table index b2cf9f087..533111959 100644 --- a/definitions/grib2/tables/19/1.5.table +++ b/definitions/grib2/tables/19/1.5.table @@ -1,7 +1,7 @@ # Code table 1.5 - Identification template number -0 0 Calendar definition -1 1 Paleontological offset -2 2 Calendar definition and paleontological offset -# 3-32767 Reserved -# 32768-65534 Reserved for local use -65535 65535 Missing +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/19/1.6.table b/definitions/grib2/tables/19/1.6.table index 5db921990..bd46899a7 100644 --- a/definitions/grib2/tables/19/1.6.table +++ b/definitions/grib2/tables/19/1.6.table @@ -1,8 +1,8 @@ # Code table 1.6 - Type of calendar -0 0 Gregorian -1 1 360-day -2 2 365-day -3 3 Proleptic Gregorian -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/3.0.table b/definitions/grib2/tables/19/3.0.table index 45187b80d..a442a06a0 100644 --- a/definitions/grib2/tables/19/3.0.table +++ b/definitions/grib2/tables/19/3.0.table @@ -1,6 +1,6 @@ # Code table 3.0 - Source of grid definition -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/19/3.10.table b/definitions/grib2/tables/19/3.10.table index afa8843a7..1612d05e3 100644 --- a/definitions/grib2/tables/19/3.10.table +++ b/definitions/grib2/tables/19/3.10.table @@ -1,8 +1,8 @@ # Flag table 3.10 - Scanning mode for one diamond -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/19/3.11.table b/definitions/grib2/tables/19/3.11.table index e516a2ab9..06ae10810 100644 --- a/definitions/grib2/tables/19/3.11.table +++ b/definitions/grib2/tables/19/3.11.table @@ -1,7 +1,7 @@ # Code table 3.11 - Interpretation of list of numbers at end of section 3 -0 0 There is no appended list -1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows -2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row -3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) -# 4-254 Reserved -255 255 Missing +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/19/3.15.table b/definitions/grib2/tables/19/3.15.table index 331217ebe..6087902a3 100644 --- a/definitions/grib2/tables/19/3.15.table +++ b/definitions/grib2/tables/19/3.15.table @@ -1,23 +1,23 @@ # Code table 3.15 - Physical meaning of vertical coordinate -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/3.2.table b/definitions/grib2/tables/19/3.2.table index 1b5c8241d..56ffdc08e 100644 --- a/definitions/grib2/tables/19/3.2.table +++ b/definitions/grib2/tables/19/3.2.table @@ -1,14 +1,14 @@ # Code table 3.2 - Shape of the Earth -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS-84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS-84 reference frame -9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS-84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS-84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/3.20.table b/definitions/grib2/tables/19/3.20.table index efbf08d19..e2bb156ee 100644 --- a/definitions/grib2/tables/19/3.20.table +++ b/definitions/grib2/tables/19/3.20.table @@ -1,6 +1,6 @@ # Code table 3.20 - Type of horizontal line -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/3.21.table b/definitions/grib2/tables/19/3.21.table index 88dbb9019..e001e1c8f 100644 --- a/definitions/grib2/tables/19/3.21.table +++ b/definitions/grib2/tables/19/3.21.table @@ -1,8 +1,8 @@ # Code table 3.21 - Vertical dimension coordinate values definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/3.3.table b/definitions/grib2/tables/19/3.3.table index 5dd7c7001..25cb46a1d 100644 --- a/definitions/grib2/tables/19/3.3.table +++ b/definitions/grib2/tables/19/3.3.table @@ -1,9 +1,9 @@ # Flag table 3.3 - Resolution and component flags -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/19/3.4.table b/definitions/grib2/tables/19/3.4.table index 897b813d7..43835c014 100644 --- a/definitions/grib2/tables/19/3.4.table +++ b/definitions/grib2/tables/19/3.4.table @@ -1,17 +1,17 @@ # Flag table 3.4 - Scanning mode -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -5 0 Points within odd rows are not offset in i (x) direction -5 1 Points within odd rows are offset by Di/2 in i (x) direction -6 0 Points within even rows are not offset in i (x) direction -6 1 Points within even rows are offset by Di/2 in i (x) direction -7 0 Points are not offset in j (y) direction -7 1 Points are offset by Dj/2 in j (y) direction -8 0 Rows have Ni grid points and columns have Nj grid points -8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +5 0 Points within odd rows are not offset in i (x) direction +5 1 Points within odd rows are offset by Di/2 in i (x) direction +6 0 Points within even rows are not offset in i (x) direction +6 1 Points within even rows are offset by Di/2 in i (x) direction +7 0 Points are not offset in j (y) direction +7 1 Points are offset by Dj/2 in j (y) direction +8 0 Rows have Ni grid points and columns have Nj grid points +8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction diff --git a/definitions/grib2/tables/19/3.5.table b/definitions/grib2/tables/19/3.5.table index eabdde896..2f8ec82e3 100644 --- a/definitions/grib2/tables/19/3.5.table +++ b/definitions/grib2/tables/19/3.5.table @@ -1,5 +1,5 @@ # Flag table 3.5 - Projection centre -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/19/3.7.table b/definitions/grib2/tables/19/3.7.table index 0a7d6efde..34c0de085 100644 --- a/definitions/grib2/tables/19/3.7.table +++ b/definitions/grib2/tables/19/3.7.table @@ -1,5 +1,5 @@ # Code table 3.7 - Spectral data representation mode -0 0 Reserved +0 0 Reserved 1 1 see separate doc or pdf file -# 2-254 Reserved -255 255 Missing +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/19/3.8.table b/definitions/grib2/tables/19/3.8.table index 844e74235..578fab37f 100644 --- a/definitions/grib2/tables/19/3.8.table +++ b/definitions/grib2/tables/19/3.8.table @@ -1,7 +1,7 @@ # Code table 3.8 - Grid point position -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/3.9.table b/definitions/grib2/tables/19/3.9.table index fd730bc64..ecd65514a 100644 --- a/definitions/grib2/tables/19/3.9.table +++ b/definitions/grib2/tables/19/3.9.table @@ -1,4 +1,4 @@ # Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/19/4.0.table b/definitions/grib2/tables/19/4.0.table index 906bf12d3..a37b59d09 100644 --- a/definitions/grib2/tables/19/4.0.table +++ b/definitions/grib2/tables/19/4.0.table @@ -1,75 +1,75 @@ # Code table 4.0 - Product definition template number -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time -8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data -34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -# 35-39 Reserved +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +# 35-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol -46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol -48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -49 49 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol -# 50 Reserved -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +49 49 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +# 50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time # 52 Reserved -53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time -54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters -55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time -56 56 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters (deprecated) -57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function -58 58 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function -59 59 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters (corrected version of template 4.56) -60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval -# 62-66 Reserved -67 67 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents based on a distribution function -68 68 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents based on a distribution function +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time +56 56 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters (deprecated) +57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function +58 58 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function +59 59 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters (corrected version of template 4.56) +60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval +# 62-66 Reserved +67 67 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents based on a distribution function +68 68 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents based on a distribution function # 69 Reserved 70 70 Post-processing analysis or forecast at a horizontal level or in a horizontal layer at a point in time -71 71 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -72 72 Post-processing average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -73 73 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval -# 74-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +71 71 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +72 72 Post-processing average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +73 73 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval +# 74-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved -# 32768-65534 Reserved for local use +# 1102-32767 Reserved +# 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/19/4.1.0.table b/definitions/grib2/tables/19/4.1.0.table index 04cfd7802..df58636d6 100644 --- a/definitions/grib2/tables/19/4.1.0.table +++ b/definitions/grib2/tables/19/4.1.0.table @@ -1,27 +1,27 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.1.1.table b/definitions/grib2/tables/19/4.1.1.table index 7b22b6fed..05a854da0 100644 --- a/definitions/grib2/tables/19/4.1.1.table +++ b/definitions/grib2/tables/19/4.1.1.table @@ -1,7 +1,7 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.1.10.table b/definitions/grib2/tables/19/4.1.10.table index a9b20eb9c..88d3c8743 100644 --- a/definitions/grib2/tables/19/4.1.10.table +++ b/definitions/grib2/tables/19/4.1.10.table @@ -1,10 +1,10 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Subsurface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Subsurface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.1.2.table b/definitions/grib2/tables/19/4.1.2.table index 5b488fe9e..e74126645 100644 --- a/definitions/grib2/tables/19/4.1.2.table +++ b/definitions/grib2/tables/19/4.1.2.table @@ -1,9 +1,9 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.1.3.table b/definitions/grib2/tables/19/4.1.3.table index 7bf60d4a7..ba38c9301 100644 --- a/definitions/grib2/tables/19/4.1.3.table +++ b/definitions/grib2/tables/19/4.1.3.table @@ -1,11 +1,11 @@ # Code table 4.1 - Parameter category by product discipline -0 0 Image format products -1 1 Quantitative products -2 2 Cloud properties -3 3 Flight rule conditions -4 4 Volcanic ash -5 5 Sea-surface temperature -6 6 Solar radiation -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +2 2 Cloud properties +3 3 Flight rule conditions +4 4 Volcanic ash +5 5 Sea-surface temperature +6 6 Solar radiation +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.10.table b/definitions/grib2/tables/19/4.10.table index 1a92baaf6..8a390e4be 100644 --- a/definitions/grib2/tables/19/4.10.table +++ b/definitions/grib2/tables/19/4.10.table @@ -1,16 +1,16 @@ # Code table 4.10 - Type of statistical processing -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -11 11 Summation -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/19/4.11.table b/definitions/grib2/tables/19/4.11.table index 7f404c849..01cc81303 100644 --- a/definitions/grib2/tables/19/4.11.table +++ b/definitions/grib2/tables/19/4.11.table @@ -1,10 +1,10 @@ # Code table 4.11 - Type of time intervals -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.12.table b/definitions/grib2/tables/19/4.12.table index 03fd89b36..d42b47e96 100644 --- a/definitions/grib2/tables/19/4.12.table +++ b/definitions/grib2/tables/19/4.12.table @@ -1,7 +1,7 @@ # Code table 4.12 - Operating mode -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.13.table b/definitions/grib2/tables/19/4.13.table index c92854eec..a0e28eac8 100644 --- a/definitions/grib2/tables/19/4.13.table +++ b/definitions/grib2/tables/19/4.13.table @@ -1,6 +1,6 @@ # Code table 4.13 - Quality control indicator -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.14.table b/definitions/grib2/tables/19/4.14.table index a88cb93fa..d525b23b3 100644 --- a/definitions/grib2/tables/19/4.14.table +++ b/definitions/grib2/tables/19/4.14.table @@ -1,6 +1,6 @@ # Code table 4.14 - Clutter filter indicator -0 0 No clutter filter used -1 1 Clutter filter used -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.15.table b/definitions/grib2/tables/19/4.15.table index 2e5f3dea3..7adddedb6 100644 --- a/definitions/grib2/tables/19/4.15.table +++ b/definitions/grib2/tables/19/4.15.table @@ -1,11 +1,11 @@ # Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.0.table b/definitions/grib2/tables/19/4.2.0.0.table index 7201a8667..83b3e8ef1 100644 --- a/definitions/grib2/tables/19/4.2.0.0.table +++ b/definitions/grib2/tables/19/4.2.0.0.table @@ -29,6 +29,6 @@ 27 27 Wet-bulb temperature (K) 28 28 Unbalanced component of temperature (K) 29 29 Temperature advection (K s-1) -# 30-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 30-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.1.table b/definitions/grib2/tables/19/4.2.0.1.table index c38d6a053..7d43684d3 100644 --- a/definitions/grib2/tables/19/4.2.0.1.table +++ b/definitions/grib2/tables/19/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,7 +86,7 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rainwater content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) @@ -118,6 +118,6 @@ 118 118 Unbalanced component of specific humidity (kg kg-1) 119 119 Unbalanced component of specific cloud liquid water content (kg kg-1) 120 120 Unbalanced component of specific cloud ice water content (kg kg-1) -# 121-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 121-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.13.table b/definitions/grib2/tables/19/4.2.0.13.table index 5086101ad..3f5c30675 100644 --- a/definitions/grib2/tables/19/4.2.0.13.table +++ b/definitions/grib2/tables/19/4.2.0.13.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.14.table b/definitions/grib2/tables/19/4.2.0.14.table index 215884737..97fb38c8b 100644 --- a/definitions/grib2/tables/19/4.2.0.14.table +++ b/definitions/grib2/tables/19/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.15.table b/definitions/grib2/tables/19/4.2.0.15.table index dfbc4d12f..8df082466 100644 --- a/definitions/grib2/tables/19/4.2.0.15.table +++ b/definitions/grib2/tables/19/4.2.0.15.table @@ -16,6 +16,6 @@ 14 14 Reflectivity of hail (dB) 15 15 Hybrid scan reflectivity (dB) 16 16 Hybrid scan reflectivity height (m) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.16.table b/definitions/grib2/tables/19/4.2.0.16.table index 0c240a853..9499d9333 100644 --- a/definitions/grib2/tables/19/4.2.0.16.table +++ b/definitions/grib2/tables/19/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.18.table b/definitions/grib2/tables/19/4.2.0.18.table index 9d106f419..9ca6db61e 100644 --- a/definitions/grib2/tables/19/4.2.0.18.table +++ b/definitions/grib2/tables/19/4.2.0.18.table @@ -8,7 +8,7 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) @@ -18,6 +18,6 @@ 16 16 Height of maximum air concentration (m) 17 17 Column-integrated air concentration (Bq m-2) 18 18 Column-averaged air concentration in layer (Bq m-3) -# 19-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 19-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.19.table b/definitions/grib2/tables/19/4.2.0.19.table index 1d7b4da91..b27eb2dbe 100644 --- a/definitions/grib2/tables/19/4.2.0.19.table +++ b/definitions/grib2/tables/19/4.2.0.19.table @@ -31,6 +31,6 @@ 29 29 Clear air turbulence (CAT) (m2/3 s-1) 30 30 Eddy dissipation parameter (m2/3 s-1) 31 31 Maximum of eddy dissipation parameter in layer (m2/3 s-1) -# 32-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 32-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.190.table b/definitions/grib2/tables/19/4.2.0.190.table index de621a924..a0d6ba0ac 100644 --- a/definitions/grib2/tables/19/4.2.0.190.table +++ b/definitions/grib2/tables/19/4.2.0.190.table @@ -1,5 +1,5 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.191.table b/definitions/grib2/tables/19/4.2.0.191.table index e3bba0ebe..b3a7092ea 100644 --- a/definitions/grib2/tables/19/4.2.0.191.table +++ b/definitions/grib2/tables/19/4.2.0.191.table @@ -3,6 +3,6 @@ 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.2.table b/definitions/grib2/tables/19/4.2.0.2.table index 5446262e6..8a70b2591 100644 --- a/definitions/grib2/tables/19/4.2.0.2.table +++ b/definitions/grib2/tables/19/4.2.0.2.table @@ -46,6 +46,6 @@ 44 44 Geostrophic wind speed (m s-1) 45 45 Unbalanced component of divergence (s-1) 46 46 Vorticity advection (s-2) -# 47-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 47-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.20.table b/definitions/grib2/tables/19/4.2.0.20.table index 3278506dd..0f95689f8 100644 --- a/definitions/grib2/tables/19/4.2.0.20.table +++ b/definitions/grib2/tables/19/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -29,7 +29,7 @@ 61 61 Maximum of mass density in layer (kg m-3) 62 62 Height of maximum mass density (m) 63 63 Column-averaged mass density in layer (kg m-3) -# 64-99 Reserved +# 64-99 Reserved 100 100 Surface area density (aerosol) (m-1) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -42,6 +42,6 @@ 109 109 Aerosol lidar extinction from satellite (m-1) 110 110 Aerosol lidar extinction from the ground (m-1) 111 111 Angstrom exponent (Numeric) -# 112-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 112-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.3.table b/definitions/grib2/tables/19/4.2.0.3.table index 34941dcab..52c421b97 100644 --- a/definitions/grib2/tables/19/4.2.0.3.table +++ b/definitions/grib2/tables/19/4.2.0.3.table @@ -31,6 +31,6 @@ 29 29 Updraught detrainment rate (kg m-3 s-1) 30 30 Downdraught detrainment rate (kg m-3 s-1) 31 31 Unbalanced component of logarithm of surface pressure (-) -# 32-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 32-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.4.table b/definitions/grib2/tables/19/4.2.0.4.table index 0a5ded2b5..f97270456 100644 --- a/definitions/grib2/tables/19/4.2.0.4.table +++ b/definitions/grib2/tables/19/4.2.0.4.table @@ -14,11 +14,11 @@ 12 12 Downward UV radiation (W m-2) 13 13 Direct short-wave radiation flux (W m-2) 14 14 Diffuse short-wave radiation flux (W m-2) -# 15-49 Reserved +# 15-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) 52 52 Downward short-wave radiation flux, clear sky (W m-2) 53 53 Upward short-wave radiation flux, clear sky (W m-2) -# 54-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 54-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.5.table b/definitions/grib2/tables/19/4.2.0.5.table index 4550220b6..ddfa634ce 100644 --- a/definitions/grib2/tables/19/4.2.0.5.table +++ b/definitions/grib2/tables/19/4.2.0.5.table @@ -8,6 +8,6 @@ 6 6 Net long-wave radiation flux, clear sky (W m-2) 7 7 Brightness temperature (K) 8 8 Downward long-wave radiation flux, clear sky (W m-2) -# 9-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 9-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.6.table b/definitions/grib2/tables/19/4.2.0.6.table index 4cec0c8aa..0450ec194 100644 --- a/definitions/grib2/tables/19/4.2.0.6.table +++ b/definitions/grib2/tables/19/4.2.0.6.table @@ -40,10 +40,10 @@ 38 38 Mass density of cloud droplets (kg m-3) 39 39 Mass density of cloud ice (kg m-3) 40 40 Mass density of convective cloud water droplets (kg m-3) -# 41-46 Reserved +# 41-46 Reserved 47 47 Volume fraction of cloud water droplets (Numeric) 48 48 Volume fraction of cloud ice particles (Numeric) 49 49 Volume fraction of cloud (ice and/or water) (Numeric) -# 50-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 50-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.0.7.table b/definitions/grib2/tables/19/4.2.0.7.table index aff6a6516..6289d8b20 100644 --- a/definitions/grib2/tables/19/4.2.0.7.table +++ b/definitions/grib2/tables/19/4.2.0.7.table @@ -13,12 +13,12 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraught helicity (m2 s-2) 16 16 Bulk Richardson number (Numeric) 17 17 Gradient Richardson number (Numeric) 18 18 Flux Richardson number (Numeric) 19 19 Convective available potential energy - shear (m2 s-2) -# 20-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 20-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.1.0.table b/definitions/grib2/tables/19/4.2.1.0.table index bcd849c2e..a2660f4f3 100644 --- a/definitions/grib2/tables/19/4.2.1.0.table +++ b/definitions/grib2/tables/19/4.2.1.0.table @@ -16,6 +16,6 @@ 14 14 Upstream accumulated precipitation (kg m-2) 15 15 Upstream accumulated snow melt (kg m-2) 16 16 Percolation rate (kg m-2 s-1) -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.1.1.table b/definitions/grib2/tables/19/4.2.1.1.table index b488eb0bd..171da3958 100644 --- a/definitions/grib2/tables/19/4.2.1.1.table +++ b/definitions/grib2/tables/19/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.10.0.table b/definitions/grib2/tables/19/4.2.10.0.table index 095f51bdf..3611abd9a 100644 --- a/definitions/grib2/tables/19/4.2.10.0.table +++ b/definitions/grib2/tables/19/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea-surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (/s) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.10.1.table b/definitions/grib2/tables/19/4.2.10.1.table index 5959bfa28..f0a073c00 100644 --- a/definitions/grib2/tables/19/4.2.10.1.table +++ b/definitions/grib2/tables/19/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.10.191.table b/definitions/grib2/tables/19/4.2.10.191.table index 524929e78..1ebf85006 100644 --- a/definitions/grib2/tables/19/4.2.10.191.table +++ b/definitions/grib2/tables/19/4.2.10.191.table @@ -1,8 +1,8 @@ # Code table 4.2 - Parameter number by product discipline and parameter category 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -2 2 Reserved +2 2 Reserved 3 3 Days since last observation (d) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.10.2.table b/definitions/grib2/tables/19/4.2.10.2.table index 6797062ac..4633bad4f 100644 --- a/definitions/grib2/tables/19/4.2.10.2.table +++ b/definitions/grib2/tables/19/4.2.10.2.table @@ -12,6 +12,6 @@ 10 10 Zonal vector component of vertically integrated ice internal pressure (Pa m) 11 11 Meridional vector component of vertically integrated ice internal pressure (Pa m) 12 12 Compressive ice strength (N/m) -# 13-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.10.3.table b/definitions/grib2/tables/19/4.2.10.3.table index de7afd61c..b01d7ae46 100644 --- a/definitions/grib2/tables/19/4.2.10.3.table +++ b/definitions/grib2/tables/19/4.2.10.3.table @@ -2,6 +2,6 @@ 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) 2 2 Heat exchange coefficient (-) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.10.4.table b/definitions/grib2/tables/19/4.2.10.4.table index 54774f1b7..d5615ae26 100644 --- a/definitions/grib2/tables/19/4.2.10.4.table +++ b/definitions/grib2/tables/19/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2/s) 6 6 Ocean vertical momentum diffusivity (m2/s) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (/m) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.2.0.table b/definitions/grib2/tables/19/4.2.2.0.table index 81548840c..b253cac22 100644 --- a/definitions/grib2/tables/19/4.2.2.0.table +++ b/definitions/grib2/tables/19/4.2.2.0.table @@ -38,6 +38,6 @@ 36 36 Tile fraction (Proportion) 37 37 Tile percentage (%) 38 38 Soil volumetric ice content (water equivalent) (m3 m-3) -# 39-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 39-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.2.3.table b/definitions/grib2/tables/19/4.2.2.3.table index 690fab42b..2674e9f42 100644 --- a/definitions/grib2/tables/19/4.2.2.3.table +++ b/definitions/grib2/tables/19/4.2.2.3.table @@ -27,6 +27,6 @@ 25 25 Snow depth at elevation bands (kg m-2) 26 26 Soil heat flux (W m-2) 27 27 Soil depth (m) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.2.4.table b/definitions/grib2/tables/19/4.2.2.4.table index bb54fac22..ceb761557 100644 --- a/definitions/grib2/tables/19/4.2.2.4.table +++ b/definitions/grib2/tables/19/4.2.2.4.table @@ -11,6 +11,6 @@ 9 9 Initial Fire Spread Index (Canadian Forest Service) (Numeric) 10 10 Fire Buildup Index (Canadian Forest Service) (Numeric) 11 11 Fire Daily Severity Rating (Canadian Forest Service) (Numeric) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.3.0.table b/definitions/grib2/tables/19/4.2.3.0.table index c0ffa29f5..80a829673 100644 --- a/definitions/grib2/tables/19/4.2.3.0.table +++ b/definitions/grib2/tables/19/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.2.3.1.table b/definitions/grib2/tables/19/4.2.3.1.table index 8e0793fe0..04cdde1f1 100644 --- a/definitions/grib2/tables/19/4.2.3.1.table +++ b/definitions/grib2/tables/19/4.2.3.1.table @@ -17,16 +17,16 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-26 Reserved +23 23 Angstrom coefficient +# 24-26 Reserved 27 27 Bidirectional reflectance factor (Numeric) 28 28 Brightness temperature (K) 29 29 Scaled radiance (Numeric) -# 30-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 30-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.201.table b/definitions/grib2/tables/19/4.201.table index 47f1b486f..fa173c4e0 100644 --- a/definitions/grib2/tables/19/4.201.table +++ b/definitions/grib2/tables/19/4.201.table @@ -1,15 +1,15 @@ # Code table 4.201 - Precipitation type -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow -6 6 Wet snow -7 7 Mixture of rain and snow -8 8 Ice pellets -9 9 Graupel -10 10 Hail -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +6 6 Wet snow +7 7 Mixture of rain and snow +8 8 Ice pellets +9 9 Graupel +10 10 Hail +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.202.table b/definitions/grib2/tables/19/4.202.table index 438502ff9..7f3c8f6cf 100644 --- a/definitions/grib2/tables/19/4.202.table +++ b/definitions/grib2/tables/19/4.202.table @@ -1,4 +1,4 @@ # Code table 4.202 - Precipitable water category -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.203.table b/definitions/grib2/tables/19/4.203.table index 8a9aedf7a..cf5eb6bdc 100644 --- a/definitions/grib2/tables/19/4.203.table +++ b/definitions/grib2/tables/19/4.203.table @@ -1,26 +1,26 @@ # Code table 4.203 - Cloud type -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.204.table b/definitions/grib2/tables/19/4.204.table index 481372936..8e0be1f8c 100644 --- a/definitions/grib2/tables/19/4.204.table +++ b/definitions/grib2/tables/19/4.204.table @@ -1,9 +1,9 @@ # Code table 4.204 - Thunderstorm coverage -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (6-45%) -4 4 Numerous (> 45%) -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (6-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.205.table b/definitions/grib2/tables/19/4.205.table index 5b4484dfd..c40c7f47b 100644 --- a/definitions/grib2/tables/19/4.205.table +++ b/definitions/grib2/tables/19/4.205.table @@ -1,6 +1,6 @@ # Code table 4.205 - Presence of aerosol -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.206.table b/definitions/grib2/tables/19/4.206.table index 02c3dfdf9..76472c261 100644 --- a/definitions/grib2/tables/19/4.206.table +++ b/definitions/grib2/tables/19/4.206.table @@ -1,6 +1,6 @@ # Code table 4.206 - Volcanic ash -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.207.table b/definitions/grib2/tables/19/4.207.table index 8ddb2e048..b6392fca0 100644 --- a/definitions/grib2/tables/19/4.207.table +++ b/definitions/grib2/tables/19/4.207.table @@ -1,10 +1,10 @@ # Code table 4.207 - Icing -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.208.table b/definitions/grib2/tables/19/4.208.table index b83685a1a..4361d38c0 100644 --- a/definitions/grib2/tables/19/4.208.table +++ b/definitions/grib2/tables/19/4.208.table @@ -1,9 +1,9 @@ # Code table 4.208 - Turbulence -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.209.table b/definitions/grib2/tables/19/4.209.table index cb7617071..39ea549ac 100644 --- a/definitions/grib2/tables/19/4.209.table +++ b/definitions/grib2/tables/19/4.209.table @@ -1,9 +1,9 @@ # Code table 4.209 - Planetary boundary-layer regime -0 0 Reserved -1 1 Stable -2 2 Mechanically driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.210.table b/definitions/grib2/tables/19/4.210.table index ae569a8ba..791878469 100644 --- a/definitions/grib2/tables/19/4.210.table +++ b/definitions/grib2/tables/19/4.210.table @@ -3,4 +3,4 @@ 1 1 Contrail present # 2-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/19/4.211.table b/definitions/grib2/tables/19/4.211.table index 098eb2d43..2a28a84d9 100644 --- a/definitions/grib2/tables/19/4.211.table +++ b/definitions/grib2/tables/19/4.211.table @@ -1,7 +1,7 @@ # Code table 4.211 - Contrail engine type -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.212.table b/definitions/grib2/tables/19/4.212.table index 1a085b88d..6a3dcf88c 100644 --- a/definitions/grib2/tables/19/4.212.table +++ b/definitions/grib2/tables/19/4.212.table @@ -1,18 +1,18 @@ # Code table 4.212 - Land use -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.213.table b/definitions/grib2/tables/19/4.213.table index c65784a00..68d627af6 100644 --- a/definitions/grib2/tables/19/4.213.table +++ b/definitions/grib2/tables/19/4.213.table @@ -1,16 +1,16 @@ # Code table 4.213 - Soil type -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.215.table b/definitions/grib2/tables/19/4.215.table index 034db72be..7888772d5 100644 --- a/definitions/grib2/tables/19/4.215.table +++ b/definitions/grib2/tables/19/4.215.table @@ -1,9 +1,9 @@ # Code table 4.215 - Remotely sensed snow coverage -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.216.table b/definitions/grib2/tables/19/4.216.table index 5d1460cef..b51b358f4 100644 --- a/definitions/grib2/tables/19/4.216.table +++ b/definitions/grib2/tables/19/4.216.table @@ -1,5 +1,5 @@ # Code table 4.216 - Elevation of snow-covered terrain -# 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 0-90 Elevation in increments of 100 m +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/19/4.217.table b/definitions/grib2/tables/19/4.217.table index a4452182c..a700410d5 100644 --- a/definitions/grib2/tables/19/4.217.table +++ b/definitions/grib2/tables/19/4.217.table @@ -1,8 +1,8 @@ # Code table 4.217 - Cloud mask type -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.218.table b/definitions/grib2/tables/19/4.218.table index 7e3a69578..b5b15150b 100644 --- a/definitions/grib2/tables/19/4.218.table +++ b/definitions/grib2/tables/19/4.218.table @@ -1,44 +1,44 @@ # Code table 4.218 - Pixel scene type -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation/crops -15 15 Permanent snow/ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -19 19 Warm liquid water cloud -20 20 Supercooled liquid water cloud -21 21 Mixed-phase cloud -22 22 Optically thin ice cloud -23 23 Optically thick ice cloud -24 24 Multilayered cloud -# 25-96 Reserved -97 97 Snow/ice on land -98 98 Snow/ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud/fog/Stratus -102 102 Low cloud/Stratocumulus -103 103 Low cloud/unknown type -104 104 Medium cloud/Nimbostratus -105 105 Medium cloud/Altostratus -106 106 Medium cloud/unknown type -107 107 High cloud/Cumulus -108 108 High cloud/Cirrus -109 109 High cloud/unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation/crops +15 15 Permanent snow/ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +19 19 Warm liquid water cloud +20 20 Supercooled liquid water cloud +21 21 Mixed-phase cloud +22 22 Optically thin ice cloud +23 23 Optically thick ice cloud +24 24 Multilayered cloud +# 25-96 Reserved +97 97 Snow/ice on land +98 98 Snow/ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud/fog/Stratus +102 102 Low cloud/Stratocumulus +103 103 Low cloud/unknown type +104 104 Medium cloud/Nimbostratus +105 105 Medium cloud/Altostratus +106 106 Medium cloud/unknown type +107 107 High cloud/Cumulus +108 108 High cloud/Cirrus +109 109 High cloud/unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.219.table b/definitions/grib2/tables/19/4.219.table index 86df0522e..9979f50ad 100644 --- a/definitions/grib2/tables/19/4.219.table +++ b/definitions/grib2/tables/19/4.219.table @@ -1,8 +1,8 @@ # Code table 4.219 - Cloud top height quality indicator -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.220.table b/definitions/grib2/tables/19/4.220.table index 93e841f8b..88e869e42 100644 --- a/definitions/grib2/tables/19/4.220.table +++ b/definitions/grib2/tables/19/4.220.table @@ -1,6 +1,6 @@ # Code table 4.220 - Horizontal dimension processed -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.221.table b/definitions/grib2/tables/19/4.221.table index 8448533d7..011cc3518 100644 --- a/definitions/grib2/tables/19/4.221.table +++ b/definitions/grib2/tables/19/4.221.table @@ -1,6 +1,6 @@ # Code table 4.221 - Treatment of missing data -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.222.table b/definitions/grib2/tables/19/4.222.table index 57f113014..558d947ac 100644 --- a/definitions/grib2/tables/19/4.222.table +++ b/definitions/grib2/tables/19/4.222.table @@ -1,6 +1,6 @@ # Code table 4.222 - Categorical result -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.223.table b/definitions/grib2/tables/19/4.223.table index f0deb076a..572c4e7a8 100644 --- a/definitions/grib2/tables/19/4.223.table +++ b/definitions/grib2/tables/19/4.223.table @@ -1,5 +1,5 @@ # Code table 4.223 - Fire detection indicator -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/19/4.224.table b/definitions/grib2/tables/19/4.224.table index e87cde4bb..014f56e23 100644 --- a/definitions/grib2/tables/19/4.224.table +++ b/definitions/grib2/tables/19/4.224.table @@ -1,18 +1,18 @@ # Code table 4.224 - Categorical outlook -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/19/4.227.table b/definitions/grib2/tables/19/4.227.table index 27c76553d..48c3b7633 100644 --- a/definitions/grib2/tables/19/4.227.table +++ b/definitions/grib2/tables/19/4.227.table @@ -1,9 +1,9 @@ # Code table 4.227 - Icing scenario (weather/cloud classification) -0 0 None -1 1 General -2 2 Convective -3 3 Stratiform -4 4 Freezing -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/19/4.234.table b/definitions/grib2/tables/19/4.234.table index 816541ce9..3b05b4515 100644 --- a/definitions/grib2/tables/19/4.234.table +++ b/definitions/grib2/tables/19/4.234.table @@ -1,21 +1,21 @@ # Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in product definition template 4.53 or 4.54) -1 1 Crops, mixed farming -2 2 Short grass -3 3 Evergreen needleleaf trees -4 4 Deciduous needleleaf trees -5 5 Deciduous broadleaf trees -6 6 Evergreen broadleaf trees -7 7 Tall grass -8 8 Desert -9 9 Tundra -10 10 Irrigated crops -11 11 Semidesert -12 12 Ice caps and glaciers -13 13 Bogs and marshes -14 14 Inland water -15 15 Ocean -16 16 Evergreen shrubs -17 17 Deciduous shrubs -18 18 Mixed forest -19 19 Interrupted forest -20 20 Water and land mixtures +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/19/4.236.table b/definitions/grib2/tables/19/4.236.table index fbe093ce9..9c58b488c 100644 --- a/definitions/grib2/tables/19/4.236.table +++ b/definitions/grib2/tables/19/4.236.table @@ -1,8 +1,8 @@ # Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in product definition template 4.53 or 4.54) -1 1 Coarse -2 2 Medium -3 3 Medium-fine -4 4 Fine -5 5 Very-fine -6 6 Organic -7 7 Tropical-organic +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/19/4.240.table b/definitions/grib2/tables/19/4.240.table index 35e363211..400a13e26 100644 --- a/definitions/grib2/tables/19/4.240.table +++ b/definitions/grib2/tables/19/4.240.table @@ -1,13 +1,13 @@ # Code table 4.240 - Type of distribution function -0 0 No specific distribution function given -1 1 Delta functions with spatially variable concentration and fixed diameters Dl (p1) in metre -2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg -3 3 Gaussian (normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) -4 4 Gaussian (normal) distribution with spatially variable concentration, mean diameter and variance -5 5 Log-normal distribution with spatially variable number density, mean diameter and variance -6 6 Log-normal distribution with spatially variable number density, mean diameter and fixed variance(p1) +0 0 No specific distribution function given +1 1 Delta functions with spatially variable concentration and fixed diameters Dl (p1) in metre +2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg +3 3 Gaussian (normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) +4 4 Gaussian (normal) distribution with spatially variable concentration, mean diameter and variance +5 5 Log-normal distribution with spatially variable number density, mean diameter and variance +6 6 Log-normal distribution with spatially variable number density, mean diameter and fixed variance(p1) 7 7 Log-normal distribution with spatially variable number density and mass density and fixed variance(p1) and fixed particle density(p2) 8 8 No distribution function. The encoded variable is derived from variables characterized by type of distribution function of type no. 7 (see above) with fixed variance(p1) and fixed particle density(p2) -# 9-49151 Reserved -# 49152-65534 Reserved for local use -65535 65535 Missing value +# 9-49151 Reserved +# 49152-65534 Reserved for local use +65535 65535 Missing value diff --git a/definitions/grib2/tables/19/4.241.table b/definitions/grib2/tables/19/4.241.table index a037b4ba5..5ea7f775a 100644 --- a/definitions/grib2/tables/19/4.241.table +++ b/definitions/grib2/tables/19/4.241.table @@ -1,9 +1,9 @@ # Code table 4.241 - Coverage attributes -0 0 Undefined -1 1 Unmodified -2 2 Snow covered -3 3 Flooded -4 4 Ice covered -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Undefined +1 1 Unmodified +2 2 Snow covered +3 3 Flooded +4 4 Ice covered +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/19/4.242.table b/definitions/grib2/tables/19/4.242.table index 083f88c29..f6865957c 100644 --- a/definitions/grib2/tables/19/4.242.table +++ b/definitions/grib2/tables/19/4.242.table @@ -1,7 +1,7 @@ # Code table 4.242 - Tile classification -0 0 Reserved -1 1 Land use classes according to ESA-GlobCover GCV2009 -2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +0 0 Reserved +1 1 Land use classes according to ESA-GlobCover GCV2009 +2 2 Land use classes according to European Commission-Global Land Cover Project GLC2000 +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/19/4.243.table b/definitions/grib2/tables/19/4.243.table index b39053311..24d21b719 100644 --- a/definitions/grib2/tables/19/4.243.table +++ b/definitions/grib2/tables/19/4.243.table @@ -1,43 +1,43 @@ # Code table 4.243 - Tile class -0 0 Reserved -1 1 Evergreen broadleaved forest -2 2 Deciduous broadleaved closed forest -3 3 Deciduous broadleaved open forest -4 4 Evergreen needle-leaf forest -5 5 Deciduous needle-leaf forest -6 6 Mixed leaf trees -7 7 Freshwater flooded trees -8 8 Saline water flooded trees -9 9 Mosaic tree/natural vegetation -10 10 Burnt tree cover -11 11 Evergreen shrubs closed-open -12 12 Deciduous shrubs closed-open -13 13 Herbaceous vegetation closed-open -14 14 Sparse herbaceous or grass -15 15 Flooded shrubs or herbaceous -16 16 Cultivated and managed areas -17 17 Mosaic crop/tree/natural vegetation -18 18 Mosaic crop/shrub/grass -19 19 Bare areas -20 20 Water -21 21 Snow and ice -22 22 Artificial surface -23 23 Ocean -24 24 Irrigated croplands -25 25 Rainfed croplands -26 26 Mosaic cropland (50-70%) - vegetation (20-50%) -27 27 Mosaic vegetation (50-70%) - cropland (20-50%) -28 28 Closed broadleaved evergreen forest -29 29 Closed needle-leaved evergreen forest -30 30 Open needle-leaved deciduous forest -31 31 Mixed broadleaved and needle-leaved forest -32 32 Mosaic shrubland (50-70%) - grassland (20-50%) -33 33 Mosaic grassland (50-70%) - shrubland (20-50%) -34 34 Closed to open shrubland -35 35 Sparse vegetation -36 36 Closed to open forest regularly flooded -37 37 Closed forest or shrubland permanently flooded -38 38 Closed to open grassland regularly flooded -39 39 Undefined -# 40-32767 Reserved -# 32768- Reserved for local use +0 0 Reserved +1 1 Evergreen broadleaved forest +2 2 Deciduous broadleaved closed forest +3 3 Deciduous broadleaved open forest +4 4 Evergreen needle-leaf forest +5 5 Deciduous needle-leaf forest +6 6 Mixed leaf trees +7 7 Freshwater flooded trees +8 8 Saline water flooded trees +9 9 Mosaic tree/natural vegetation +10 10 Burnt tree cover +11 11 Evergreen shrubs closed-open +12 12 Deciduous shrubs closed-open +13 13 Herbaceous vegetation closed-open +14 14 Sparse herbaceous or grass +15 15 Flooded shrubs or herbaceous +16 16 Cultivated and managed areas +17 17 Mosaic crop/tree/natural vegetation +18 18 Mosaic crop/shrub/grass +19 19 Bare areas +20 20 Water +21 21 Snow and ice +22 22 Artificial surface +23 23 Ocean +24 24 Irrigated croplands +25 25 Rainfed croplands +26 26 Mosaic cropland (50-70%) - vegetation (20-50%) +27 27 Mosaic vegetation (50-70%) - cropland (20-50%) +28 28 Closed broadleaved evergreen forest +29 29 Closed needle-leaved evergreen forest +30 30 Open needle-leaved deciduous forest +31 31 Mixed broadleaved and needle-leaved forest +32 32 Mosaic shrubland (50-70%) - grassland (20-50%) +33 33 Mosaic grassland (50-70%) - shrubland (20-50%) +34 34 Closed to open shrubland +35 35 Sparse vegetation +36 36 Closed to open forest regularly flooded +37 37 Closed forest or shrubland permanently flooded +38 38 Closed to open grassland regularly flooded +39 39 Undefined +# 40-32767 Reserved +# 32768- Reserved for local use diff --git a/definitions/grib2/tables/19/4.3.table b/definitions/grib2/tables/19/4.3.table index 8ba9e08ab..cea1bef4f 100644 --- a/definitions/grib2/tables/19/4.3.table +++ b/definitions/grib2/tables/19/4.3.table @@ -1,23 +1,23 @@ # Code table 4.3 - Type of generating process -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -12 12 Post-processed analysis -13 13 Post-processed forecast -14 14 Nowcast -15 15 Hindcast -16 16 Physical retrieval -17 17 Regression analysis -18 18 Difference between two forecasts -# 19-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +12 12 Post-processed analysis +13 13 Post-processed forecast +14 14 Nowcast +15 15 Hindcast +16 16 Physical retrieval +17 17 Regression analysis +18 18 Difference between two forecasts +# 19-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.4.table b/definitions/grib2/tables/19/4.4.table index 7087ebddb..6e63e069c 100644 --- a/definitions/grib2/tables/19/4.4.table +++ b/definitions/grib2/tables/19/4.4.table @@ -1,17 +1,17 @@ # Code table 4.4 - Indicator of unit of time range -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.5.table b/definitions/grib2/tables/19/4.5.table index 2f1a8a8b7..33abd6293 100644 --- a/definitions/grib2/tables/19/4.5.table +++ b/definitions/grib2/tables/19/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface (-) 2 2 Cloud base level (-) 3 3 Level of cloud tops (-) @@ -16,15 +16,15 @@ 14 14 Level of free convection (LFC) 15 15 Convective condensation level (CCL) 16 16 Level of neutral buoyancy or equilibrium level (LNB) -# 17-19 Reserved +# 17-19 Reserved 20 20 Isothermal level (K) 21 21 Lowest level where mass density exceeds the specified value (base for a given threshold of mass density) (kg m-3) 22 22 Highest level where mass density exceeds the specified value (top for a given threshold of mass density) (kg m-3) 23 23 Lowest level where air concentration exceeds the specified value (base for a given threshold of air concentration) (Bq m-3) 24 24 Highest level where air concentration exceeds the specified value (top for a given threshold of air concentration) (Bq m-3) -# 25-99 Reserved +# 25-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -33,20 +33,20 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level (-) -112 112 Reserved -113 113 Logarithmic hybrid level +112 112 Reserved +113 113 Logarithmic hybrid level 114 114 Snow level (Numeric) 115 115 Sigma height level # 116 Reserved 117 117 Mixed layer depth (m) 118 hhl Hybrid height level (-) 119 hpl Hybrid pressure level (-) -# 120-149 Reserved -150 150 Generalized vertical height coordinate +# 120-149 Reserved +150 150 Generalized vertical height coordinate 151 sol Soil level (Numeric) -# 152-159 Reserved +# 152-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 sfc Lake or river bottom (-) @@ -55,7 +55,7 @@ 165 165 Bottom of sediment layer penetrated by thermal wave (-) 166 sfc Mixing layer (-) 167 167 Bottom of root zone (-) -# 168-173 Reserved +# 168-173 Reserved 174 sfc Top surface of ice on sea, lake or river 175 175 Top surface of ice, under snow cover, on sea, lake or river 176 176 Bottom surface (underside) ice on sea, lake or river @@ -67,6 +67,6 @@ 182 182 Grid tile water fraction as a model surface 183 183 Grid tile ice fraction on sea, lake or river as a model surface 184 184 Grid tile glacier ice and inland ice fraction as a model surface -# 185-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 185-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.6.table b/definitions/grib2/tables/19/4.6.table index b2dfeb498..ce799721d 100644 --- a/definitions/grib2/tables/19/4.6.table +++ b/definitions/grib2/tables/19/4.6.table @@ -1,9 +1,9 @@ # Code table 4.6 - Type of ensemble forecast -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.7.table b/definitions/grib2/tables/19/4.7.table index e0de0e1b2..69b2b4d77 100644 --- a/definitions/grib2/tables/19/4.7.table +++ b/definitions/grib2/tables/19/4.7.table @@ -1,14 +1,14 @@ # Code table 4.7 - Derived forecast -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.8.table b/definitions/grib2/tables/19/4.8.table index ad883039c..78467454a 100644 --- a/definitions/grib2/tables/19/4.8.table +++ b/definitions/grib2/tables/19/4.8.table @@ -1,6 +1,6 @@ # Code table 4.8 - Clustering method -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.9.table b/definitions/grib2/tables/19/4.9.table index 5878b5ad3..0ce312dd1 100644 --- a/definitions/grib2/tables/19/4.9.table +++ b/definitions/grib2/tables/19/4.9.table @@ -1,9 +1,9 @@ # Code table 4.9 - Probability type -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/4.91.table b/definitions/grib2/tables/19/4.91.table index 44cf25f44..ae31ed61c 100644 --- a/definitions/grib2/tables/19/4.91.table +++ b/definitions/grib2/tables/19/4.91.table @@ -1,16 +1,16 @@ # Code table 4.91 - Type of Interval -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit -11 11 Equal to first limit -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/19/5.0.table b/definitions/grib2/tables/19/5.0.table index 33597681b..4d6cc68c8 100644 --- a/definitions/grib2/tables/19/5.0.table +++ b/definitions/grib2/tables/19/5.0.table @@ -1,24 +1,24 @@ # Code table 5.0 - Data representation template number -0 0 Grid point data - simple packing -1 1 Matrix value at grid point - simple packing -2 2 Grid point data - complex packing -3 3 Grid point data - complex packing and spatial differencing -4 4 Grid point data - IEEE floating point data -40 40 Grid point data - JPEG 2000 code stream format -41 41 Grid point data - Portable Network Graphics (PNG) +0 0 Grid point data - simple packing +1 1 Matrix value at grid point - simple packing +2 2 Grid point data - complex packing +3 3 Grid point data - complex packing and spatial differencing +4 4 Grid point data - IEEE floating point data +40 40 Grid point data - JPEG 2000 code stream format +41 41 Grid point data - Portable Network Graphics (PNG) 42 42 Grid point data - CCSDS recommended lossless compression -# 43-49 Reserved -50 50 Spectral data - simple packing -51 51 Spherical harmonics data - complex packing -# 52-60 Reserved -61 61 Grid point data - simple packing with logarithm pre-processing -# 62-199 Reserved -200 200 Run length packing with level values -# 201-49151 Reserved -# 49152-65534 Reserved for local use +# 43-49 Reserved +50 50 Spectral data - simple packing +51 51 Spherical harmonics data - complex packing +# 52-60 Reserved +61 61 Grid point data - simple packing with logarithm pre-processing +# 62-199 Reserved +200 200 Run length packing with level values +# 201-49151 Reserved +# 49152-65534 Reserved for local use 40000 40000 JPEG2000 Packing 40010 40010 PNG pacling 50000 50000 Sperical harmonics ieee packing 50001 50001 Second order packing 50002 50002 Second order packing -65535 65535 Missing +65535 65535 Missing diff --git a/definitions/grib2/tables/19/5.1.table b/definitions/grib2/tables/19/5.1.table index 854330c74..1189b5e46 100644 --- a/definitions/grib2/tables/19/5.1.table +++ b/definitions/grib2/tables/19/5.1.table @@ -1,6 +1,6 @@ # Code table 5.1 - Type of original field values -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/5.2.table b/definitions/grib2/tables/19/5.2.table index 40586a131..d77fdf4e7 100644 --- a/definitions/grib2/tables/19/5.2.table +++ b/definitions/grib2/tables/19/5.2.table @@ -1,8 +1,8 @@ # Code table 5.2 - Matrix coordinate value function definition -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/5.3.table b/definitions/grib2/tables/19/5.3.table index c3b7b30fe..481331791 100644 --- a/definitions/grib2/tables/19/5.3.table +++ b/definitions/grib2/tables/19/5.3.table @@ -1,7 +1,7 @@ # Code table 5.3 - Matrix coordinate parameter -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/5.4.table b/definitions/grib2/tables/19/5.4.table index 8121c1819..e84ab1901 100644 --- a/definitions/grib2/tables/19/5.4.table +++ b/definitions/grib2/tables/19/5.4.table @@ -1,6 +1,6 @@ # Code table 5.4 - Group splitting method -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/5.40.table b/definitions/grib2/tables/19/5.40.table index b9bad2c39..97e8880ab 100644 --- a/definitions/grib2/tables/19/5.40.table +++ b/definitions/grib2/tables/19/5.40.table @@ -1,5 +1,5 @@ # Code table 5.40 - Type of compression -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/19/5.5.table b/definitions/grib2/tables/19/5.5.table index 3ef3eb070..f2316975a 100644 --- a/definitions/grib2/tables/19/5.5.table +++ b/definitions/grib2/tables/19/5.5.table @@ -1,7 +1,7 @@ # Code table 5.5 - Missing value management for complex packing -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/5.6.table b/definitions/grib2/tables/19/5.6.table index 6d5177877..db68ead9c 100644 --- a/definitions/grib2/tables/19/5.6.table +++ b/definitions/grib2/tables/19/5.6.table @@ -1,7 +1,7 @@ # Code table 5.6 - Order of spatial differencing -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/19/5.7.table b/definitions/grib2/tables/19/5.7.table index 5ab780056..e54862c19 100644 --- a/definitions/grib2/tables/19/5.7.table +++ b/definitions/grib2/tables/19/5.7.table @@ -1,7 +1,7 @@ # Code table 5.7 - Precision of floating-point numbers -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/19/6.0.table b/definitions/grib2/tables/19/6.0.table index 2a29aa285..a8f30f5a4 100644 --- a/definitions/grib2/tables/19/6.0.table +++ b/definitions/grib2/tables/19/6.0.table @@ -1,6 +1,6 @@ # Code table 6.0 - Bit map indicator -0 0 A bit map applies to this product and is specified in this Section +0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/32/4.252.table b/definitions/grib2/tables/32/4.252.table index f13d72689..961928cd4 100644 --- a/definitions/grib2/tables/32/4.252.table +++ b/definitions/grib2/tables/32/4.252.table @@ -161,5 +161,5 @@ # 4023-4500 Reserved for tile class entries for tile models using the European Commission-Global Land Cover Project GLC2000 survey # 4501-5000 Reserved for tile grouping entries for tile models using the European Commission-Global Land Cover Project GLC2000 survey # 5001-32767 Reserved for additional land cover surveys -# 32768-65534 Reserved for local use -65535 65535 Missing \ No newline at end of file +# 32768-65534 Reserved for local use +65535 65535 Missing \ No newline at end of file diff --git a/definitions/grib2/tables/33/0.0.table b/definitions/grib2/tables/33/0.0.table new file mode 100644 index 000000000..a8542e94f --- /dev/null +++ b/definitions/grib2/tables/33/0.0.table @@ -0,0 +1,13 @@ +# Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Satellite remote sensing products (formerly Space products) +4 4 Space weather products +# 5-9 Reserved +10 10 Oceanographic products +# 11-19 Reserved +20 20 Health and socioeconomic impacts +# 21-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/1.0.table b/definitions/grib2/tables/33/1.0.table new file mode 100644 index 000000000..841af8c85 --- /dev/null +++ b/definitions/grib2/tables/33/1.0.table @@ -0,0 +1,38 @@ +# Code table 1.0 - GRIB master tables version number +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Version implemented on 2 May 2012 +10 10 Version implemented on 7 November 2012 +11 11 Version implemented on 8 May 2013 +12 12 Version implemented on 14 November 2013 +13 13 Version implemented on 7 May 2014 +14 14 Version implemented on 5 November 2014 +15 15 Version implemented on 6 May 2015 +16 16 Version implemented on 11 November 2015 +17 17 Version implemented on 4 May 2016 +18 18 Version implemented on 2 November 2016 +19 19 Version implemented on 3 May 2017 +20 20 Version implemented on 8 November 2017 +21 21 Version implemented on 2 May 2018 +22 22 Version implemented on 7 November 2018 +23 23 Version implemented on 15 May 2019 +24 24 Version implemented on 6 November 2019 +25 25 Version implemented on 6 May 2020 +26 26 Version implemented on 16 November 2020 +27 27 Version implemented on 15 June 2021 +28 28 Version implemented on 15 November 2021 +29 29 Version implemented on 15 May 2022 +30 30 Version implemented on 15 November 2022 +31 31 Version implemented on 15 May 2023 +32 32 Version implemented on 30 November 2023 +33 33 Version implemented on 15 May 2024 +34 34 Pre-operational to be implemented by next amendment +# 35-254 Future versions +255 255 Missing diff --git a/definitions/grib2/tables/33/1.1.table b/definitions/grib2/tables/33/1.1.table new file mode 100644 index 000000000..f6d332005 --- /dev/null +++ b/definitions/grib2/tables/33/1.1.table @@ -0,0 +1,4 @@ +# Code table 1.1 - GRIB local tables version number +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/33/1.2.table b/definitions/grib2/tables/33/1.2.table new file mode 100644 index 000000000..05ec48c5d --- /dev/null +++ b/definitions/grib2/tables/33/1.2.table @@ -0,0 +1,10 @@ +# Code table 1.2 - Significance of reference time +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +4 4 Local time +5 5 Simulation start +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/1.3.table b/definitions/grib2/tables/33/1.3.table new file mode 100644 index 000000000..88c033e42 --- /dev/null +++ b/definitions/grib2/tables/33/1.3.table @@ -0,0 +1,18 @@ +# Code table 1.3 - Production status of data +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products +4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) +5 5 THORPEX Interactive Grand Global Ensemble test (TIGGE) +6 6 S2S operational products +7 7 S2S test products +8 8 Uncertainties in Ensembles of Regional ReAnalyses project (UERRA) +9 9 Uncertainties in Ensembles of Regional ReAnalyses project test (UERRA) +10 10 Copernicus regional reanalysis (CARRA/CERRA) +11 11 Copernicus regional reanalysis test (CARRA/CERRA) +12 12 Destination Earth +13 13 Destination Earth test +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/1.4.table b/definitions/grib2/tables/33/1.4.table new file mode 100644 index 000000000..877288c0e --- /dev/null +++ b/definitions/grib2/tables/33/1.4.table @@ -0,0 +1,13 @@ +# Code table 1.4 - Type of data +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/33/1.5.table b/definitions/grib2/tables/33/1.5.table new file mode 100644 index 000000000..533111959 --- /dev/null +++ b/definitions/grib2/tables/33/1.5.table @@ -0,0 +1,7 @@ +# Code table 1.5 - Identification template number +0 0 Calendar definition +1 1 Paleontological offset +2 2 Calendar definition and paleontological offset +# 3-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/33/1.6.table b/definitions/grib2/tables/33/1.6.table new file mode 100644 index 000000000..bd46899a7 --- /dev/null +++ b/definitions/grib2/tables/33/1.6.table @@ -0,0 +1,8 @@ +# Code table 1.6 - Type of calendar +0 0 Gregorian +1 1 360-day +2 2 365-day +3 3 Proleptic Gregorian +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/3.0.table b/definitions/grib2/tables/33/3.0.table new file mode 100644 index 000000000..a442a06a0 --- /dev/null +++ b/definitions/grib2/tables/33/3.0.table @@ -0,0 +1,6 @@ +# Code table 3.0 - Source of grid definition +0 0 Specified in Code table 3.1 +1 1 Predetermined grid definition (Defined by originating centre) +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/33/3.1.table b/definitions/grib2/tables/33/3.1.table new file mode 100644 index 000000000..26dc8da3f --- /dev/null +++ b/definitions/grib2/tables/33/3.1.table @@ -0,0 +1,57 @@ +# Code table 3.1 - Grid definition template number +0 0 Latitude/longitude (Also called equidistant cylindrical, or Plate Carree) +1 1 Rotated latitude/longitude +2 2 Stretched latitude/longitude +3 3 Stretched and rotated latitude/longitude +4 4 Variable resolution latitude/longitude +5 5 Variable resolution rotated latitude/longitude +# 6-9 Reserved +10 10 Mercator +# 11 Reserved +12 12 Transverse Mercator +13 13 Mercator with modelling subdomains definition +# 14-19 Reserved +20 20 Polar stereographic projection (Can be south or north) +# 21-22 Reserved +23 23 Polar stereographic with modelling subdomains definition +# 24-29 Reserved +30 30 Lambert conformal (Can be secant or tangent, conical or bipolar) +31 31 Albers equal area +# 32 Reserved +33 33 Lambert conformal with modelling subdomains definition +# 34-39 Reserved +40 40 Gaussian latitude/longitude +41 41 Rotated Gaussian latitude/longitude +42 42 Stretched Gaussian latitude/longitude +43 43 Stretched and rotated Gaussian latitude/longitude +# 44-49 Reserved +50 50 Spherical harmonic coefficients +51 51 Rotated spherical harmonic coefficients +52 52 Stretched spherical harmonic coefficients +53 53 Stretched and rotated spherical harmonic coefficients +# 54-60 Reserved +61 61 Spectral Mercator with modelling subdomains definition +62 62 Spectral polar stereographic with modelling subdomains definition +63 63 Spectral Lambert conformal with modelling subdomains definition +# 64-89 Reserved +90 90 Space view perspective or orthographic +# 91-99 Reserved +100 100 Triangular grid based on an icosahedron +101 101 General unstructured grid +# 102-109 Reserved +110 110 Equatorial azimuthal equidistant projection +# 111-119 Reserved +120 120 Azimuth-range projection +# 121-139 Reserved +140 140 Lambert azimuthal equal area projection +# 141-149 Reserved +150 150 Hierarchical Equal Area isoLatitude Pixelization grid (HEALPix) +# 151-999 Reserved +1000 1000 Cross-section grid with points equally spaced on the horizontal +# 1001-1099 Reserved +1100 1100 Hovmoller diagram grid with points equally spaced on the horizontal +# 1101-1199 Reserved +1200 1200 Time section grid +# 1201-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/33/3.10.table b/definitions/grib2/tables/33/3.10.table new file mode 100644 index 000000000..1612d05e3 --- /dev/null +++ b/definitions/grib2/tables/33/3.10.table @@ -0,0 +1,8 @@ +# Flag table 3.10 - Scanning mode for one diamond +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/33/3.11.table b/definitions/grib2/tables/33/3.11.table new file mode 100644 index 000000000..06ae10810 --- /dev/null +++ b/definitions/grib2/tables/33/3.11.table @@ -0,0 +1,7 @@ +# Code table 3.11 - Interpretation of list of numbers at end of section 3 +0 0 There is no appended list +1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows +2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row +3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/3.12.table b/definitions/grib2/tables/33/3.12.table new file mode 100644 index 000000000..7d4757100 --- /dev/null +++ b/definitions/grib2/tables/33/3.12.table @@ -0,0 +1,6 @@ +# Code table 3.12 - HEALPix rhomboids or points ordering +0 0 Ring ordering +1 1 Nested ordering +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/3.13.table b/definitions/grib2/tables/33/3.13.table new file mode 100644 index 000000000..aabe4fc03 --- /dev/null +++ b/definitions/grib2/tables/33/3.13.table @@ -0,0 +1,8 @@ +# Flag table 3.13 - HEALPix scanning mode +1 0 Points scan in +i (+x) direction +1 1 Points scan in -i (-x) direction +2 0 Points scan in -j (-y) direction +2 1 Points scan in +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/33/3.15.table b/definitions/grib2/tables/33/3.15.table new file mode 100644 index 000000000..43539dbfc --- /dev/null +++ b/definitions/grib2/tables/33/3.15.table @@ -0,0 +1,23 @@ +# Code table 3.15 - Physical meaning of vertical coordinate +# 0-19 Reserved +20 20 Temperature (K) +# 21-99 Reserved +100 100 Pressure (Pa) +101 101 Pressure deviation from mean sea level (Pa) +102 102 Altitude above mean sea level (m) +103 103 Height above ground (m) +104 104 Sigma coordinate +105 105 Hybrid coordinate +106 106 Depth below land surface (m) +107 pt Potential temperature (theta) (K) +108 108 Pressure deviation from ground to level (Pa) +109 pv Potential vorticity (K m2 kg-1 s-1) +110 110 Geometrical height (m) +111 111 Eta coordinate +112 112 Geopotential height (gpm) +113 113 Logarithmic hybrid coordinate +# 114-159 Reserved +160 160 Depth below sea level (m) +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/3.2.table b/definitions/grib2/tables/33/3.2.table new file mode 100644 index 000000000..13b9bf469 --- /dev/null +++ b/definitions/grib2/tables/33/3.2.table @@ -0,0 +1,16 @@ +# Code table 3.2 - Shape of the reference system +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS-84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS-84 reference frame +9 9 Earth represented by the Ordnance Survey Great Britain 1936 Datum, using the Airy 1830 Spheroid, the Greenwich meridian as 0 longitude, and the Newlyn datum as mean sea level, 0 height +10 10 Earth model assumed WGS84 with corrected geomagnetic coordinates (latitude and longitude) defined by Gustafsson et al., 1992 +11 11 Sun assumed spherical with radius = 695 990 000 m (Allen, C.W., Astrophysical Quantities, 3rd ed.; Athlone: London, 1976) and Stonyhurst latitude and longitude system with origin at the intersection of the solar central meridian (as seen from Earth) and the solar equator (Thompson, W., Coordinate systems for solar image data, Astron. Astrophys. 2006, 449, 791-803) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/3.20.table b/definitions/grib2/tables/33/3.20.table new file mode 100644 index 000000000..e2bb156ee --- /dev/null +++ b/definitions/grib2/tables/33/3.20.table @@ -0,0 +1,6 @@ +# Code table 3.20 - Type of horizontal line +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/3.21.table b/definitions/grib2/tables/33/3.21.table new file mode 100644 index 000000000..e001e1c8f --- /dev/null +++ b/definitions/grib2/tables/33/3.21.table @@ -0,0 +1,8 @@ +# Code table 3.21 - Vertical dimension coordinate values definition +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/3.25.table b/definitions/grib2/tables/33/3.25.table new file mode 100644 index 000000000..e5a754994 --- /dev/null +++ b/definitions/grib2/tables/33/3.25.table @@ -0,0 +1,10 @@ +# Code table 3.25 - Type of bi-Fourier truncation +# 0-76 Reserved +77 77 Rectangular +# 78-87 Reserved +88 88 Elliptic +# 89-98 Reserved +99 99 Diamond +# 100-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/3.3.table b/definitions/grib2/tables/33/3.3.table new file mode 100644 index 000000000..25cb46a1d --- /dev/null +++ b/definitions/grib2/tables/33/3.3.table @@ -0,0 +1,9 @@ +# Flag table 3.3 - Resolution and component flags +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/33/3.4.table b/definitions/grib2/tables/33/3.4.table new file mode 100644 index 000000000..0f9d84464 --- /dev/null +++ b/definitions/grib2/tables/33/3.4.table @@ -0,0 +1,17 @@ +# Flag table 3.4 - Scanning mode +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction are consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scan in the opposite direction +5 0 Points within odd rows are not offset in i (x) direction +5 1 Points within odd rows are offset by Di/2 in i (x) direction +6 0 Points within even rows are not offset in i (x) direction +6 1 Points within even rows are offset by Di/2 in i (x) direction +7 0 Points are not offset in j (y) direction +7 1 Points are offset by Dj/2 in j (y) direction +8 0 Rows have Ni grid points and columns have Nj grid points +8 1 Rows have Ni grid points if points are not offset in i direction Rows have Ni-1 grid points if points are offset by Di/2 in i direction Columns have Nj grid points if points are not offset in j direction Columns have Nj-1 grid points if points are offset by Dj/2 in j direction diff --git a/definitions/grib2/tables/33/3.5.table b/definitions/grib2/tables/33/3.5.table new file mode 100644 index 000000000..2f8ec82e3 --- /dev/null +++ b/definitions/grib2/tables/33/3.5.table @@ -0,0 +1,5 @@ +# Flag table 3.5 - Projection centre +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/33/3.6.table b/definitions/grib2/tables/33/3.6.table new file mode 100644 index 000000000..5ab13aaa5 --- /dev/null +++ b/definitions/grib2/tables/33/3.6.table @@ -0,0 +1,3 @@ +# Code table 3.6 - Spectral data representation type +1 1 see separate doc or pdf file +2 2 Bi-Fourier representation diff --git a/definitions/grib2/tables/33/3.7.table b/definitions/grib2/tables/33/3.7.table new file mode 100644 index 000000000..34c0de085 --- /dev/null +++ b/definitions/grib2/tables/33/3.7.table @@ -0,0 +1,5 @@ +# Code table 3.7 - Spectral data representation mode +0 0 Reserved +1 1 see separate doc or pdf file +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/3.8.table b/definitions/grib2/tables/33/3.8.table new file mode 100644 index 000000000..fcd17dca8 --- /dev/null +++ b/definitions/grib2/tables/33/3.8.table @@ -0,0 +1,10 @@ +# Code table 3.8 - Grid point position +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +3 3 Grid points at shape vertices +4 4 Grid points at centre of shapes +5 5 Grid points at midpoints of shape sides +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/3.9.table b/definitions/grib2/tables/33/3.9.table new file mode 100644 index 000000000..ecd65514a --- /dev/null +++ b/definitions/grib2/tables/33/3.9.table @@ -0,0 +1,4 @@ +# Flag table 3.9 - Numbering order of diamonds as seen from the corresponding pole +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/33/4.0.table b/definitions/grib2/tables/33/4.0.table new file mode 100644 index 000000000..86399bd79 --- /dev/null +++ b/definitions/grib2/tables/33/4.0.table @@ -0,0 +1,124 @@ +# Code table 4.0 - Product definition template number +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values or other statistically processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +33 33 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +34 34 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data +35 35 Satellite product with or without associated quality values +# 36-39 Reserved +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +42 42 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +49 49 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol +# 50 Reserved +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +# 52 Reserved +53 53 Partitioned parameters at a horizontal level or in a horizontal layer at a point in time +54 54 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for partitioned parameters +55 55 Spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time +56 56 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters (deprecated) +57 57 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function +58 58 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents based on a distribution function +59 59 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters (corrected version of template 4.56) +60 60 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +61 61 Individual ensemble reforecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval +62 62 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for spatio-temporal changing tiles at a horizontal level or horizontal layer at a point in time +63 63 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for spatio-temporal changing tiles +# 64-66 Reserved +67 67 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents based on a distribution function +68 68 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents based on a distribution function +# 69 Reserved +70 70 Post-processing analysis or forecast at a horizontal level or in a horizontal layer at a point in time +71 71 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +72 72 Post-processing average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +73 73 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval +# 74-75 Reserved +76 76 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents with source or sink +77 77 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents with source or sink +78 78 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents with source or sink +79 79 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents with source or sink +80 80 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol with source or sink +81 81 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for optical properties of aerosol with source or sink +82 82 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol with source or sink +83 83 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol with source or sink +84 84 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol with source or sink +85 85 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol +86 86 Quantile forecasts at a horizontal level or in a horizontal layer at a point in time +87 87 Quantile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +88 88 Analysis or forecast at a horizontal level or in a horizontal layer at a specified local time +89 89 Post-processed quantile forecasts at a horizontal level or in a horizontal layer at a point in time +90 90 Post-processed quantile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +92 92 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a specified local time +93 93 Post-processing analysis or forecast at a horizontal level or in a horizontal layer at a specified local time +94 94 Post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a specified local time +95 95 Average, accumulation, extreme values or other statistically processed value at a horizontal level or in a horizontal layer at a specified local time +96 96 Average, accumulation, extreme values or other statistically processed values of an individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a specified local time +97 97 Average, accumulation, extreme values or other statistically processed values of post-processing analysis or forecast at a horizontal level or in a horizontal layer at a specified local time +98 98 Average, accumulation, extreme values or other statistically processed values of a post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a specified local time +99 99 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for wave 2D spectra with explicit list of frequencies and directions +100 100 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for wave 2D spectra with explicit list of frequencies and directions +101 101 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for wave 2D spectra with frequencies and directions defined by formulae +102 102 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for wave 2D spectra with frequencies and directions defined by formulae +103 103 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for waves selected by period range +104 104 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for waves selected by period range +105 105 Anomalies, significance and other derived products from an analysis or forecast in relation to a reference period at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +106 106 Anomalies, significance and other derived products from an individual ensemble forecast, control and perturbed in relation to a reference period at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +107 107 Anomalies, significance and other derived products from derived forecasts based on all ensemble members in relation to a reference period at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +108 108 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for generic optical products +109 109 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for generic optical products +110 110 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for generic optical products +111 111 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for generic optical products +112 112 Anomalies, significance and other derived products as probability forecasts in relation to a reference period at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +113 113 Generalised tiles at a horizontal level or horizontal layer at a point in time +114 114 Average, accumulation, and/or extreme values or other statistically processed values on generalised tiles at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +115 115 Individual ensemble forecast, control and perturbed on generalised tiles at a horizontal level or in a horizontal layer at a point in time +116 116 Individual ensemble forecast, control and perturbed on generalised tiles at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +117 117 Individual large ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +118 118 Individual large ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +119 119 Probability forecasts from large ensembles at a horizontal level or in a horizontal layer at a point in time +120 120 Probability forecasts from large ensembles at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +121 121 Probability forecasts from large ensembles with spatiotemporal processing based on focal (moving window) statistics at a horizontal level or in a horizontal layer at a point in time +122 122 Probability forecasts from large ensembles with spatiotemporal processing based on focal (moving window) statistics at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +123 123 Probability forecasts from large ensembles with spatiotemporal processing based on focal (moving window) statistics in relation to a reference period at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +124 124 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for radionuclides +125 125 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for radionuclides +126 126 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for radionuclides +127 127 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for radionuclides +# 128-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing +# 1102-32767 Reserved +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/33/4.1.0.table b/definitions/grib2/tables/33/4.1.0.table new file mode 100644 index 000000000..deb34a4e3 --- /dev/null +++ b/definitions/grib2/tables/33/4.1.0.table @@ -0,0 +1,29 @@ +# Product discipline 0 - Meteorological products +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +21 21 Thermodynamic properties +22 22 Drought indices +# 23-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.1.1.table b/definitions/grib2/tables/33/4.1.1.table new file mode 100644 index 000000000..df2c13fa8 --- /dev/null +++ b/definitions/grib2/tables/33/4.1.1.table @@ -0,0 +1,7 @@ +# Product discipline 1 - Hydrological products +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.1.10.table b/definitions/grib2/tables/33/4.1.10.table new file mode 100644 index 000000000..5a64f9652 --- /dev/null +++ b/definitions/grib2/tables/33/4.1.10.table @@ -0,0 +1,10 @@ +# Product discipline 10 - Oceanographic products +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Subsurface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.1.2.table b/definitions/grib2/tables/33/4.1.2.table new file mode 100644 index 000000000..9d6f690ac --- /dev/null +++ b/definitions/grib2/tables/33/4.1.2.table @@ -0,0 +1,11 @@ +# Product discipline 2 - Land surface products +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +5 5 Glaciers and inland ice +6 6 Urban areas +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.1.20.table b/definitions/grib2/tables/33/4.1.20.table new file mode 100644 index 000000000..e651e326f --- /dev/null +++ b/definitions/grib2/tables/33/4.1.20.table @@ -0,0 +1,8 @@ +# Product discipline 20 - Health and socioeconomic impacts +0 0 Health indicators +1 1 Epidemiology +2 2 Socioeconomic indicators +3 3 Renewable energy sector +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.1.3.table b/definitions/grib2/tables/33/4.1.3.table new file mode 100644 index 000000000..35d82f440 --- /dev/null +++ b/definitions/grib2/tables/33/4.1.3.table @@ -0,0 +1,11 @@ +# Product discipline 3 - Satellite remote sensing products (formerly Space products) +0 0 Image format products +1 1 Quantitative products +2 2 Cloud properties +3 3 Flight rule conditions +4 4 Volcanic ash +5 5 Sea-surface temperature +6 6 Solar radiation +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.1.4.table b/definitions/grib2/tables/33/4.1.4.table new file mode 100644 index 000000000..7d1378729 --- /dev/null +++ b/definitions/grib2/tables/33/4.1.4.table @@ -0,0 +1,15 @@ +# Product discipline 4 - Space weather products +0 0 Temperature +1 1 Momentum +2 2 Charged particle mass and number +3 3 Electric and magnetic fields +4 4 Energetic particles +5 5 Waves +6 6 Solar electromagnetic emissions +7 7 Terrestrial electromagnetic emissions +8 8 Imagery +9 9 Ion-neutral coupling +10 10 Space weather indices +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.10.table b/definitions/grib2/tables/33/4.10.table new file mode 100644 index 000000000..0acd9127c --- /dev/null +++ b/definitions/grib2/tables/33/4.10.table @@ -0,0 +1,22 @@ +# Code table 4.10 - Type of statistical processing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +11 11 Summation +12 12 Return period +13 13 Median +# 14-99 Reserved +100 100 Severity +101 101 Mode +102 102 Index processing +# 103-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/33/4.100.table b/definitions/grib2/tables/33/4.100.table new file mode 100644 index 000000000..a24770d68 --- /dev/null +++ b/definitions/grib2/tables/33/4.100.table @@ -0,0 +1,10 @@ +# Code table 4.100 - Type of reference dataset +0 0 Analysis +1 1 Forecast +2 2 Reforecast (Hindcast) +3 3 Reanalysis +4 4 Climate projection +5 5 Gridded observations +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.101.table b/definitions/grib2/tables/33/4.101.table new file mode 100644 index 000000000..0fcdb13d9 --- /dev/null +++ b/definitions/grib2/tables/33/4.101.table @@ -0,0 +1,13 @@ +# Code table 4.101 - Type of relationship to reference dataset +0 0 Anomaly +1 1 Standardized anomaly +2 2 Significance (Wilcoxon-Mann-Whitney) +3 3 Climatology +# 4-19 Reserved +20 20 Extreme Forecast Index (EFI) +21 21 Shift of Tails (SOT) +22 22 Anomaly of probabilities +23 23 Standardized Drought Index +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.102.table b/definitions/grib2/tables/33/4.102.table new file mode 100644 index 000000000..214844fb3 --- /dev/null +++ b/definitions/grib2/tables/33/4.102.table @@ -0,0 +1,22 @@ +# Code table 4.102 - Statistical processing of reference period +0 0 Average +1 1 Accumulation +2 2 Maximum +3 3 Minimum +4 4 Median +# 5-19 Reserved +20 20 Model Climate +21 21 Index based on normal distribution +22 22 Index based on log-normal distribution +23 23 Index based on generalised log-normal distribution +24 24 Index based on gamma distribution +25 25 Index based on logistic distribution +26 26 Index based on log-logistic distribution +27 27 Index based on generalised logistic distribution +28 28 Index based on Weibull distribution +29 29 Index based on generalised extreme value distribution +30 30 Index based on Pearson III distribution +31 31 Index based on empirical distribution +# 32-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.103.table b/definitions/grib2/tables/33/4.103.table new file mode 100644 index 000000000..5d70488ca --- /dev/null +++ b/definitions/grib2/tables/33/4.103.table @@ -0,0 +1,9 @@ +# Code table 4.103 - Spatial vicinity type +0 0 Circle [m] +1 1 Rectangle [m,m] +2 2 Square [m] +3 3 Wedge [m, degree, degree] +4 4 Span of grid boxes centered around grid box i,j [x,y] +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.104.table b/definitions/grib2/tables/33/4.104.table new file mode 100644 index 000000000..d1e417780 --- /dev/null +++ b/definitions/grib2/tables/33/4.104.table @@ -0,0 +1,15 @@ +# Code table 4.104 - Spatial and temporal vicinity processing +0 0 Average +1 1 Reserved +2 2 Maximum +3 3 Minimum +4 4 Range +5 5 Reserved +6 6 Standard deviation +# 7-10 Reserved +11 11 Sum +# 12-189 Reserved +190 190 Quantile +191 191 Categorical (boolean) +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.105.table b/definitions/grib2/tables/33/4.105.table new file mode 100644 index 000000000..f3be24ecb --- /dev/null +++ b/definitions/grib2/tables/33/4.105.table @@ -0,0 +1,6 @@ +# Code table 4.105 - Spatial and temporal vicinity missing data +0 0 Ignore missing data +1 1 No data +# 2-189 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.11.table b/definitions/grib2/tables/33/4.11.table new file mode 100644 index 000000000..01cc81303 --- /dev/null +++ b/definitions/grib2/tables/33/4.11.table @@ -0,0 +1,10 @@ +# Code table 4.11 - Type of time intervals +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.12.table b/definitions/grib2/tables/33/4.12.table new file mode 100644 index 000000000..d42b47e96 --- /dev/null +++ b/definitions/grib2/tables/33/4.12.table @@ -0,0 +1,7 @@ +# Code table 4.12 - Operating mode +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.13.table b/definitions/grib2/tables/33/4.13.table new file mode 100644 index 000000000..a0e28eac8 --- /dev/null +++ b/definitions/grib2/tables/33/4.13.table @@ -0,0 +1,6 @@ +# Code table 4.13 - Quality control indicator +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.14.table b/definitions/grib2/tables/33/4.14.table new file mode 100644 index 000000000..d525b23b3 --- /dev/null +++ b/definitions/grib2/tables/33/4.14.table @@ -0,0 +1,6 @@ +# Code table 4.14 - Clutter filter indicator +0 0 No clutter filter used +1 1 Clutter filter used +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.15.table b/definitions/grib2/tables/33/4.15.table new file mode 100644 index 000000000..7adddedb6 --- /dev/null +++ b/definitions/grib2/tables/33/4.15.table @@ -0,0 +1,11 @@ +# Code table 4.15 - Type of spatial processing used to arrive at given data value from the source data +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.16.table b/definitions/grib2/tables/33/4.16.table new file mode 100644 index 000000000..5b9f6fd73 --- /dev/null +++ b/definitions/grib2/tables/33/4.16.table @@ -0,0 +1,10 @@ +# Code table 4.16 - Quality value associated with parameter +0 0 Confidence index +1 1 Quality indicator +2 2 Correlation of product with used calibration product +3 3 Standard deviation +4 4 Random error +5 5 Probability +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.192.table b/definitions/grib2/tables/33/4.192.table new file mode 100644 index 000000000..e1fd91594 --- /dev/null +++ b/definitions/grib2/tables/33/4.192.table @@ -0,0 +1,4 @@ +1 1 first +2 2 second +3 3 third +4 4 fourth diff --git a/definitions/grib2/tables/33/4.2.0.0.table b/definitions/grib2/tables/33/4.2.0.0.table new file mode 100644 index 000000000..e4912c9d6 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.0.table @@ -0,0 +1,37 @@ +# Product discipline 0 - Meteorological products, parameter category 0: temperature +0 0 Temperature (K) +1 1 Virtual temperature (K) +2 2 Potential temperature (K) +3 3 Pseudo-adiabatic potential temperature or equivalent potential temperature (K) +4 4 Maximum temperature (K) +5 5 Minimum temperature (K) +6 6 Dewpoint temperature (K) +7 7 Dewpoint depression (or deficit) (K) +8 8 Lapse rate (K/m) +9 9 Temperature anomaly (K) +10 10 Latent heat net flux (W m-2) +11 11 Sensible heat net flux (W m-2) +12 12 Heat index (K) +13 13 Wind chill factor (K) +14 14 Minimum dewpoint depression (K) +15 15 Virtual potential temperature (K) +16 16 Snow phase change heat flux (W m-2) +17 17 Skin temperature (K) +18 18 Snow temperature (top of snow) (K) +19 19 Turbulent transfer coefficient for heat (Numeric) +20 20 Turbulent diffusion coefficient for heat (m2/s) +21 21 Apparent temperature (K) +22 22 Temperature tendency due to short-wave radiation (K s-1) +23 23 Temperature tendency due to long-wave radiation (K s-1) +24 24 Temperature tendency due to short-wave radiation, clear sky (K s-1) +25 25 Temperature tendency due to long-wave radiation, clear sky (K s-1) +26 26 Temperature tendency due to parameterization (K s-1) +27 27 Wet-bulb temperature (K) +28 28 Unbalanced component of temperature (K) +29 29 Temperature advection (K s-1) +30 30 Latent heat net flux due to evaporation (W m-2) +31 31 Latent heat net flux due to sublimation (W m-2) +32 32 Wet-bulb potential temperature (K) +# 33-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.1.table b/definitions/grib2/tables/33/4.2.0.1.table new file mode 100644 index 000000000..2405606cb --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.1.table @@ -0,0 +1,174 @@ +# Product discipline 0 - Meteorological products, parameter category 1: moisture +0 0 Specific humidity (kg/kg) +1 1 Relative humidity (%) +2 2 Humidity mixing ratio (kg/kg) +3 3 Precipitable water (kg m-2) +4 4 Vapour pressure (Pa) +5 5 Saturation deficit (Pa) +6 6 Evaporation (kg m-2) +7 7 Precipitation rate (kg m-2 s-1) +8 8 Total precipitation (kg m-2) +9 9 Large-scale precipitation (non-convective) (kg m-2) +10 10 Convective precipitation (kg m-2) +11 11 Snow depth (m) +12 12 Snowfall rate water equivalent (kg m-2 s-1) +13 13 Water equivalent of accumulated snow depth (kg m-2) +14 14 Convective snow (kg m-2) +15 15 Large-scale snow (kg m-2) +16 16 Snow melt (kg m-2) +17 17 Snow age (d) +18 18 Absolute humidity (kg m-3) +19 19 Precipitation type (Code table 4.201) +20 20 Integrated liquid water (kg m-2) +21 21 Condensate (kg/kg) +22 22 Cloud mixing ratio (kg/kg) +23 23 Ice water mixing ratio (kg/kg) +24 24 Rain mixing ratio (kg/kg) +25 25 Snow mixing ratio (kg/kg) +26 26 Horizontal moisture convergence (kg kg-1 s-1) +27 27 Maximum relative humidity (%) +28 28 Maximum absolute humidity (kg m-3) +29 29 Total snowfall (m) +30 30 Precipitable water category (Code table 4.202) +31 31 Hail (m) +32 32 Graupel (snow pellets) (kg/kg) +33 33 Categorical rain (Code table 4.222) +34 34 Categorical freezing rain (Code table 4.222) +35 35 Categorical ice pellets (Code table 4.222) +36 36 Categorical snow (Code table 4.222) +37 37 Convective precipitation rate (kg m-2 s-1) +38 38 Horizontal moisture divergence (kg kg-1 s-1) +39 39 Per cent frozen precipitation (%) +40 40 Potential evaporation (kg m-2) +41 41 Potential evaporation rate (W m-2) +42 42 Snow cover (%) +43 43 Rain fraction of total cloud water (Proportion) +44 44 Rime factor (Numeric) +45 45 Total column integrated rain (kg m-2) +46 46 Total column integrated snow (kg m-2) +47 47 Large scale water precipitation (non-convective) (kg m-2) +48 48 Convective water precipitation (kg m-2) +49 49 Total water precipitation (kg m-2) +50 50 Total snow precipitation (kg m-2) +51 51 Total column water [Vertically integrated total water=vapour + cloud water/ice] (kg m-2) +52 52 Total precipitation rate (kg m-2 s-1) +53 53 Total snowfall rate water equivalent (kg m-2 s-1) +54 54 Large scale precipitation rate (kg m-2 s-1) +55 55 Convective snowfall rate water equivalent (kg m-2 s-1) +56 56 Large scale snowfall rate water equivalent (kg m-2 s-1) +57 57 Total snowfall rate (m/s) +58 58 Convective snowfall rate (m/s) +59 59 Large scale snowfall rate (m/s) +60 60 Snow depth water equivalent (kg m-2) +61 61 Snow density (kg m-3) +62 62 Snow evaporation (kg m-2) +63 63 Reserved +64 64 Total column integrated water vapour (kg m-2) +65 65 Rain precipitation rate (kg m-2 s-1) +66 66 Snow precipitation rate (kg m-2 s-1) +67 67 Freezing rain precipitation rate (kg m-2 s-1) +68 68 Ice pellets precipitation rate (kg m-2 s-1) +69 69 Total column integrated cloud water (kg m-2) +70 70 Total column integrated cloud ice (kg m-2) +71 71 Hail mixing ratio (kg/kg) +72 72 Total column integrated hail (kg m-2) +73 73 Hail precipitation rate (kg m-2 s-1) +74 74 Total column integrated graupel (kg m-2) +75 75 Graupel (snow pellets) precipitation rate (kg m-2 s-1) +76 76 Convective rain rate (kg m-2 s-1) +77 77 Large scale rain rate (kg m-2 s-1) +78 78 Total column integrated water (all components including precipitation) (kg m-2) +79 79 Evaporation rate (kg m-2 s-1) +80 80 Total condensate (kg/kg) +81 81 Total column-integrated condensate (kg m-2) +82 82 Cloud ice mixing-ratio (kg/kg) +83 83 Specific cloud liquid water content (kg/kg) +84 84 Specific cloud ice water content (kg/kg) +85 85 Specific rainwater content (kg/kg) +86 86 Specific snow water content (kg/kg) +87 87 Stratiform precipitation rate (kg m-2 s-1) +88 88 Categorical convective precipitation (Code table 4.222) +# 89 Reserved +90 90 Total kinematic moisture flux (kg kg-1 m s-1) +91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) +92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) +93 93 Relative humidity with respect to water (%) +94 94 Relative humidity with respect to ice (%) +95 95 Freezing or frozen precipitation rate (kg m-2 s-1) +96 96 Mass density of rain (kg m-3) +97 97 Mass density of snow (kg m-3) +98 98 Mass density of graupel (kg m-3) +99 99 Mass density of hail (kg m-3) +100 100 Specific number concentration of rain (kg-1) +101 101 Specific number concentration of snow (kg-1) +102 102 Specific number concentration of graupel (kg-1) +103 103 Specific number concentration of hail (kg-1) +104 104 Number density of rain (m-3) +105 105 Number density of snow (m-3) +106 106 Number density of graupel (m-3) +107 107 Number density of hail (m-3) +108 108 Specific humidity tendency due to parameterization (kg kg-1 s-1) +109 109 Mass density of liquid water coating on hail expressed as mass of liquid water per unit volume of air (kg m-3) +110 110 Specific mass of liquid water coating on hail expressed as mass of liquid water per unit mass of moist air (kg kg-1) +111 111 Mass mixing ratio of liquid water coating on hail expressed as mass of liquid water per unit mass of dry air (kg kg-1) +112 112 Mass density of liquid water coating on graupel expressed as mass of liquid water per unit volume of air (kg m-3) +113 113 Specific mass of liquid water coating on graupel expressed as mass of liquid water per unit mass of moist air (kg kg-1) +114 114 Mass mixing ratio of liquid water coating on graupel expressed as mass of liquid water per unit mass of dry air (kg kg-1) +115 115 Mass density of liquid water coating on snow expressed as mass of liquid water per unit volume of air (kg m-3) +116 116 Specific mass of liquid water coating on snow expressed as mass of liquid water per unit mass of moist air (kg kg-1) +117 117 Mass mixing ratio of liquid water coating on snow expressed as mass of liquid water per unit mass of dry air (kg kg-1) +118 118 Unbalanced component of specific humidity (kg kg-1) +119 119 Unbalanced component of specific cloud liquid water content (kg kg-1) +120 120 Unbalanced component of specific cloud ice water content (kg kg-1) +121 121 Fraction of snow cover (Proportion) +122 122 Precipitation intensity index (Code table 4.247) +123 123 Dominant precipitation type (Code table 4.201) +124 124 Presence of showers (Code table 4.222) +125 125 Presence of blowing snow (Code table 4.222) +126 126 Presence of blizzard (Code table 4.222) +127 127 Ice pellets (non-water equivalent) precipitation rate (m/s) +128 128 Total solid precipitation rate (kg m-2 s-1) +129 129 Effective radius of cloud water (m) +130 130 Effective radius of rain (m) +131 131 Effective radius of cloud ice (m) +132 132 Effective radius of snow (m) +133 133 Effective radius of graupel (m) +134 134 Effective radius of hail (m) +135 135 Effective radius of subgrid liquid clouds (m) +136 136 Effective radius of subgrid ice clouds (m) +137 137 Effective aspect ratio of rain (-) +138 138 Effective aspect ratio of cloud ice (-) +139 139 Effective aspect ratio of snow (-) +140 140 Effective aspect ratio of graupel (-) +141 141 Effective aspect ratio of hail (-) +142 142 Effective aspect ratio of subgrid ice clouds (-) +143 143 Potential evaporation rate (kg m-2 s-1) +144 144 Specific rain water content (convective) (kg kg-1) +145 145 Specific snow water content (convective) (kg kg-1) +146 146 Cloud ice precipitation rate (kg m-2 s-1) +147 147 Character of precipitation (Code table 4.249) +148 148 Snow evaporation rate (kg m-2 s-1) +149 149 Cloud water mixing ratio (kg kg-1) +150 150 Column integrated eastward water vapour mass flux (kg m-1 s-1) +151 151 Column integrated northward water vapour mass flux (kg m-1 s-1) +152 152 Column integrated eastward cloud liquid water mass flux (kg m-1 s-1) +153 153 Column integrated northward cloud liquid water mass flux (kg m-1 s-1) +154 154 Column integrated eastward cloud ice mass flux (kg m-1 s-1) +155 155 Column integrated northward cloud ice mass flux (kg m-1 s-1) +156 156 Column integrated eastward rain mass flux (kg m-1 s-1) +157 157 Column integrated northward rain mass flux (kg m-1 s-1) +158 158 Column integrated eastward snow mass flux (kg m-1 s-1) +159 159 Column integrated northward snow mass flux (kg m-1 s-1) +160 160 Column integrated divergence of water vapour mass flux (kg m-2 s-1) +161 161 Column integrated divergence of cloud liquid water mass flux (kg m-2 s-1) +162 162 Column integrated divergence of cloud ice mass flux (kg m-2 s-1) +163 163 Column integrated divergence of rain mass flux (kg m-2 s-1) +164 164 Column integrated divergence of snow mass flux (kg m-2 s-1) +165 165 Column integrated divergence of total water mass flux (kg m-2 s-1) +166 166 Column integrated water vapour flux (kg m-2 s-1) +167 167 Total column supercooled liquid water (kg m-2) +168 168 Saturation specific humidity with respect to water (kg m-3) +169 169 Total column integrated saturation specific humidity with respect to water (kg m-2) +# 170-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.13.table b/definitions/grib2/tables/33/4.2.0.13.table new file mode 100644 index 000000000..4c1253b96 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.13.table @@ -0,0 +1,5 @@ +# Product discipline 0 - Meteorological products, parameter category 13: aerosols +0 0 Aerosol type (Code table 4.205) +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.14.table b/definitions/grib2/tables/33/4.2.0.14.table new file mode 100644 index 000000000..df0f721ea --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.14.table @@ -0,0 +1,7 @@ +# Product discipline 0 - Meteorological products, parameter category 14: trace gases +0 0 Total ozone (DU) +1 1 Ozone mixing ratio (kg/kg) +2 2 Total column integrated ozone (DU) +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.15.table b/definitions/grib2/tables/33/4.2.0.15.table new file mode 100644 index 000000000..ac49ad402 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.15.table @@ -0,0 +1,21 @@ +# Product discipline 0 - Meteorological products, parameter category 15: radar +0 0 Base spectrum width (m/s) +1 1 Base reflectivity (dB) +2 2 Base radial velocity (m/s) +3 3 Vertically integrated liquid water (VIL) (kg m-2) +4 4 Layer-maximum base reflectivity (dB) +5 5 Precipitation (kg m-2) +6 6 Radar spectra (1) (-) +7 7 Radar spectra (2) (-) +8 8 Radar spectra (3) (-) +9 9 Reflectivity of cloud droplets (dB) +10 10 Reflectivity of cloud ice (dB) +11 11 Reflectivity of snow (dB) +12 12 Reflectivity of rain (dB) +13 13 Reflectivity of graupel (dB) +14 14 Reflectivity of hail (dB) +15 15 Hybrid scan reflectivity (dB) +16 16 Hybrid scan reflectivity height (m) +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.16.table b/definitions/grib2/tables/33/4.2.0.16.table new file mode 100644 index 000000000..111e6d986 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.16.table @@ -0,0 +1,10 @@ +# Product discipline 0 - Meteorological products, parameter category 16: forecast radar imagery +0 0 Equivalent radar reflectivity factor for rain (mm6 m-3) +1 1 Equivalent radar reflectivity factor for snow (mm6 m-3) +2 2 Equivalent radar reflectivity factor for parameterized convection (mm6 m-3) +3 3 Echo top (m) +4 4 Reflectivity (dB) +5 5 Composite reflectivity (dB) +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.17.table b/definitions/grib2/tables/33/4.2.0.17.table new file mode 100644 index 000000000..90ef72d87 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.17.table @@ -0,0 +1,7 @@ +# Product discipline 0 - Meteorological products, parameter category 17: electrodynamics +0 0 Lightning strike density (m-2 s-1) +1 1 Lightning potential index (LPI) (J kg-1) +2 2 Cloud-to-ground lightning flash density (km-2 day-1) +3 3 Cloud-to-cloud lightning flash density (km-2 day-1) +4 4 Total lightning flash density (km-2 day-1) +5 5 Subgrid-scale lightning potential index (J kg-1) diff --git a/definitions/grib2/tables/33/4.2.0.18.table b/definitions/grib2/tables/33/4.2.0.18.table new file mode 100644 index 000000000..6efa6e5e0 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.18.table @@ -0,0 +1,31 @@ +# Product discipline 0 - Meteorological products, parameter category 18: nuclear/radiology +0 0 Air activity concentration of caesium 137 (Bq m-3) +1 1 Air activity concentration of iodine 131 (Bq m-3) +2 2 Air activity concentration of radioactive pollutant (Bq m-3) +3 3 Ground deposition activity of caesium 137 (Bq m-2) +4 4 Ground deposition activity of iodine 131 (Bq m-2) +5 5 Ground deposition activity of radioactive pollutant (Bq m-2) +6 6 Time-integrated air activity concentration of caesium pollutant (Bq s m-3) +7 7 Time-integrated air activity concentration of iodine pollutant (Bq s m-3) +8 8 Time-integrated air activity concentration of radioactive pollutant (Bq s m-3) +9 9 Reserved +10 10 Air activity concentration (Bq m-3) +11 11 Wet deposition activity (Bq m-2) +12 12 Dry deposition activity (Bq m-2) +13 13 Total deposition activity (wet + dry) (Bq m-2) +14 14 Specific activity concentration (Bq kg-1) +15 15 Maximum of air activity concentration in layer (Bq m-3) +16 16 Height of maximum air activity concentration (m) +17 17 Column-integrated air activity concentration (Bq m-2) +18 18 Column-averaged air activity concentration in layer (Bq m-3) +19 19 Deposition activity arrival (s) +20 20 Deposition activity ended (s) +21 21 Cloud activity arrival (s) +22 22 Cloud activity ended (s) +23 23 Effective dose rate (nSv h-1) +24 24 Thyroid dose rate (adult) (nSv h-1) +25 25 Gamma dose rate (adult) (nSv h-1) +26 26 Activity emission (Bq s-1) +# 27-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.19.table b/definitions/grib2/tables/33/4.2.0.19.table new file mode 100644 index 000000000..be45d7a0d --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.19.table @@ -0,0 +1,55 @@ +# Product discipline 0 - Meteorological products, parameter category 19: physical atmospheric properties +0 0 Visibility (m) +1 1 Albedo (%) +2 2 Thunderstorm probability (%) +3 3 Mixed layer depth (m) +4 4 Volcanic ash (Code table 4.206) +5 5 Icing top (m) +6 6 Icing base (m) +7 7 Icing (Code table 4.207) +8 8 Turbulence top (m) +9 9 Turbulence base (m) +10 10 Turbulence (Code table 4.208) +11 11 Turbulent kinetic energy (J/kg) +12 12 Planetary boundary-layer regime (Code table 4.209) +13 13 Contrail intensity (Code table 4.210) +14 14 Contrail engine type (Code table 4.211) +15 15 Contrail top (m) +16 16 Contrail base (m) +17 17 Maximum snow albedo (%) +18 18 Snow free albedo (%) +19 19 Snow albedo (%) +20 20 Icing (%) +21 21 In-cloud turbulence (%) +22 22 Clear air turbulence (CAT) (%) +23 23 Supercooled large droplet probability (%) +24 24 Convective turbulent kinetic energy (J/kg) +25 25 Weather (Code table 4.225) +26 26 Convective outlook (Code table 4.224) +27 27 Icing scenario (Code table 4.227) +28 28 Mountain wave turbulence (eddy dissipation rate) (m2/3 s-1) +29 29 Clear air turbulence (CAT) (m2/3 s-1) +30 30 Eddy dissipation parameter (m2/3 s-1) +31 31 Maximum of eddy dissipation parameter in layer (m2/3 s-1) +32 32 Highest freezing level (m) +33 33 Visibility through liquid fog (m) +34 34 Visibility through ice fog (m) +35 35 Visibility through blowing snow (m) +36 36 Presence of snow squalls (Code table 4.222) +37 37 Icing severity (Code table 4.228) +38 38 Sky transparency index (Code table 4.214) +39 39 Seeing index (Code table 4.214) +40 40 Snow level (m) +41 41 Duct base height (m) +42 42 Trapping layer base height (m) +43 43 Trapping layer top height (m) +44 44 Mean vertical gradient of refractivity inside trapping layer (m-1) +45 45 Minimum vertical gradient of refractivity inside trapping layer (m-1) +46 46 Net radiation flux (W m-2) +47 47 Global irradiance on tilted surfaces (W m-2) +48 48 Top of persistent contrails (m) +49 49 Base of persistent contrails (m) +50 50 Convectively-induced turbulence (CIT) (eddy dissipation rate) (m2/3 s-1) +# 51-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.190.table b/definitions/grib2/tables/33/4.2.0.190.table new file mode 100644 index 000000000..dfe39840d --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.190.table @@ -0,0 +1,5 @@ +# Product discipline 0 - Meteorological products, parameter category 190: CCITT IA5 string +0 0 Arbitrary text string (CCITT IA5) +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.191.table b/definitions/grib2/tables/33/4.2.0.191.table new file mode 100644 index 000000000..5fce8eab0 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.191.table @@ -0,0 +1,12 @@ +# Product discipline 0 - Meteorological products, parameter category 191: miscellaneous +0 0 Seconds prior to initial reference time (defined in Section 1) (s) +1 1 Geographical latitude (deg N) +2 2 Geographical longitude (deg E) +3 3 Days since last observation (d) +4 4 Tropical cyclone density track (Numeric) +5 5 Hurricane track in spatiotemporal vicinity (boolean) +6 6 Tropical storm track in spatiotemporal vicinity (boolean) +7 7 Tropical depression track in spatiotemporal vicinity (boolean) +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.2.table b/definitions/grib2/tables/33/4.2.0.2.table new file mode 100644 index 000000000..bd6e32851 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.2.table @@ -0,0 +1,72 @@ +# Product discipline 0 - Meteorological products, parameter category 2: momentum +0 0 Wind direction (from which blowing) (degree true) +1 1 Wind speed (m/s) +2 2 u-component of wind (m/s) +3 3 v-component of wind (m/s) +4 4 Stream function (m2/s) +5 5 Velocity potential (m2/s) +6 6 Montgomery stream function (m2 s-2) +7 7 Sigma coordinate vertical velocity (/s) +8 8 Vertical velocity (pressure) (Pa/s) +9 9 Vertical velocity (geometric) (m/s) +10 10 Absolute vorticity (/s) +11 11 Absolute divergence (/s) +12 12 Relative vorticity (/s) +13 13 Relative divergence (/s) +14 14 Potential vorticity (K m2 kg-1 s-1) +15 15 Vertical u-component shear (/s) +16 16 Vertical v-component shear (/s) +17 17 Momentum flux, u-component (N m-2) +18 18 Momentum flux, v-component (N m-2) +19 19 Wind mixing energy (J) +20 20 Boundary layer dissipation (W m-2) +21 21 Maximum wind speed (m/s) +22 22 Wind speed (gust) (m/s) +23 23 u-component of wind (gust) (m/s) +24 24 v-component of wind (gust) (m/s) +25 25 Vertical speed shear (/s) +26 26 Horizontal momentum flux (N m-2) +27 27 u-component storm motion (m/s) +28 28 v-component storm motion (m/s) +29 29 Drag coefficient (Numeric) +30 30 Frictional velocity (m/s) +31 31 Turbulent diffusion coefficient for momentum (m2/s) +32 32 Eta coordinate vertical velocity (/s) +33 33 Wind fetch (m) +34 34 Normal wind component (m/s) +35 35 Tangential wind component (m/s) +36 36 Amplitude function for Rossby wave envelope for meridional wind (m/s) +37 37 Northward turbulent surface stress (N m-2 s) +38 38 Eastward turbulent surface stress (N m-2 s) +39 39 Eastward wind tendency due to parameterization (m s-2) +40 40 Northward wind tendency due to parameterization (m s-2) +41 41 u-component of geostrophic wind (m s-1) +42 42 v-component of geostrophic wind (m s-1) +43 43 Geostrophic wind direction (degree true) +44 44 Geostrophic wind speed (m s-1) +45 45 Unbalanced component of divergence (s-1) +46 46 Vorticity advection (s-2) +47 47 Surface roughness for heat (m) +48 48 Surface roughness for moisture (m) +49 49 Wind stress (N m-2) +50 50 Eastward wind stress (N m-2) +51 51 Northward wind stress (N m-2) +52 52 u-component of wind stress (N m-2) +53 53 v-component of wind stress (N m-2) +54 54 Natural logarithm of surface roughness length for heat (Numeric) +55 55 Natural logarithm of surface roughness length for moisture (Numeric) +56 56 u-component of neutral wind (m s-1) +57 57 v-component of neutral wind (m s-1) +58 58 Magnitude of turbulent surface stress (N m-2) +59 59 Vertical divergence (s-1) +60 60 Drag thermal coefficient (Numeric) +61 61 Drag evaporation coefficient (Numeric) +62 62 Eastward turbulent surface stress (N m-2) +63 63 Northward turbulent surface stress (N m-2) +64 64 Eastward turbulent surface stress due to orographic form drag (N m-2) +65 65 Northward turbulent surface stress due to orographic form drag (N m-2) +66 66 Eastward turbulent surface stress due to surface roughness (N m-2) +67 67 Northward turbulent surface stress due to surface roughness (N m-2) +# 68-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.20.table b/definitions/grib2/tables/33/4.2.0.20.table new file mode 100644 index 000000000..7855a8618 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.20.table @@ -0,0 +1,69 @@ +# Product discipline 0 - Meteorological products, parameter category 20: atmospheric chemical constituents +0 0 Mass density (concentration) (kg m-3) +1 1 Column-integrated mass density (kg m-2) +2 2 Mass mixing ratio (mass fraction in air) (kg/kg) +3 3 Atmosphere emission mass flux (kg m-2 s-1) +4 4 Atmosphere net production mass flux (kg m-2 s-1) +5 5 Atmosphere net production and emission mass flux (kg m-2 s-1) +6 6 Surface dry deposition mass flux (kg m-2 s-1) +7 7 Surface wet deposition mass flux (kg m-2 s-1) +8 8 Atmosphere re-emission mass flux (kg m-2 s-1) +9 9 Wet deposition by large-scale precipitation mass flux (kg m-2 s-1) +10 10 Wet deposition by convective precipitation mass flux (kg m-2 s-1) +11 11 Sedimentation mass flux (kg m-2 s-1) +12 12 Dry deposition mass flux (kg m-2 s-1) +13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) +14 14 Transfer from SO2 (sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) +15 15 Dry deposition velocity (m/s) +16 16 Mass mixing ratio with respect to dry air (kg/kg) +17 17 Mass mixing ratio with respect to wet air (kg/kg) +18 18 Potential of hydrogen (pH) (pH) +# 19-49 Reserved +50 50 Amount in atmosphere (mol) +51 51 Concentration in air (mol m-3) +52 52 Volume mixing ratio (fraction in air) (mol/mol) +53 53 Chemical gross production rate of concentration (mol m-3 s-1) +54 54 Chemical gross destruction rate of concentration (mol m-3 s-1) +55 55 Surface flux (mol m-2 s-1) +56 56 Changes of amount in atmosphere (mol/s) +57 57 Total yearly average burden of the atmosphere (mol) +58 58 Total yearly averaged atmospheric loss (mol/s) +59 59 Aerosol number concentration (m-3) +60 60 Aerosol specific number concentration (kg-1) +61 61 Maximum of mass density in layer (kg m-3) +62 62 Height of maximum mass density (m) +63 63 Column-averaged mass density in layer (kg m-3) +64 64 Mole fraction with respect to dry air (mol/mol) +65 65 Mole fraction with respect to wet air (mol/mol) +66 66 Column-integrated in-cloud scavenging rate by precipitation (kg m-2 s-1) +67 67 Column-integrated below-cloud scavenging rate by precipitation (kg m-2 s-1) +68 68 Column-integrated release rate from evaporating precipitation (kg m-2 s-1) +69 69 Column-integrated in-cloud scavenging rate by large-scale precipitation (kg m-2 s-1) +70 70 Column-integrated below-cloud scavenging rate by large-scale precipitation (kg m-2 s-1) +71 71 Column-integrated release rate from evaporating large-scale precipitation (kg m-2 s-1) +72 72 Column-integrated in-cloud scavenging rate by convective precipitation (kg m-2 s-1) +73 73 Column-integrated below-cloud scavenging rate by convective precipitation (kg m-2 s-1) +74 74 Column-integrated release rate from evaporating convective precipitation (kg m-2 s-1) +75 75 Wildfire flux (kg m-2 s-1) +76 76 Emission rate (kg kg-1 s-1) +77 77 Surface emission flux (kg m-2 s-1) +78 78 Column integrated eastward mass flux (kg m-1 s-1) +79 79 Column integrated northward mass flux (kg m-1 s-1) +80 80 Column integrated divergence of mass flux (kg m-2 s-1) +81 81 Column integrated net source (kg m-2 s-1) +# 82-99 Reserved +100 100 Surface area density (aerosol) (/m) +101 101 Vertical visual range (m) +102 102 Aerosol optical thickness (Numeric) +103 103 Single scattering albedo (Numeric) +104 104 Asymmetry factor (Numeric) +105 105 Aerosol extinction coefficient (/m) +106 106 Aerosol absorption coefficient (/m) +107 107 Aerosol lidar backscatter from satellite (m-1 sr-1) +108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) +109 109 Aerosol lidar extinction from satellite (/m) +110 110 Aerosol lidar extinction from the ground (/m) +111 111 Angstrom exponent (Numeric) +# 112-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.21.table b/definitions/grib2/tables/33/4.2.0.21.table new file mode 100644 index 000000000..05646e1a6 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.21.table @@ -0,0 +1,27 @@ +# Product discipline 0 - Meteorological products, parameter category 21: thermodynamic properties +0 0 Column integrated potential + internal energy (J m-2) +1 1 Column integrated kinetic energy (J m-2) +2 2 Column integrated total energy (J m-2) +3 3 Column integrated enthalpy (J m-2) +4 4 Column integrated water enthalpy (J m-2) +5 5 Column integrated eastward enthalpy flux (W m-1) +6 6 Column integrated northward enthalpy flux (W m-1) +7 7 Column integrated eastward potential energy flux (W m-1) +8 8 Column integrated northward potential energy flux (W m-1) +9 9 Column integrated eastward kinetic energy flux (W m-1) +10 10 Column integrated northward kinetic energy flux (W m-1) +11 11 Column integrated eastward total energy flux (W m-1) +12 12 Column integrated northward total energy flux (W m-1) +13 13 Divergence of column integrated enthalpy flux (W m-2) +14 14 Divergence of column integrated potential energy flux (W m-2) +15 15 Divergence of column integrated water potential energy flux (W m-2) +16 16 Divergence of column integrated kinetic energy flux (W m-2) +17 17 Divergence of column integrated total energy flux (W m-2) +18 18 Divergence of column integrated water enthalpy flux (W m-2) +19 19 Column integrated eastward heat flux (W m-1) +20 20 Column integrated northward heat flux (W m-1) +21 21 Column integrated potential+internal+latent energy (J m-2) +22 22 Eady growth rate (day-1) +# 23-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.22.table b/definitions/grib2/tables/33/4.2.0.22.table new file mode 100644 index 000000000..726bda9c0 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.22.table @@ -0,0 +1,11 @@ +# Product discipline 0 - Meteorological products, parameter category 22: drought indices +0 0 Standard Precipitation Index (SPI) (dimensionless) +1 1 Standardized Precipitation Evapotranspiration Index (SPEI) (dimensionless) +2 2 Standardized Streamflow index (SSFI) (dimensionless) +3 3 Standardized Reservoir Supply Index (SRSI) (dimensionless) +4 4 Standardized Water-level Index (SWI) (dimensionless) +5 5 Standardized Snowmelt and Rain Index (SMRI) (dimensionless) +6 6 Streamflow Drought Index (SDI) (dimensionless) +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.3.table b/definitions/grib2/tables/33/4.2.0.3.table new file mode 100644 index 000000000..d685de2ef --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.3.table @@ -0,0 +1,51 @@ +# Product discipline 0 - Meteorological products, parameter category 3: mass +0 0 Pressure (Pa) +1 1 Pressure reduced to MSL (Pa) +2 2 Pressure tendency (Pa/s) +3 3 ICAO Standard Atmosphere Reference Height (m) +4 4 Geopotential (m2 s-2) +5 5 Geopotential height (gpm) +6 6 Geometric height (m) +7 7 Standard deviation of height (m) +8 8 Pressure anomaly (Pa) +9 9 Geopotential height anomaly (gpm) +10 10 Density (kg m-3) +11 11 Altimeter setting (Pa) +12 12 Thickness (m) +13 13 Pressure altitude (m) +14 14 Density altitude (m) +15 15 5-wave geopotential height (gpm) +16 16 Zonal flux of gravity wave stress (N m-2) +17 17 Meridional flux of gravity wave stress (N m-2) +18 18 Planetary boundary layer height (m) +19 19 5-wave geopotential height anomaly (gpm) +20 20 Standard deviation of sub-grid scale orography (m) +21 21 Angle of sub-gridscale orography (rad) +22 22 Slope of sub-gridscale orography (Numeric) +23 23 Gravity wave dissipation (W m-2) +24 24 Anisotropy of sub-gridscale orography (Numeric) +25 25 Natural logarithm of pressure in Pa (Numeric) +26 26 Exner pressure (Numeric) +27 27 Updraught mass flux (kg m-2 s-1) +28 28 Downdraught mass flux (kg m-2 s-1) +29 29 Updraught detrainment rate (kg m-3 s-1) +30 30 Downdraught detrainment rate (kg m-3 s-1) +31 31 Unbalanced component of logarithm of surface pressure (-) +32 32 Saturation water vapour pressure (Pa) +33 33 Geometric altitude above mean sea level (m) +34 34 Geometric height above ground level (m) +35 35 Column integrated divergence of total mass flux (kg m-2 s-1) +36 36 Column integrated eastward total mass flux (kg m-1 s-1) +37 37 Column integrated northward total mass flux (kg m-1 s-1) +38 38 Standard deviation of filtered subgrid orography (m) +39 39 Column integrated mass of atmosphere (kg m-2) +40 40 Column integrated eastward geopotential flux (W m-1) +41 41 Column integrated northward geopotential flux (W m-1) +42 42 Column integrated divergence of water geopotential flux (W m-2) +43 43 Column integrated divergence of geopotential flux (W m-2) +44 44 Height of zero-degree wet-bulb temperature (m) +45 45 Height of one-degree wet-bulb temperature (m) +46 46 Pressure departure from hydrostatic state (Pa) +# 47-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.4.table b/definitions/grib2/tables/33/4.2.0.4.table new file mode 100644 index 000000000..88c24ae52 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.4.table @@ -0,0 +1,33 @@ +# Product discipline 0 - Meteorological products, parameter category 4: short-wave radiation +0 0 Net short-wave radiation flux (surface) (W m-2) +1 1 Net short-wave radiation flux (top of atmosphere) (W m-2) +2 2 Short-wave radiation flux (W m-2) +3 3 Global radiation flux (W m-2) +4 4 Brightness temperature (K) +5 5 Radiance (with respect to wave number) (W m-1 sr-1) +6 6 Radiance (with respect to wavelength) (W m-3 sr-1) +7 7 Downward short-wave radiation flux (W m-2) +8 8 Upward short-wave radiation flux (W m-2) +9 9 Net short wave radiation flux (W m-2) +10 10 Photosynthetically active radiation (W m-2) +11 11 Net short-wave radiation flux, clear sky (W m-2) +12 12 Downward UV radiation (W m-2) +13 13 Direct short-wave radiation flux (W m-2) +14 14 Diffuse short-wave radiation flux (W m-2) +15 15 Upward UV radiation emitted/reflected from the Earth's surface (W m-2) +# 16-49 Reserved +50 50 UV index (under clear sky) (Numeric) +51 51 UV index (Numeric) +52 52 Downward short-wave radiation flux, clear sky (W m-2) +53 53 Upward short-wave radiation flux, clear sky (W m-2) +54 54 Direct normal short-wave radiation flux (W m-2) +55 55 UV visible albedo for diffuse radiation (%) +56 56 UV visible albedo for direct radiation (%) +57 57 UV visible albedo for direct radiation, geometric component (%) +58 58 UV visible albedo for direct radiation, isotropic component (%) +59 59 UV visible albedo for direct radiation, volumetric component (%) +60 60 Photosynthetically active radiation flux, clear sky (W m-2) +61 61 Direct short-wave radiation flux, clear sky (W m-2) +# 62-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.5.table b/definitions/grib2/tables/33/4.2.0.5.table new file mode 100644 index 000000000..7065106a2 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.5.table @@ -0,0 +1,18 @@ +# Product discipline 0 - Meteorological products, parameter category 5: long-wave radiation +0 0 Net long-wave radiation flux (surface) (W m-2) +1 1 Net long-wave radiation flux (top of atmosphere) (W m-2) +2 2 Long-wave radiation flux (W m-2) +3 3 Downward long-wave radiation flux (W m-2) +4 4 Upward long-wave radiation flux (W m-2) +5 5 Net long-wave radiation flux (W m-2) +6 6 Net long-wave radiation flux, clear sky (W m-2) +7 7 Brightness temperature (K) +8 8 Downward long-wave radiation flux, clear sky (W m-2) +9 9 Near IR albedo for diffuse radiation (%) +10 10 Near IR albedo for direct radiation (%) +11 11 Near IR albedo for direct radiation, geometric component (%) +12 12 Near IR albedo for direct radiation, isotropic component (%) +13 13 Near IR albedo for direct radiation, volumetric component (%) +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.6.table b/definitions/grib2/tables/33/4.2.0.6.table new file mode 100644 index 000000000..d831f3474 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.6.table @@ -0,0 +1,51 @@ +# Product discipline 0 - Meteorological products, parameter category 6: cloud +0 0 Cloud ice (kg m-2) +1 1 Total cloud cover (%) +2 2 Convective cloud cover (%) +3 3 Low cloud cover (%) +4 4 Medium cloud cover (%) +5 5 High cloud cover (%) +6 6 Cloud water (kg m-2) +7 7 Cloud amount (%) +8 8 Cloud type (Code table 4.203) +9 9 Thunderstorm maximum tops (m) +10 10 Thunderstorm coverage (Code table 4.204) +11 11 Cloud base (m) +12 12 Cloud top (m) +13 13 Ceiling (m) +14 14 Non-convective cloud cover (%) +15 15 Cloud work function (J/kg) +16 16 Convective cloud efficiency (Proportion) +17 17 Total condensate (kg/kg) +18 18 Total column-integrated cloud water (kg m-2) +19 19 Total column-integrated cloud ice (kg m-2) +20 20 Total column-integrated condensate (kg m-2) +21 21 Ice fraction of total condensate (Proportion) +22 22 Cloud cover (%) +23 23 Cloud ice mixing ratio (kg/kg) +24 24 Sunshine (Numeric) +25 25 Horizontal extent of cumulonimbus (CB) (%) +26 26 Height of convective cloud base (m) +27 27 Height of convective cloud top (m) +28 28 Number of cloud droplets per unit mass of air (/kg) +29 29 Number of cloud ice particles per unit mass of air (/kg) +30 30 Number density of cloud droplets (m-3) +31 31 Number density of cloud ice particles (m-3) +32 32 Fraction of cloud cover (Numeric) +33 33 Sunshine duration (s) +34 34 Surface long-wave effective total cloudiness (Numeric) +35 35 Surface short-wave effective total cloudiness (Numeric) +36 36 Fraction of stratiform precipitation cover (Proportion) +37 37 Fraction of convective precipitation cover (Proportion) +38 38 Mass density of cloud droplets (kg m-3) +39 39 Mass density of cloud ice (kg m-3) +40 40 Mass density of convective cloud water droplets (kg m-3) +# 41-46 Reserved +47 47 Volume fraction of cloud water droplets (Numeric) +48 48 Volume fraction of cloud ice particles (Numeric) +49 49 Volume fraction of cloud (ice and/or water) (Numeric) +50 50 Fog (%) +51 51 Sunshine duration fraction (Proportion) +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.0.7.table b/definitions/grib2/tables/33/4.2.0.7.table new file mode 100644 index 000000000..15acb1857 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.0.7.table @@ -0,0 +1,25 @@ +# Product discipline 0 - Meteorological products, parameter category 7: thermodynamic stability indices +0 0 Parcel lifted index (to 500 hPa) (K) +1 1 Best lifted index (to 500 hPa) (K) +2 2 K index (K) +3 3 KO index (K) +4 4 Total totals index (K) +5 5 Sweat index (Numeric) +6 6 Convective available potential energy (J/kg) +7 7 Convective inhibition (J/kg) +8 8 Storm relative helicity (J/kg) +9 9 Energy helicity index (Numeric) +10 10 Surface lifted index (K) +11 11 Best (4-layer) lifted index (K) +12 12 Richardson number (Numeric) +13 13 Showalter index (K) +14 14 Reserved +15 15 Updraught helicity (m2 s-2) +16 16 Bulk Richardson number (Numeric) +17 17 Gradient Richardson number (Numeric) +18 18 Flux Richardson number (Numeric) +19 19 Convective available potential energy - shear (m2 s-2) +20 20 Thunderstorm intensity index (Code table 4.246) +# 21-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.1.0.table b/definitions/grib2/tables/33/4.2.1.0.table new file mode 100644 index 000000000..7072b3d44 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.1.0.table @@ -0,0 +1,25 @@ +# Product discipline 1 - Hydrological products, parameter category 0: hydrology basic products +0 0 Flash flood guidance (Encoded as an accumulation over a floating subinterval of time between the reference time and valid time) (kg m-2) +1 1 Flash flood runoff (Encoded as an accumulation over a floating subinterval of time) (kg m-2) +2 2 Remotely-sensed snow cover (Code table 4.215) +3 3 Elevation of snow-covered terrain (Code table 4.216) +4 4 Snow water equivalent per cent of normal (%) +5 5 Baseflow-groundwater runoff (kg m-2) +6 6 Storm surface runoff (kg m-2) +7 7 Discharge from rivers or streams (m3/s) +8 8 Groundwater upper storage (kg m-2) +9 9 Groundwater lower storage (kg m-2) +10 10 Side flow into river channel (m3 s-1 m-1) +11 11 River storage of water (m3) +12 12 Floodplain storage of water (m3) +13 13 Water on soil surface (kg m-2) +14 14 Upstream accumulated precipitation (kg m-2) +15 15 Upstream accumulated snow melt (kg m-2) +16 16 Percolation rate (kg m-2 s-1) +17 17 River outflow of water (m3 s-1) +18 18 Floodplain outflow of water (m3 s-1) +19 19 Floodpath outflow of water (m3 s-1) +20 20 Water on surface (kg m-2) +# 21-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.1.1.table b/definitions/grib2/tables/33/4.2.1.1.table new file mode 100644 index 000000000..e3931d5e6 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.1.1.table @@ -0,0 +1,7 @@ +# Product discipline 1 - Hydrological products, parameter category 1: hydrology probabilities +0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) +1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) +2 2 Probability of 0.01 inch of precipitation (POP) (%) +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.1.2.table b/definitions/grib2/tables/33/4.2.1.2.table new file mode 100644 index 000000000..2c4e0f50d --- /dev/null +++ b/definitions/grib2/tables/33/4.2.1.2.table @@ -0,0 +1,28 @@ +# Product discipline 1 - Hydrological products, parameter category 2: inland water and sediment properties +0 0 Water depth (m) +1 1 Water temperature (K) +2 2 Water fraction (Proportion) +3 3 Sediment thickness (m) +4 4 Sediment temperature (K) +5 5 Ice thickness (m) +6 6 Ice temperature (K) +7 7 Ice cover (Proportion) +8 8 Land cover (0 = water, 1 = land) (Proportion) +9 9 Shape factor with respect to salinity profile (-) +10 10 Shape factor with respect to temperature profile in thermocline (-) +11 11 Attenuation coefficient of water with respect to solar radiation (m) +12 12 Salinity (kg/kg) +13 13 Cross-sectional area of flow in channel (m2) +14 14 Snow temperature (K) +15 15 Lake depth (m) +16 16 River depth (m) +17 17 Floodplain depth (m) +18 18 Floodplain flooded fraction (proportion) +19 19 FLoodplain flooded area (m2) +20 20 River fraction (proportion) +21 21 River area (m2) +22 22 Fraction of river coverage plus river related flooding (proportion) +23 23 Area of river coverage plus river related flooding (m2) +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.10.0.table b/definitions/grib2/tables/33/4.2.10.0.table new file mode 100644 index 000000000..92b18661a --- /dev/null +++ b/definitions/grib2/tables/33/4.2.10.0.table @@ -0,0 +1,103 @@ +# Product discipline 10 - Oceanographic products, parameter category 0: waves +0 0 Wave spectra (1) (-) +1 1 Wave spectra (2) (-) +2 2 Wave spectra (3) (-) +3 3 Significant height of combined wind waves and swell (m) +4 4 Direction of wind waves (degree true) +5 5 Significant height of wind waves (m) +6 6 Mean period of wind waves (s) +7 7 Direction of swell waves (degree true) +8 8 Significant height of swell waves (m) +9 9 Mean period of swell waves (s) +10 10 Primary wave direction (degree true) +11 11 Primary wave mean period (s) +12 12 Secondary wave direction (degree true) +13 13 Secondary wave mean period (s) +14 14 Mean direction of combined wind waves and swell (degree true) +15 15 Mean period of combined wind waves and swell (s) +16 16 Coefficient of drag with waves (-) +17 17 Friction velocity (m/s) +18 18 Wave stress (N m-2) +19 19 Normalized wave stress (-) +20 20 Mean square slope of waves (-) +21 21 u-component surface Stokes drift (m/s) +22 22 v-component surface Stokes drift (m/s) +23 23 Period of maximum individual wave height (s) +24 24 Maximum individual wave height (m) +25 25 Inverse mean wave frequency (s) +26 26 Inverse mean frequency of wind waves (s) +27 27 Inverse mean frequency of total swell (s) +28 28 Mean zero-crossing wave period (s) +29 29 Mean zero-crossing period of wind waves (s) +30 30 Mean zero-crossing period of total swell (s) +31 31 Wave directional width (-) +32 32 Directional width of wind waves (-) +33 33 Directional width of total swell (-) +34 34 Peak wave period (s) +35 35 Peak period of wind waves (s) +36 36 Peak period of total swell (s) +37 37 Altimeter wave height (m) +38 38 Altimeter corrected wave height (m) +39 39 Altimeter range relative correction (-) +40 40 10-metre neutral wind speed over waves (m/s) +41 41 10-metre wind direction over waves (deg) +42 42 Wave energy spectrum (m2 s rad-1) +43 43 Kurtosis of the sea-surface elevation due to waves (-) +44 44 Benjamin-Feir index (-) +45 45 Spectral peakedness factor (/s) +46 46 Peak wave direction (deg) +47 47 Significant wave height of first swell partition (m) +48 48 Significant wave height of second swell partition (m) +49 49 Significant wave height of third swell partition (m) +50 50 Mean wave period of first swell partition (s) +51 51 Mean wave period of second swell partition (s) +52 52 Mean wave period of third swell partition (s) +53 53 Mean wave direction of first swell partition (deg) +54 54 Mean wave direction of second swell partition (deg) +55 55 Mean wave direction of third swell partition (deg) +56 56 Wave directional width of first swell partition (-) +57 57 Wave directional width of second swell partition (-) +58 58 Wave directional width of third swell partition (-) +59 59 Wave frequency width of first swell partition (-) +60 60 Wave frequency width of second swell partition (-) +61 61 Wave frequency width of third swell partition (-) +62 62 Wave frequency width (-) +63 63 Frequency width of wind waves (-) +64 64 Frequency width of total swell (-) +65 65 Peak wave period of first swell partition (s) +66 66 Peak wave period of second swell partition (s) +67 67 Peak wave period of third swell partition (s) +68 68 Peak wave direction of first swell partition (degree true) +69 69 Peak wave direction of second swell partition (degree true) +70 70 Peak wave direction of third swell partition (degree true) +71 71 Peak direction of wind waves (degree true) +72 72 Peak direction of total swell (degree true) +73 73 Whitecap fraction (fraction) +74 74 Mean direction of total swell (degree) +75 75 Mean direction of wind waves (degree) +76 76 Charnock (Numeric) +77 77 Wave Spectral Skewness (Numeric) +78 78 Wave energy flux magnitude (W m-1) +79 79 Wave energy flux mean direction (degree true) +80 80 Ratio of wave angular and frequency width (Numeric) +81 81 Free convective velocity over the oceans (m s-1) +82 82 Air density over the oceans (kg m-3) +83 83 Normalized energy flux into waves (Numeric) +84 84 Normalized stress into ocean (Numeric) +85 85 Normalized energy flux into ocean (Numeric) +86 86 Surface elevation variance due to waves (over all frequencies and directions) (m2 s rad-1) +87 87 Wave induced mean sea level correction (m) +88 88 Spectral width index (Numeric) +89 89 Number of events in freak waves statistics (Numeric) +90 90 u-component of surface momentum flux into ocean (N m-2) +91 91 v-component of surface momentum flux into ocean (N m-2) +92 92 Wave turbulent energy flux into ocean (W m-2) +93 93 Envelop maximum individual wave height (m) +94 94 Time domain maximum individual crest height (m) +95 95 Time domain maximum individual wave height (m) +96 96 Space time maximum individual crest height (m) +97 97 Space time maximum individual wave height (m) +98 98 Goda peakedness factor (Numeric) +# 99-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.10.1.table b/definitions/grib2/tables/33/4.2.10.1.table new file mode 100644 index 000000000..aeec67455 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.10.1.table @@ -0,0 +1,11 @@ +# Product discipline 10 - Oceanographic products, parameter category 1: currents +0 0 Current direction (degree true) +1 1 Current speed (m/s) +2 2 u-component of current (m/s) +3 3 v-component of current (m/s) +4 4 Rip current occurrence probability (%) +5 5 Eastward current (m s-1) +6 6 Northward current (m s-1) +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.10.191.table b/definitions/grib2/tables/33/4.2.10.191.table new file mode 100644 index 000000000..cd4d4cde7 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.10.191.table @@ -0,0 +1,9 @@ +# Product discipline 10 - Oceanographic products, parameter category 191: miscellaneous +0 0 Seconds prior to initial reference time (defined in Section 1) (s) +1 1 Meridional overturning stream function (m3/s) +2 2 Reserved +3 3 Days since last observation (d) +4 4 Barotropic stream function (m3 s-1) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.10.2.table b/definitions/grib2/tables/33/4.2.10.2.table new file mode 100644 index 000000000..0f27bd249 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.10.2.table @@ -0,0 +1,34 @@ +# Product discipline 10 - Oceanographic products, parameter category 2: ice +0 0 Ice cover (Proportion) +1 1 Ice thickness (m) +2 2 Direction of ice drift (degree true) +3 3 Speed of ice drift (m/s) +4 4 u-component of ice drift (m/s) +5 5 v-component of ice drift (m/s) +6 6 Ice growth rate (m/s) +7 7 Ice divergence (/s) +8 8 Ice temperature (K) +9 9 Module of ice internal pressure (Pa m) +10 10 Zonal vector component of vertically integrated ice internal pressure (Pa m) +11 11 Meridional vector component of vertically integrated ice internal pressure (Pa m) +12 12 Compressive ice strength (N/m) +13 13 Snow temperature (over sea ice) (K) +14 14 Albedo (Numeric) +15 15 Sea ice volume per unit area (m3 m-2) +16 16 Snow volume over sea ice per unit area (m3 m-2) +17 17 Sea ice heat content (J m-2) +18 18 Snow over sea ice heat content (J m-2) +19 19 Ice freeboard thickness (m) +20 20 Ice melt pond fraction (fraction) +21 21 Ice melt pond depth (m) +22 22 Ice melt pond volume per unit area (m3 m-2) +23 23 Sea ice fraction tendency due to parameterization (s-1) +24 24 x-component of ice drift (m s-1) +25 25 y-component of ice drift (m s-1) +26 26 Sea ice salinity (g kg-1) +27 27 Freezing/melting potential (W m-2) +28 28 Melt onset date (Numeric) +29 29 Freeze onset date (Numeric) +# 30-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.10.3.table b/definitions/grib2/tables/33/4.2.10.3.table new file mode 100644 index 000000000..6c4277c8e --- /dev/null +++ b/definitions/grib2/tables/33/4.2.10.3.table @@ -0,0 +1,26 @@ +# Product discipline 10 - Oceanographic products, parameter category 3: surface properties +0 0 Water temperature (K) +1 1 Deviation of sea level from mean (m) +2 2 Heat exchange coefficient (-) +3 3 Practical salinity (Numeric) +4 4 Downward heat flux (W m-2) +5 5 Eastward surface stress (N m-2) +6 6 Northward surface stress (N m-2) +7 7 x-component surface stress (N m-2) +8 8 y-component surface stress (N m-2) +9 9 Thermosteric change in sea surface height (m) +10 10 Halosteric change in sea surface height (m) +11 11 Steric change in sea surface height (m) +12 12 Sea salt flux (kg m-2 s-1) +13 13 Net upward water flux (kg m-2 s-1) +14 14 Eastward surface water velocity (m s-1) +15 15 Northward surface water velocity (m s-1) +16 16 x-component of surface water velocity (m s-1) +17 17 y-component of surface water velocity (m s-1) +18 18 Heat flux correction (W m-2) +19 19 Sea surface height tendency due to parameterization (m s-1) +20 20 Deviation of sea level from mean with inverse barometer correction (m) +21 21 Salinity (kg kg-1) +# 22-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.10.4.table b/definitions/grib2/tables/33/4.2.10.4.table new file mode 100644 index 000000000..0b9ef0956 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.10.4.table @@ -0,0 +1,54 @@ +# Product discipline 10 - Oceanographic products, parameter category 4: subsurface properties +0 0 Main thermocline depth (m) +1 1 Main thermocline anomaly (m) +2 2 Transient thermocline depth (m) +3 3 Salinity (kg/kg) +4 4 Ocean vertical heat diffusivity (m2/s) +5 5 Ocean vertical salt diffusivity (m2/s) +6 6 Ocean vertical momentum diffusivity (m2/s) +7 7 Bathymetry (m) +# 8-10 Reserved +11 11 Shape factor with respect to salinity profile (-) +12 12 Shape factor with respect to temperature profile in thermocline (-) +13 13 Attenuation coefficient of water with respect to solar radiation (/m) +14 14 Water depth (m) +15 15 Water temperature (K) +16 16 Water density (rho) (kg m-3) +17 17 Water density anomaly (sigma) (kg m-3) +18 18 Water potential temperature (theta) (K) +19 19 Water potential density (rho theta) (kg m-3) +20 20 Water potential density anomaly (sigma theta) (kg m-3) +21 21 Practical salinity (Numeric) +22 22 Water column-integrated heat content (J m-2) +23 23 Eastward water velocity (m s-1) +24 24 Northward water velocity (m s-1) +25 25 x-component water velocity (m s-1) +26 26 y-component water velocity (m s-1) +27 27 Upward water velocity (m s-1) +28 28 Vertical eddy diffusivity (m2 s-1) +29 29 Bottom pressure equivalent height (m) +30 30 Fresh water flux into sea water from rivers (kg m-2 s-1) +31 31 Fresh water flux correction (kg m-2 s-1) +32 32 Virtual salt flux into sea water (g kg-1 m-2 s-1) +33 33 Virtual salt flux correction (g kg-1 m-2 s-1) +34 34 Sea water temperature tendency due to Newtonian relaxation (K s-1) +35 35 Sea water salinity tendency due to Newtonian relaxation (g kg-1 s-1) +36 36 Sea water temperature tendency due to parameterization (K s-1) +37 37 Sea water salinity tendency due to parameterization (g kg-1 s-1) +38 38 Eastward sea water velocity tendency due to parameterization (m s-2) +39 39 Northward sea water velocity tendency due to parameterization (m s-2) +40 40 Sea water temperature tendency due to direct bias correction (K s-1) +41 41 Sea water salinity tendency due to direct bias correction (g kg-1 s-1) +42 42 Sea water meridional volume transport (m3 m-2 s-1) +43 43 Sea water zonal volume transport (m3 m-2 s-1) +44 44 Sea water column integrated meridional volume transport (m3 m-1 s-1) +45 45 Sea water column integrated zonal volume transport (m3 m-1 s-1) +46 46 Sea water meridional mass transport (kg m-2 s-1) +47 47 Sea water zonal mass transport (kg m-2 s-1) +48 48 Sea water column integrated meridional mass transport (kg m-1 s-1) +49 49 Sea water column integrated zonal mass transport (kg m-1 s-1) +50 50 Sea water column integrated practical salinity (g kg-1 m) +51 51 Sea water column integrated salinity (kg kg-1 m) +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.2.0.table b/definitions/grib2/tables/33/4.2.2.0.table new file mode 100644 index 000000000..8daeafd85 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.2.0.table @@ -0,0 +1,68 @@ +# Product discipline 2 - Land surface products, parameter category 0: vegetation/biomass +0 0 Land cover (0 = sea, 1 = land) (Proportion) +1 1 Surface roughness (m) +2 2 Soil temperature (K) +3 3 Soil moisture content (kg m-2) +4 4 Vegetation (%) +5 5 Water runoff (kg m-2) +6 6 Evapotranspiration (kg-2 s-1) +7 7 Model terrain height (m) +8 8 Land use (Code table 4.212) +9 9 Volumetric soil moisture content (Proportion) +10 10 Ground heat flux (W m-2) +11 11 Moisture availability (%) +12 12 Exchange coefficient (kg m-2 s-1) +13 13 Plant canopy surface water (kg m-2) +14 14 Blackadar's mixing length scale (m) +15 15 Canopy conductance (m/s) +16 16 Minimal stomatal resistance (s/m) +17 17 Wilting point (Proportion) +18 18 Solar parameter in canopy conductance (Proportion) +19 19 Temperature parameter in canopy (Proportion) +20 20 Humidity parameter in canopy conductance (Proportion) +21 21 Soil moisture parameter in canopy conductance (Proportion) +22 22 Soil moisture (kg m-3) +23 23 Column-integrated soil water (kg m-2) +24 24 Heat flux (W m-2) +25 25 Volumetric soil moisture (m3 m-3) +26 26 Wilting point (kg m-3) +27 27 Volumetric wilting point (m3 m-3) +28 28 Leaf area index (Numeric) +29 29 Evergreen forest cover (Proportion) +30 30 Deciduous forest cover (Proportion) +31 31 Normalized differential vegetation index (NDVI) (Numeric) +32 32 Root depth of vegetation (m) +33 33 Water runoff and drainage (kg m-2) +34 34 Surface water runoff (kg m-2) +35 35 Tile class (Code table 4.243) +36 36 Tile fraction (Proportion) +37 37 Tile percentage (%) +38 38 Soil volumetric ice content (water equivalent) (m3 m-3) +39 39 Evapotranspiration rate (kg m-2 s-1) +40 40 Potential evapotranspiration rate (kg m-2 s-1) +41 41 Snow melt rate (kg m-2 s-1) +42 42 Water runoff and drainage rate (kg m-2 s-1) +43 43 Drainage direction (Code table 4.250) +44 44 Upstream area (m2) +45 45 Wetland cover (Proportion) +46 46 Wetland type (Code table 4.239) +47 47 Irrigation cover (Proportion) +48 48 C4 crop cover (Proportion) +49 49 C4 grass cover (Proportion) +50 50 Skin reservoir content (kg m-2) +51 51 Surface runoff rate (kg m-2 s-1) +52 52 Subsurface runoff rate (kg m-2 s-1) +53 53 Low-vegetation cover (Proportion) +54 54 High-vegetation cover (Proportion) +55 55 Leaf area index, low-vegetation (m2 m-2) +56 56 Leaf area index, high-vegetation (m2 m-2) +57 57 Type of low-vegetation (Code table 4.234) +58 58 Type of high-vegetation (Code table 4.234) +59 59 Net ecosystem exchange flux (kg m-2 s-1) +60 60 Gross primary production flux (kg m-2 s-1) +61 61 Ecosystem respiration flux (kg m-2 s-1) +62 62 Emissivity (Proportion) +63 63 Canopy air temperature (K) +# 64-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.2.3.table b/definitions/grib2/tables/33/4.2.2.3.table new file mode 100644 index 000000000..ad6b618f2 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.2.3.table @@ -0,0 +1,35 @@ +# Product discipline 2 - Land surface products, parameter category 3: soil products +0 0 Soil type (Code table 4.213) +1 1 Upper layer soil temperature (K) +2 2 Upper layer soil moisture (kg m-3) +3 3 Lower layer soil moisture (kg m-3) +4 4 Bottom layer soil temperature (K) +5 5 Liquid volumetric soil moisture (non-frozen) (Proportion) +6 6 Number of soil layers in root zone (Numeric) +7 7 Transpiration stress-onset (soil moisture) (Proportion) +8 8 Direct evaporation cease (soil moisture) (Proportion) +9 9 Soil porosity (Proportion) +10 10 Liquid volumetric soil moisture (non-frozen) (m3 m-3) +11 11 Volumetric transpiration stress-onset (soil moisture) (m3 m-3) +12 12 Transpiration stress-onset (soil moisture) (kg m-3) +13 13 Volumetric direct evaporation cease (soil moisture) (m3 m-3) +14 14 Direct evaporation cease (soil moisture) (kg m-3) +15 15 Soil porosity (m3 m-3) +16 16 Volumetric saturation of soil moisture (m3 m-3) +17 17 Saturation of soil moisture (kg m-3) +18 18 Soil temperature (K) +19 19 Soil moisture (kg m-3) +20 20 Column-integrated soil moisture (kg m-2) +21 21 Soil ice (kg m-3) +22 22 Column-integrated soil ice (kg m-2) +23 23 Liquid water in snow pack (kg m-2) +24 24 Frost index (K day-1) +25 25 Snow depth at elevation bands (kg m-2) +26 26 Soil heat flux (W m-2) +27 27 Soil depth (m) +28 28 Snow temperature (K) +29 29 Ice temperature (K) +30 30 Soil wetness index (Numeric) +# 31-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.2.4.table b/definitions/grib2/tables/33/4.2.2.4.table new file mode 100644 index 000000000..0ea44a18c --- /dev/null +++ b/definitions/grib2/tables/33/4.2.2.4.table @@ -0,0 +1,41 @@ +# Product discipline 2 - Land surface products, parameter category 4: fire weather products +0 0 Fire outlook (Code table 4.224) +1 1 Fire outlook due to dry thunderstorm (Code table 4.224) +2 2 Haines index (Numeric) +3 3 Fire burned area (%) +4 4 Fosberg index (Numeric) +5 5 Forest Fire Weather Index (as defined by the Canadian Forest Service) (Numeric) +6 6 Fine Fuel Moisture Code (as defined by the Canadian Forest Service) (Numeric) +7 7 Duff Moisture Code (as defined by the Canadian Forest Service) (Numeric) +8 8 Drought Code (as defined by the Canadian Forest Service) (Numeric) +9 9 Initial Fire Spread Index (as defined by the Canadian Forest Service) (Numeric) +10 10 Fire Buildup Index (as defined by the Canadian Forest Service) (Numeric) +11 11 Fire Daily Severity Rating (as defined by the Canadian Forest Service) (Numeric) +12 12 Keetch-Byram drought index (Numeric) +13 13 Drought factor (as defined by the Australian forest service ) (Numeric) +14 14 Rate of spread (as defined by the Australian forest service ) (m/s) +15 15 Fire danger index (as defined by the Australian forest service ) (Numeric) +16 16 Spread component (as defined by the US Forest Service National Fire Danger Rating System) (Numeric) +17 17 Burning index (as defined by the US Forest Service National Fire Danger Rating System) (Numeric) +18 18 Ignition component (as defined by the US Forest Service National Fire Danger Rating System) (%) +19 19 Energy release component (as defined by the US Forest Service National Fire Danger Rating System) (Joule/m2) +20 20 Burning area (%) +21 21 Burnable area (%) +22 22 Unburnable area (%) +23 23 Fuel load (kg m-2) +24 24 Combustion completeness (%) +25 25 Fuel moisture content (kg kg-1) +26 26 Wildfire potential (as defined by the US NOAA Global Systems Laboratory) (Numeric) +27 27 Live leaf fuel load (kg m-2) +28 28 Live wood fuel load (kg m-2) +29 29 Dead leaf fuel load (kg m-2) +30 30 Dead wood fuel load (kg m-2) +31 31 Live fuel moisture content (kg kg-1) +32 32 Fine dead leaf moisture content (kg kg-1) +33 33 Dense dead leaf moisture content (kg kg-1) +34 34 Fine dead wood moisture content (kg kg-1) +35 35 Dense dead wood moisture content (kg kg-1) +36 36 Fire radiative power (W) +# 37-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.2.5.table b/definitions/grib2/tables/33/4.2.2.5.table new file mode 100644 index 000000000..1d08dd573 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.2.5.table @@ -0,0 +1,6 @@ +# Product discipline 2 - Land surface products, parameter category 5: glaciers and inland ice +0 0 Glacier cover (Proportion) +1 1 Glacier temperature (K) +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.2.6.table b/definitions/grib2/tables/33/4.2.2.6.table new file mode 100644 index 000000000..7a7712af0 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.2.6.table @@ -0,0 +1,13 @@ +# Product discipline 2 - Land surface products, parameter category 6: urban areas +0 0 Urban cover (Proportion) +1 1 Road cover (Proportion) +2 2 Building cover (Proportion) +3 3 Building height (m) +4 4 Vertical-to-horizontal area fraction (m2 m-2) +5 5 Standard deviation of building height (m) +6 6 Distance downward from roof surface (m) +7 7 Distance inward from outer wall surface (m) +8 8 Distance downward from road surface (m) +# 9-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.20.0.table b/definitions/grib2/tables/33/4.2.20.0.table new file mode 100644 index 000000000..a997371d9 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.20.0.table @@ -0,0 +1,13 @@ +# Product discipline 20 - Health and socioeconomic impacts, parameter category 0: health indicators +0 0 Universal thermal climate index (K) +1 1 Mean radiant temperature (K) +2 2 Wet-bulb globe temperature (K) +3 3 Globe temperature (K) +4 4 Humidex (K) +5 5 Effective temperature (K) +6 6 Normal effective temperature (K) +7 7 Standard effective temperature (K) +8 8 Physiological equivalent temperature (K) +# 9-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.20.1.table b/definitions/grib2/tables/33/4.2.20.1.table new file mode 100644 index 000000000..0712cd8d1 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.20.1.table @@ -0,0 +1,14 @@ +# Product discipline 20 - Health and socioeconomic impacts, parameter category 1: epidemiology +0 0 Malaria cases (Fraction) +1 1 Malaria circumsporozoite protein rate (Fraction) +2 2 Plasmodium falciparum entomological inoculation rate (Bites per day per person) +3 3 Human bite rate by anopheles vectors (Bites per day per person) +4 4 Malaria immunity (Fraction) +5 5 Falciparum parasite rates (Fraction) +6 6 Detectable falciparum parasite ratio (after day 10) (Fraction) +7 7 Anopheles vector to host ratio (Fraction) +8 8 Anopheles vector number (Number m-2) +9 9 Fraction of malarial vector reproductive habitat (Fraction) +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.20.2.table b/definitions/grib2/tables/33/4.2.20.2.table new file mode 100644 index 000000000..d6b9083d1 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.20.2.table @@ -0,0 +1,5 @@ +# Product discipline 20 - Health and socioeconomic impacts, parameter category 2: socioeconomic indicators +0 0 Population density (Person m-2) +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.20.3.table b/definitions/grib2/tables/33/4.2.20.3.table new file mode 100644 index 000000000..9c2f80cfa --- /dev/null +++ b/definitions/grib2/tables/33/4.2.20.3.table @@ -0,0 +1,14 @@ +# Product discipline 20 - Health and socioeconomic impacts, parameter category 3: renewable energy sector +0 0 Renewable power capacity (W) +1 1 Renewable power production rate (W) +2 2 Wind power capacity (W) +3 3 Wind power production rate (W) +4 4 Solar photovoltaic (PV) power capacity (W) +5 5 Solar photovoltaic (PV) power production rate (W) +6 6 Solar non-photovoltaic (PV) power capacity (W) +7 7 Solar non-photovoltaic (PV) power production rate (W) +8 8 Concentrated solar power (CSP) power capacity (W) +9 9 Concentrated solar power (CSP) power production rate (W) +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.3.0.table b/definitions/grib2/tables/33/4.2.3.0.table new file mode 100644 index 000000000..0bec15119 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.3.0.table @@ -0,0 +1,14 @@ +# Product discipline 3 - Space products, parameter category 0: image format products +0 0 Scaled radiance (Numeric) +1 1 Scaled albedo (Numeric) +2 2 Scaled brightness temperature (Numeric) +3 3 Scaled precipitable water (Numeric) +4 4 Scaled lifted index (Numeric) +5 5 Scaled cloud top pressure (Numeric) +6 6 Scaled skin temperature (Numeric) +7 7 Cloud mask (Code table 4.217) +8 8 Pixel scene type (Code table 4.218) +9 9 Fire detection indicator (Code table 4.223) +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.3.1.table b/definitions/grib2/tables/33/4.2.3.1.table new file mode 100644 index 000000000..2aec33b42 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.3.1.table @@ -0,0 +1,38 @@ +# Product discipline 3 - Space products, parameter category 1: quantitative products +0 0 Estimated precipitation (kg m-2) +1 1 Instantaneous rain rate (kg m-2 s-1) +2 2 Cloud top height (m) +3 3 Cloud top height quality indicator (Code table 4.219) +4 4 Estimated u-component of wind (m/s) +5 5 Estimated v-component of wind (m/s) +6 6 Number of pixel used (Numeric) +7 7 Solar zenith angle (deg) +8 8 Relative azimuth angle (deg) +9 9 Reflectance in 0.6 micron channel (%) +10 10 Reflectance in 0.8 micron channel (%) +11 11 Reflectance in 1.6 micron channel (%) +12 12 Reflectance in 3.9 micron channel (%) +13 13 Atmospheric divergence (/s) +14 14 Cloudy brightness temperature (K) +15 15 Clear-sky brightness temperature (K) +16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) +17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) +18 18 Reserved +19 19 Wind speed (m/s) +20 20 Aerosol optical thickness at 0.635 um +21 21 Aerosol optical thickness at 0.810 um +22 22 Aerosol optical thickness at 1.640 um +23 23 Angstrom coefficient +# 24-26 Reserved +27 27 Bidirectional reflectance factor (Numeric) +28 28 Brightness temperature (K) +29 29 Scaled radiance (Numeric) +30 30 Reflectance in 0.4 micron channel (%) +31 31 Cloudy reflectance (%) +32 32 Clear reflectance (%) +# 33-97 Reserved +98 98 Correlation coefficient between MPE rain-rates for the co-located IR data and the microwave data rain-rates (Numeric) +99 99 Standard deviation between MPE rain-rates for the co-located IR data and the microwave data rain-rates (kg m-2 s-1) +# 100-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.3.2.table b/definitions/grib2/tables/33/4.2.3.2.table new file mode 100644 index 000000000..a97ce4942 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.3.2.table @@ -0,0 +1,24 @@ +# Product discipline 3 - Space products, parameter category 2: cloud properties +0 0 Clear sky probability (%) +1 1 Cloud top temperature (K) +2 2 Cloud top pressure (Pa) +3 3 Cloud type (Code table 4.218) +4 4 Cloud phase (Code table 4.218) +5 5 Cloud optical depth (Numeric) +6 6 Cloud particle effective radius (m) +7 7 Cloud liquid water path (kg m-2) +8 8 Cloud ice water path (kg m-2) +9 9 Cloud albedo (Numeric) +10 10 Cloud emissivity (Numeric) +11 11 Effective absorption optical depth ratio (Numeric) +30 30 Measurement cost (Numeric) +31 31 Upper layer cloud optical depth (Numeric) +32 32 Upper layer cloud top pressure (Pa) +33 33 Upper layer cloud effective radius (m) +34 34 Error in upper layer cloud optical depth (Numeric) +35 35 Error in upper layer cloud top pressure (Pa) +36 36 Error in upper layer cloud effective radius (m) +37 37 Lower layer cloud optical depth (Numeric) +38 38 Lower layer cloud top pressure (Pa) +39 39 Error in lower layer cloud optical depth (Numeric) +40 40 Error in lower layer cloud top pressure (Pa) diff --git a/definitions/grib2/tables/33/4.2.3.3.table b/definitions/grib2/tables/33/4.2.3.3.table new file mode 100644 index 000000000..c487a578e --- /dev/null +++ b/definitions/grib2/tables/33/4.2.3.3.table @@ -0,0 +1,4 @@ +# Product discipline 3 - Space products, parameter category 3: flight rule conditions +0 0 Probability of encountering marginal visual flight rule conditions (%) +1 1 Probability of encountering low instrument flight rule conditions (%) +2 2 Probability of encountering instrument flight rule conditions (%) diff --git a/definitions/grib2/tables/33/4.2.3.4.table b/definitions/grib2/tables/33/4.2.3.4.table new file mode 100644 index 000000000..7f832ff3c --- /dev/null +++ b/definitions/grib2/tables/33/4.2.3.4.table @@ -0,0 +1,10 @@ +# Product discipline 3 - Space products, parameter category 4: volcanic ash +0 0 Volcanic ash probability (%) +1 1 Volcanic ash cloud top temperature (K) +2 2 Volcanic ash cloud top pressure (Pa) +3 3 Volcanic ash cloud top height (m) +4 4 Volcanic ash cloud emissivity (Numeric) +5 5 Volcanic ash effective absorption optical depth ratio (Numeric) +6 6 Volcanic ash cloud optical depth (Numeric) +7 7 Volcanic ash column density (kg m-2) +8 8 Volcanic ash particle effective radius (m) diff --git a/definitions/grib2/tables/33/4.2.3.5.table b/definitions/grib2/tables/33/4.2.3.5.table new file mode 100644 index 000000000..58a3f12cb --- /dev/null +++ b/definitions/grib2/tables/33/4.2.3.5.table @@ -0,0 +1,7 @@ +# Product discipline 3 - Space products, parameter category 5: sea-surface temperature +0 0 Interface sea-surface temperature (K) +1 1 Skin sea-surface temperature (K) +2 2 Sub-skin sea-surface temperature (K) +3 3 Foundation sea-surface temperature (K) +4 4 Estimated bias between sea-surface temperature and standard (K) +5 5 Estimated standard deviation between sea surface temperature and standard (K) diff --git a/definitions/grib2/tables/33/4.2.3.6.table b/definitions/grib2/tables/33/4.2.3.6.table new file mode 100644 index 000000000..62a5ba656 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.3.6.table @@ -0,0 +1,7 @@ +# Product discipline 3 - Space products, parameter category 6: solar radiation +0 0 Global solar irradiance (W m-2) +1 1 Global solar exposure (J m-2) +2 2 Direct solar irradiance (W m-2) +3 3 Direct solar exposure (J m-2) +4 4 Diffuse solar irradiance (W m-2) +5 5 Diffuse solar exposure (J m-2) diff --git a/definitions/grib2/tables/33/4.2.4.0.table b/definitions/grib2/tables/33/4.2.4.0.table new file mode 100644 index 000000000..337308305 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.0.table @@ -0,0 +1,10 @@ +# Product discipline 4 - Space weather products, parameter category 0: temperature +0 0 Temperature (K) +1 1 Electron temperature (K) +2 2 Proton temperature (K) +3 3 Ion temperature (K) +4 4 Parallel temperature (K) +5 5 Perpendicular temperature (K) +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.1.table b/definitions/grib2/tables/33/4.2.4.1.table new file mode 100644 index 000000000..9ec11160f --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.1.table @@ -0,0 +1,8 @@ +# Product discipline 4 - Space weather products, parameter category 1: momentum +0 0 Velocity magnitude (speed) (m s-1) +1 1 1st vector component of velocity (coordinate system dependent) (m s-1) +2 2 2nd vector component of velocity (coordinate system dependent) (m s-1) +3 3 3rd vector component of velocity (coordinate system dependent) (m s-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.10.table b/definitions/grib2/tables/33/4.2.4.10.table new file mode 100644 index 000000000..8f5b19e06 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.10.table @@ -0,0 +1,12 @@ +# Product discipline 4 - Space weather products, parameter category 10: space weather indices +0 0 Scintillation index (sigma phi) (rad) +1 1 Scintillation index S4 (Numeric) +2 2 Rate of change of TEC index (ROTI) (TECU/min) +3 3 Disturbance ionosphere index spatial gradient (DIXSG) (Numeric) +4 4 Along arc TEC rate (AATR) (TECU/min) +5 5 Kp (Numeric) +6 6 Equatorial disturbance storm time index (Dst) (nT) +7 7 Auroral electrojet (AE) (nT) +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.2.table b/definitions/grib2/tables/33/4.2.4.2.table new file mode 100644 index 000000000..b479b3361 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.2.table @@ -0,0 +1,18 @@ +# Product discipline 4 - Space weather products, parameter category 2: charged particle mass and number +0 0 Particle number density (m-3) +1 1 Electron density (m-3) +2 2 Proton density (m-3) +3 3 Ion density (m-3) +4 4 Vertical total electron content (TECU) +5 5 HF absorption frequency (Hz) +6 6 HF absorption (dB) +7 7 Spread F (m) +8 8 h'F (m) +9 9 Critical frequency (Hz) +10 10 Maximal usable frequency (MUF) (Hz) +11 11 Peak height (hm) (m) +12 12 Peak density (Nm) (m-3) +13 13 Equivalent slab thickness (tau) (km) +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.3.table b/definitions/grib2/tables/33/4.2.4.3.table new file mode 100644 index 000000000..3b752bbbc --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.3.table @@ -0,0 +1,12 @@ +# Product discipline 4 - Space weather products, parameter category 3: electric and magnetic fields +0 0 Magnetic field magnitude (T) +1 1 1st vector component of magnetic field (T) +2 2 2nd vector component of magnetic field (T) +3 3 3rd vector component of magnetic field (T) +4 4 Electric field magnitude (V m-1) +5 5 1st vector component of electric field (V m-1) +6 6 2nd vector component of electric field (V m-1) +7 7 3rd vector component of electric field (V m-1) +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.4.table b/definitions/grib2/tables/33/4.2.4.4.table new file mode 100644 index 000000000..694c8cacc --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.4.table @@ -0,0 +1,11 @@ +# Product discipline 4 - Space weather products, parameter category 4: energetic particles +0 0 Proton flux (differential) ((m2 s sr eV)-1) +1 1 Proton flux (integral) ((m2 s sr )-1) +2 2 Electron flux (differential) ((m2 s sr eV)-1) +3 3 Electron flux (integral) ((m2 s sr)-1) +4 4 Heavy ion flux (differential) ((m2 s sr eV/nuc)-1) +5 5 Heavy ion flux (integral) ((m2 s sr)-1) +6 6 Cosmic ray neutron flux (h-1) +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.5.table b/definitions/grib2/tables/33/4.2.4.5.table new file mode 100644 index 000000000..913efec6f --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.5.table @@ -0,0 +1,8 @@ +# Product discipline 4 - Space weather products, parameter category 5: waves +0 0 Amplitude (dB) +1 1 Phase (rad) +2 2 Frequency (Hz) +3 3 Wavelength (m) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.6.table b/definitions/grib2/tables/33/4.2.4.6.table new file mode 100644 index 000000000..6d13019a6 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.6.table @@ -0,0 +1,11 @@ +# Product discipline 4 - Space weather products, parameter category 6: solar electromagnetic emissions +0 0 Integrated solar irradiance (W m-2) +1 1 Solar X-ray flux (XRS long) (W m-2) +2 2 Solar X-ray flux (XRS short) (W m-2) +3 3 Solar EUV irradiance (W m-2) +4 4 Solar spectral irradiance (W m-2 nm-1) +5 5 F10.7 (W m-2 Hz-1) +6 6 Solar radio emissions (W m-2 Hz-1) +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.7.table b/definitions/grib2/tables/33/4.2.4.7.table new file mode 100644 index 000000000..38c2b17a8 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.7.table @@ -0,0 +1,8 @@ +# Product discipline 4 - Space weather products, parameter category 7: terrestrial electromagnetic emissions +0 0 Limb intensity (J m-2 s-1) +1 1 Disk intensity (J m-2 s-1) +2 2 Disk intensity day (J m-2 s-1) +3 3 Disk intensity night (J m-2 s-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.8.table b/definitions/grib2/tables/33/4.2.4.8.table new file mode 100644 index 000000000..f350f4807 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.8.table @@ -0,0 +1,13 @@ +# Product discipline 4 - Space weather products, parameter category 8: imagery +0 0 X-ray radiance (W sr-1 m-2) +1 1 EUV radiance (W sr-1 m-2) +2 2 H-alpha radiance (W sr-1 m-2) +3 3 White light radiance (W sr-1 m-2) +4 4 CaII-K radiance (W sr-1 m-2) +5 5 White light coronagraph radiance (W sr-1 m-2) +6 6 Heliospheric radiance (W sr-1 m-2) +7 7 Thematic mask (Numeric) +8 8 Solar induced chlorophyll fluorescence (W m-2 sr-1 m-1) +# 9-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.2.4.9.table b/definitions/grib2/tables/33/4.2.4.9.table new file mode 100644 index 000000000..0e83436e2 --- /dev/null +++ b/definitions/grib2/tables/33/4.2.4.9.table @@ -0,0 +1,7 @@ +# Product discipline 4 - Space weather products, parameter category 9: ion-neutral coupling +0 0 Pedersen conductivity (S m-1) +1 1 Hall conductivity (S m-1) +2 2 Parallel conductivity (S m-1) +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.201.table b/definitions/grib2/tables/33/4.201.table new file mode 100644 index 000000000..a725e4e65 --- /dev/null +++ b/definitions/grib2/tables/33/4.201.table @@ -0,0 +1,17 @@ +# Code table 4.201 - Precipitation type +0 0 No precipitation +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +6 6 Wet snow +7 7 Mixture of rain and snow +8 8 Ice pellets +9 9 Graupel +10 10 Hail +11 11 Drizzle +12 12 Freezing drizzle +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.202.table b/definitions/grib2/tables/33/4.202.table new file mode 100644 index 000000000..7f3c8f6cf --- /dev/null +++ b/definitions/grib2/tables/33/4.202.table @@ -0,0 +1,4 @@ +# Code table 4.202 - Precipitable water category +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.203.table b/definitions/grib2/tables/33/4.203.table new file mode 100644 index 000000000..cf5eb6bdc --- /dev/null +++ b/definitions/grib2/tables/33/4.203.table @@ -0,0 +1,26 @@ +# Code table 4.203 - Cloud type +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.204.table b/definitions/grib2/tables/33/4.204.table new file mode 100644 index 000000000..8e0be1f8c --- /dev/null +++ b/definitions/grib2/tables/33/4.204.table @@ -0,0 +1,9 @@ +# Code table 4.204 - Thunderstorm coverage +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (6-45%) +4 4 Numerous (> 45%) +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.205.table b/definitions/grib2/tables/33/4.205.table new file mode 100644 index 000000000..c40c7f47b --- /dev/null +++ b/definitions/grib2/tables/33/4.205.table @@ -0,0 +1,6 @@ +# Code table 4.205 - Presence of aerosol +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.206.table b/definitions/grib2/tables/33/4.206.table new file mode 100644 index 000000000..76472c261 --- /dev/null +++ b/definitions/grib2/tables/33/4.206.table @@ -0,0 +1,6 @@ +# Code table 4.206 - Volcanic ash +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.207.table b/definitions/grib2/tables/33/4.207.table new file mode 100644 index 000000000..b6392fca0 --- /dev/null +++ b/definitions/grib2/tables/33/4.207.table @@ -0,0 +1,10 @@ +# Code table 4.207 - Icing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.208.table b/definitions/grib2/tables/33/4.208.table new file mode 100644 index 000000000..4361d38c0 --- /dev/null +++ b/definitions/grib2/tables/33/4.208.table @@ -0,0 +1,9 @@ +# Code table 4.208 - Turbulence +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.209.table b/definitions/grib2/tables/33/4.209.table new file mode 100644 index 000000000..39ea549ac --- /dev/null +++ b/definitions/grib2/tables/33/4.209.table @@ -0,0 +1,9 @@ +# Code table 4.209 - Planetary boundary-layer regime +0 0 Reserved +1 1 Stable +2 2 Mechanically driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.210.table b/definitions/grib2/tables/33/4.210.table new file mode 100644 index 000000000..791878469 --- /dev/null +++ b/definitions/grib2/tables/33/4.210.table @@ -0,0 +1,6 @@ +# Code table 4.210 - Contrail intensity +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.211.table b/definitions/grib2/tables/33/4.211.table new file mode 100644 index 000000000..2a28a84d9 --- /dev/null +++ b/definitions/grib2/tables/33/4.211.table @@ -0,0 +1,7 @@ +# Code table 4.211 - Contrail engine type +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.212.table b/definitions/grib2/tables/33/4.212.table new file mode 100644 index 000000000..6a3dcf88c --- /dev/null +++ b/definitions/grib2/tables/33/4.212.table @@ -0,0 +1,18 @@ +# Code table 4.212 - Land use +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.213.table b/definitions/grib2/tables/33/4.213.table new file mode 100644 index 000000000..68d627af6 --- /dev/null +++ b/definitions/grib2/tables/33/4.213.table @@ -0,0 +1,16 @@ +# Code table 4.213 - Soil type +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.214.table b/definitions/grib2/tables/33/4.214.table new file mode 100644 index 000000000..b08860ce0 --- /dev/null +++ b/definitions/grib2/tables/33/4.214.table @@ -0,0 +1,11 @@ +# Code table 4.214 - Environmental Factor Qualifier +0 0 Worst +1 1 Very poor +2 2 Poor +3 3 Average +4 4 Good +5 5 Excellent +# 6-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.215.table b/definitions/grib2/tables/33/4.215.table new file mode 100644 index 000000000..7888772d5 --- /dev/null +++ b/definitions/grib2/tables/33/4.215.table @@ -0,0 +1,9 @@ +# Code table 4.215 - Remotely sensed snow coverage +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.216.table b/definitions/grib2/tables/33/4.216.table new file mode 100644 index 000000000..b51b358f4 --- /dev/null +++ b/definitions/grib2/tables/33/4.216.table @@ -0,0 +1,5 @@ +# Code table 4.216 - Elevation of snow-covered terrain +# 0-90 Elevation in increments of 100 m +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/33/4.217.table b/definitions/grib2/tables/33/4.217.table new file mode 100644 index 000000000..a700410d5 --- /dev/null +++ b/definitions/grib2/tables/33/4.217.table @@ -0,0 +1,8 @@ +# Code table 4.217 - Cloud mask type +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.218.table b/definitions/grib2/tables/33/4.218.table new file mode 100644 index 000000000..a13debf16 --- /dev/null +++ b/definitions/grib2/tables/33/4.218.table @@ -0,0 +1,46 @@ +# Code table 4.218 - Pixel scene type +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation/crops +15 15 Permanent snow/ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +19 19 Warm liquid water cloud +20 20 Supercooled liquid water cloud +21 21 Mixed-phase cloud +22 22 Optically thin ice cloud +23 23 Optically thick ice cloud +24 24 Multilayered cloud +# 25-96 Reserved +97 97 Snow/ice on land +98 98 Snow/ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud/fog/stratus +102 102 Low cloud/stratocumulus +103 103 Low cloud/unknown type +104 104 Medium cloud/nimbostratus +105 105 Medium cloud/altostratus +106 106 Medium cloud/unknown type +107 107 High cloud/cumulus +108 108 High cloud/cirrus +109 109 High cloud/unknown +110 110 Unknown cloud type +111 111 Single layer water cloud +112 112 Single layer ice cloud +# 113-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.219.table b/definitions/grib2/tables/33/4.219.table new file mode 100644 index 000000000..9979f50ad --- /dev/null +++ b/definitions/grib2/tables/33/4.219.table @@ -0,0 +1,8 @@ +# Code table 4.219 - Cloud top height quality indicator +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.220.table b/definitions/grib2/tables/33/4.220.table new file mode 100644 index 000000000..88e869e42 --- /dev/null +++ b/definitions/grib2/tables/33/4.220.table @@ -0,0 +1,6 @@ +# Code table 4.220 - Horizontal dimension processed +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.221.table b/definitions/grib2/tables/33/4.221.table new file mode 100644 index 000000000..011cc3518 --- /dev/null +++ b/definitions/grib2/tables/33/4.221.table @@ -0,0 +1,6 @@ +# Code table 4.221 - Treatment of missing data +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.222.table b/definitions/grib2/tables/33/4.222.table new file mode 100644 index 000000000..558d947ac --- /dev/null +++ b/definitions/grib2/tables/33/4.222.table @@ -0,0 +1,6 @@ +# Code table 4.222 - Categorical result +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.223.table b/definitions/grib2/tables/33/4.223.table new file mode 100644 index 000000000..572c4e7a8 --- /dev/null +++ b/definitions/grib2/tables/33/4.223.table @@ -0,0 +1,5 @@ +# Code table 4.223 - Fire detection indicator +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing diff --git a/definitions/grib2/tables/33/4.224.table b/definitions/grib2/tables/33/4.224.table new file mode 100644 index 000000000..014f56e23 --- /dev/null +++ b/definitions/grib2/tables/33/4.224.table @@ -0,0 +1,18 @@ +# Code table 4.224 - Categorical outlook +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/4.225.table b/definitions/grib2/tables/33/4.225.table new file mode 100644 index 000000000..9dc374087 --- /dev/null +++ b/definitions/grib2/tables/33/4.225.table @@ -0,0 +1,2 @@ +# Code table 4.225 - Weather (see FM 94 BUFR/FM 95 CREX Code table 0 20 003 - Present weather) +511 511 Missing value diff --git a/definitions/grib2/tables/33/4.227.table b/definitions/grib2/tables/33/4.227.table new file mode 100644 index 000000000..48c3b7633 --- /dev/null +++ b/definitions/grib2/tables/33/4.227.table @@ -0,0 +1,9 @@ +# Code table 4.227 - Icing scenario (weather/cloud classification) +0 0 None +1 1 General +2 2 Convective +3 3 Stratiform +4 4 Freezing +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/33/4.228.table b/definitions/grib2/tables/33/4.228.table new file mode 100644 index 000000000..048a69f0b --- /dev/null +++ b/definitions/grib2/tables/33/4.228.table @@ -0,0 +1,8 @@ +# Code table 4.228 - Icing severity +0 0 None +1 1 Trace +2 2 Light +3 3 Moderate +4 4 Severe +# 5-254 Reserved +255 255 Missing value diff --git a/definitions/grib2/tables/33/4.230.table b/definitions/grib2/tables/33/4.230.table new file mode 100644 index 000000000..1871fb176 --- /dev/null +++ b/definitions/grib2/tables/33/4.230.table @@ -0,0 +1,601 @@ +# Code table 4.230 - Atmospheric chemical constituent type +0 0 Ozone O3 +1 1 Water vapour H2O +2 2 Methane CH4 +3 3 Carbon dioxide CO2 +4 4 Carbon monoxide CO +5 5 Nitrogen dioxide NO2 +6 6 Nitrous oxide N2O +7 7 Formaldehyde HCHO +8 8 Sulphur dioxide SO2 +9 9 Ammonia NH3 +10 10 Ammonium cation NH4+ +11 11 Nitrogen monoxide NO +12 12 Atomic oxygen O +13 13 Nitrate radical NO3* +14 14 Hydroperoxyl radical HOO* +15 15 Dinitrogen pentoxide N2O5 +16 16 Nitrous acid HONO +17 17 Nitric acid HNO3 +18 18 Peroxynitric acid HO2NO2 +19 19 Hydrogen peroxide H2O2 +20 20 Dihydrogen H2 +21 21 Atomic nitrogen N +22 22 Sulphate anion SO42- +23 23 Atomic Radon Rn +24 24 Mercury vapour Hg(0) +25 25 Mercury(II) cation Hg2+ +26 26 Atomic chlorine Cl +27 27 Chlorine monoxide ClO +28 28 Dichlorine peroxide Cl2O2 +29 29 Hypochlorous acid HClO +30 30 Chlorine nitrate ClONO2 +31 31 Chlorine dioxide ClO2 +32 32 Atomic bromine Br +33 33 Bromine monoxide BrO +34 34 Bromine chloride BrCl +35 35 Hydrogen bromide HBr +36 36 Hypobromous acid HBrO +37 37 Bromine nitrate BrONO2 +38 38 Dioxygen O2 +39 39 Nitryl chloride NO2Cl +40 40 Sulphuric acid H2SO4 +41 41 Hydrogen sulphide H2S +42 42 Sulphur trioxide SO3 +43 43 Bromine Br2 +44 44 Hydrofluoric acid HF +45 45 Sulphur hexafluoride SF6 +46 46 Chlorine Cl2 +# 47-9999 Reserved +10000 10000 Hydroxyl radical HO* +10001 10001 Methyl peroxy radical CH3OO* +10002 10002 Methyl hydroperoxide CH3OOH +10004 10004 Methanol CH3OH +10005 10005 Formic acid HCOOH +10006 10006 Hydrogen cyanide HCN +10007 10007 Aceto nitrile CH3CN +10008 10008 Ethane C2H6 +10009 10009 Ethene (= Ethylene) C2H4 +10010 10010 Ethyne (= Acetylene) C2H2 +10011 10011 Ethanol C2H5OH +10012 10012 Acetic acid C2H5OOH +10013 10013 Peroxyacetyl nitrate CH3C(O)OONO2 +10014 10014 Propane C3H8 +10015 10015 Propene C3H6 +10016 10016 Butane (all isomers) C4H10 +10017 10017 Isoprene C5H10 +10018 10018 Alpha pinene C10H16 +10019 10019 Beta pinene C10H16 +10020 10020 Limonene C10H16 +10021 10021 Benzene C6H6 +10022 10022 Toluene C7H8 +10023 10023 Xylene C8H10 +10024 10024 Methanesulphonic acid CH3SO3H +10025 10025 Methylglyoxal (2-oxopropanal) CH3C(O)CHO +10026 10026 Peroxyacetyl radical CH3C(O)OO* +10027 10027 Methacrylic acid (2-methylprop-2-enoic acid) CH2C(CH3)COOH +10028 10028 Methacrolein (2-methylprop-2-enal) CH2C(CH3)CHO +10029 10029 Acetone (propan-2-one) CH3C(O)CH3 +10030 10030 Ethyl dioxidanyl radical CH3CH2OO* +10031 10031 Butadiene (buta-1,3-diene) (CH2CH)2 +10032 10032 Acetaldehyde (ethanal) CH3CHO +10033 10033 Glycolaldehyde (hydroxyethanal) HOCH2CHO +10034 10034 Cresol (methylphenol), all isomers CH3C6H4OH +10035 10035 Peracetic acid (ethaneperoxoic acid) CH3C(O)OOH +10036 10036 2-hydroxyethyl oxidanyl radical HOCH2CH2O* +10037 10037 2-hydroxyethyl dioxidanyl radical HOCH2CH2OO* +10038 10038 Glyoxal (oxaldehyde) OCHCHO +10039 10039 Isopropyl dioxidanyl radical (CH3)2CHOO* +10040 10040 Isopropyl hydroperoxide (2-hydroperoxypropane) (CH3)2CHOOH +10041 10041 Hydroxyacetone (1-hydroxypropan-2-one) CH3C(O)CH2OH +10042 10042 Peroxyacetic acid (ethaneperoxoic acid) CH3C(O)OOH +10043 10043 Methyl vinyl ketone (but-3-en-2-one) CH3C(O)CHCH2 +10044 10044 Phenoxy radical C6H5O* +10045 10045 Methyl radical CH3* +10046 10046 Carbonyl sulphide (carbon oxide sulphide) OCS +10047 10047 Dibromomethane CH2Br2 +10048 10048 Methoxy radical CH3O* +10049 10049 Tribromomethane CHBr3 +10050 10050 Formyl radical (oxomethyl radical) HOC* +10051 10051 Hydroxymethyl dioxidanyl radical HOCH2OO* +10052 10052 Ethyl hydroperoxide CH3CH2OOH +10053 10053 3-hydroxypropyl dioxidanyl radical HOCH2CH2CH2OO* +10054 10054 3-hydroxypropyl hydroperoxide HOCH2CH2CH2OOH +10055 10055 Methyl-peroxy-nitrate (nitroperoxy-methane) CH3OONO2 +10056 10056 2-lambda^1-oxidanyloxy-2-methylbut-3-en-1-ol (4-hydroxy-3-methyl-1-butene-3-ylperoxy radical) HOCH2C(CH3)(OO*)CHCH2 +10057 10057 2-lambda^1-oxidanyloxy-3-methylbut-3-en-1-ol (2-hydroxy-1-isopropenylethylperoxy radical) HOCH2CH(OO*)C(CH3)CH2 +10058 10058 (Z)-4-hydroperoxy-2-methyl-2-butenal CH2(OOH)CHC(CH3)CHO +10059 10059 (Z)-4-hydroperoxy-3-methyl-2-butenal CH2(OOH)C(CH3)CHCHO +# 10060-10499 Reserved for other simple organic molecules (e.g. higher aldehydes, alcohols, peroxides, etc.) +10500 10500 Dimethyl sulphide CH3SCH3 (DMS) +10501 10501 DMSO (dimethyl sulfoxide) (CH3)2SO +# 10502-20000 Reserved +20001 20001 Hydrogen chloride HCl +20002 20002 CFC-11 (trichlorofluoromethane) CCl3F +20003 20003 CFC-12 (dichlorodifluoromethane) CCl2F2 +20004 20004 CFC-113 (1,1,2-trichloro-1,2,2-trifluoroethane) Cl2FC-CClF2 +20005 20005 CFC-113a (1,1,1-trichloro-2,2,2-trifluoroethane) Cl3C-CF3 +20006 20006 CFC-114 (1,2-dichloro-1,1,2,2-tetrafluoroethane) ClF2C-CClF2 +20007 20007 CFC-115 (1-chloro-1,1,2,2,2-pentafluoroethane) ClF2C-CF3 +20008 20008 HCFC-22 (chlorodifluoromethane) CHClF2 +20009 20009 HCFC-141b (1,1-dichloro-1-fluoroethane) Cl2FC-CH3 +20010 20010 HCFC-142b (1-chloro-1,1-difluoroethane) ClF2C-CH3 +20011 20011 Halon-1202 (dibromodifluoromethane) CBr2F2 +20012 20012 Halon-1211 (bromochlorodifluoromethane) CBrClF2 +20013 20013 Halon-1301 (bromotrifluoromethane) CBrF3 +20014 20014 Halon-2402 (1,2-dibromo-1,1,2,2-tetrafluoroethane) BrF2C-CBrF2 +20015 20015 HCC-40 (methyl chloride) CH3Cl +20016 20016 HCC-10 (carbon tetrachloride) CCl4 +20017 20017 HCC-140a (1,1,1-trichloroethane) Cl3C-CH3 +20018 20018 HBC-40B1 (methyl bromide) CH3Br +20019 20019 HCH (hexachlorocyclohexane) all isomers C6H6Cl6 +20020 20020 alpha-HCH (alpha-hexachlorocyclohexane) both enantiomers alpha-C6H6Cl6 +20021 20021 PCB-153 (2,2',4,4',5,5'-hexachlorobiphenyl) (C6H2Cl3)2 +20022 20022 HCFC-141a (1,1-dichloro-2-fluoroethane) Cl2HC-CH2F +# 20023-29999 Reserved +30000 30000 Radioactive pollutant (tracer, defined by originating centre) +# 30001-30009 Reserved +30010 30010 Tritium (Hydrogen 3) H-3 +30011 30011 Tritium organic bounded H-3o +30012 30012 Tritium inorganic H-3a +30013 30013 Beryllium 7 Be-7 +30014 30014 Beryllium 10 Be-10 +30015 30015 Carbon 14 C-14 +30016 30016 Carbon 14 CO2 C-14CO2 +30017 30017 Carbon 14 other gases C-14og +30018 30018 Nitrogen 13 N-13 +30019 30019 Nitrogen 16 N-16 +30020 30020 Fluorine 18 F-18 +30021 30021 Sodium 22 Na-22 +30022 30022 Phosphate 32 P-32 +30023 30023 Phosphate 33 P-33 +30024 30024 Sulphur 35 S-35 +30025 30025 Chlorine 36 Cl-36 +30026 30026 Potassium 40 K-40 +30027 30027 Argon 41 Ar-41 +30028 30028 Calcium 41 Ca-41 +30029 30029 Calcium 45 Ca-45 +30030 30030 Titanium 44 Ti-44 +30031 30031 Scandium 46 Sc-46 +30032 30032 Vanadium 48 V-48 +30033 30033 Vanadium 49 V-49 +30034 30034 Chrome 51 Cr-51 +30035 30035 Manganese 52 Mn-52 +30036 30036 Manganese 54 Mn-54 +30037 30037 Iron 55 Fe-55 +30038 30038 Iron 59 Fe-59 +30039 30039 Cobalt 56 Co-56 +30040 30040 Cobalt 57 Co-57 +30041 30041 Cobalt 58 Co-58 +30042 30042 Cobalt 60 Co-60 +30043 30043 Nickel 59 Ni-59 +30044 30044 Nickel 63 Ni-63 +30045 30045 Zinc 65 Zn-65 +30046 30046 Gallium 67 Ga-67 +30047 30047 Gallium 68 Ga-68 +30048 30048 Germanium 68 Ge-68 +30049 30049 Germanium 69 Ge-69 +30050 30050 Arsenic 73 As-73 +30051 30051 Selenium 75 Se-75 +30052 30052 Selenium 79 Se-79 +30053 30053 Rubidium 81 Rb-81 +30054 30054 Rubidium 83 Rb-83 +30055 30055 Rubidium 84 Rb-84 +30056 30056 Rubidium 86 Rb-86 +30057 30057 Rubidium 87 Rb-87 +30058 30058 Rubidium 88 Rb-88 +30059 30059 Krypton 85 Kr-85 +30060 30060 Krypton 85 metastable Kr-85m +30061 30061 Krypton 87 Kr-87 +30062 30062 Krypton 88 Kr-88 +30063 30063 Krypton 89 Kr-89 +30064 30064 Strontium 85 Sr-85 +30065 30065 Strontium 89 Sr-89 +30066 30066 Strontium 89/90 Sr-8990 +30067 30067 Strontium 90 Sr-90 +30068 30068 Strontium 91 Sr-91 +30069 30069 Strontium 92 Sr-92 +30070 30070 Yttrium 87 Y-87 +30071 30071 Yttrium 88 Y-88 +30072 30072 Yttrium 90 Y-90 +30073 30073 Yttrium 91 Y-91 +30074 30074 Yttrium 91 metastable Y-91m +30075 30075 Yttrium 92 Y-92 +30076 30076 Yttrium 93 Y-93 +30077 30077 Zirconium 89 Zr-89 +30078 30078 Zirconium 93 Zr-93 +30079 30079 Zirconium 95 Zr-95 +30080 30080 Zirconium 97 Zr-97 +30081 30081 Niobium 93 metastable Nb-93m +30082 30082 Niobium 94 Nb-94 +30083 30083 Niobium 95 Nb-95 +30084 30084 Niobium 95 metastable Nb-95m +30085 30085 Niobium 97 Nb-97 +30086 30086 Niobium 97 metastable Nb-97m +30087 30087 Molybdenum 93 Mo-93 +30088 30088 Molybdenum 99 Mo-99 +30089 30089 Technetium 95 metastable Tc-95m +30090 30090 Technetium 96 Tc-96 +30091 30091 Technetium 99 Tc-99 +30092 30092 Technetium 99 metastable Tc-99m +30093 30093 Rhodium 99 Rh-99 +30094 30094 Rhodium 101 Rh-101 +30095 30095 Rhodium 102 metastable Rh-102m +30096 30096 Rhodium 103 metastable Rh-103m +30097 30097 Rhodium 105 Rh-105 +30098 30098 Rhodium 106 Rh-106 +30099 30099 Palladium 100 Pd-100 +30100 30100 Palladium 103 Pd-103 +30101 30101 Palladium 107 Pd-107 +30102 30102 Ruthenium 103 Ru-103 +30103 30103 Ruthenium 105 Ru-105 +30104 30104 Ruthenium 106 Ru-106 +30105 30105 Silver 108 metastable Ag-108m +30106 30106 Silver 110 metastable Ag-110m +30107 30107 Cadmium 109 Cd-109 +30108 30108 Cadmium 113 metastable Cd-113m +30109 30109 Cadmium 115 metastable Cd-115m +30110 30110 Indium 114 metastable In-114m +30111 30111 Tin 113 Sn-113 +30112 30112 Tin 119 metastable Sn-119m +30113 30113 Tin 121 metastable Sn-121m +30114 30114 Tin 122 Sn-122 +30115 30115 Tin 123 Sn-123 +30116 30116 Tin 126 Sn-126 +30117 30117 Antimony 124 Sb-124 +30118 30118 Antimony 125 Sb-125 +30119 30119 Antimony 126 Sb-126 +30120 30120 Antimony 127 Sb-127 +30121 30121 Antimony 129 Sb-129 +30122 30122 Tellurium 123 metastable Te-123m +30123 30123 Tellurium 125 metastable Te-125m +30124 30124 Tellurium 127 Te-127 +30125 30125 Tellurium 127 metastable Te-127m +30126 30126 Tellurium 129 Te-129 +30127 30127 Tellurium 129 metastable Te-129m +30128 30128 Tellurium 131 metastable Te-131m +30129 30129 Tellurium 132 Te-132 +30130 30130 Iodine 123 I-123 +30131 30131 Iodine 124 I-124 +30132 30132 Iodine 125 I-125 +30133 30133 Iodine 126 I-126 +30134 30134 Iodine 129 I-129 +30135 30135 Iodine 129 elementary gaseous I-129g +30136 30136 Iodine 129 organic bounded I-129o +30137 30137 Iodine 131 I-131 +30138 30138 Iodine 131 elementary gaseous I-131g +30139 30139 Iodine 131 organic bounded I-131o +30140 30140 Iodine 131 gaseous elementary and organic bounded I-131go +30141 30141 Iodine 131 aerosol I-131a +30142 30142 Iodine 132 I-132 +30143 30143 Iodine 132 elementary gaseous I-132g +30144 30144 Iodine 132 organic bounded I-132o +30145 30145 Iodine 132 gaseous elementary and organic bounded I-132go +30146 30146 Iodine 132 aerosol I-132a +30147 30147 Iodine 133 I-133 +30148 30148 Iodine 133 elementary gaseous I-133g +30149 30149 Iodine 133 organic bounded I-133o +30150 30150 Iodine 133 gaseous elementary and organic bounded I-133go +30151 30151 Iodine 133 aerosol I-133a +30152 30152 Iodine 134 I-134 +30153 30153 Iodine 134 elementary gaseous I-134g +30154 30154 Iodine 134 organic bounded I-134o +30155 30155 Iodine 135 I-135 +30156 30156 Iodine 135 elementary gaseous I-135g +30157 30157 Iodine 135 organic bounded I-135o +30158 30158 Iodine 135 gaseous elementary and organic bounded I-135go +30159 30159 Iodine 135 aerosol I-135a +30160 30160 Xenon 131 metastable Xe-131m +30161 30161 Xenon 133 Xe-133 +30162 30162 Xenon 133 metastable Xe-133m +30163 30163 Xenon 135 Xe-135 +30164 30164 Xenon 135 metastable Xe-135m +30165 30165 Xenon 137 Xe-137 +30166 30166 Xenon 138 Xe-138 +30167 30167 Xenon sum of all Xenon isotopes Xe-sum +30168 30168 Caesium 131 Cs-131 +30169 30169 Caesium 134 Cs-134 +30170 30170 Caesium 135 Cs-135 +30171 30171 Caesium 136 Cs-136 +30172 30172 Caesium 137 Cs-137 +30173 30173 Barium 133 Ba-133 +30174 30174 Barium 137 metastable Ba-137m +30175 30175 Barium 140 Ba-140 +30176 30176 Cerium 139 Ce-139 +30177 30177 Cerium 141 Ce-141 +30178 30178 Cerium 143 Ce-143 +30179 30179 Cerium 144 Ce-144 +30180 30180 Lanthanum 140 La-140 +30181 30181 Lanthanum 141 La-141 +30182 30182 Praseodymium 143 Pr-143 +30183 30183 Praseodymium 144 Pr-144 +30184 30184 Praseodymium 144 metastable Pr-144m +30185 30185 Samarium 145 Sm-145 +30186 30186 Samarium 147 Sm-147 +30187 30187 Samarium 151 Sm-151 +30188 30188 Neodymium 147 Nd-147 +30189 30189 Promethium 146 Pm-146 +30190 30190 Promethium 147 Pm-147 +30191 30191 Promethium 151 Pm-151 +30192 30192 Europium 152 Eu-152 +30193 30193 Europium 154 Eu-154 +30194 30194 Europium 155 Eu-155 +30195 30195 Gadolinium 153 Gd-153 +30196 30196 Terbium 160 Tb-160 +30197 30197 Holmium 166 metastable Ho-166m +30198 30198 Thulium 170 Tm-170 +30199 30199 Ytterbium 169 Yb-169 +30200 30200 Hafnium 175 Hf-175 +30201 30201 Hafnium 181 Hf-181 +30202 30202 Tantalum 179 Ta-179 +30203 30203 Tantalum 182 Ta-182 +30204 30204 Rhenium 184 Re-184 +30205 30205 Iridium 192 Ir-192 +30206 30206 Mercury 203 Hg-203 +30207 30207 Thallium 204 Tl-204 +30208 30208 Thallium 207 Tl-207 +30209 30209 Thallium 208 Tl-208 +30210 30210 Thallium 209 Tl-209 +30211 30211 Bismuth 205 Bi-205 +30212 30212 Bismuth 207 Bi-207 +30213 30213 Bismuth 210 Bi-210 +30214 30214 Bismuth 211 Bi-211 +30215 30215 Bismuth 212 Bi-212 +30216 30216 Bismuth 213 Bi-213 +30217 30217 Bismuth 214 Bi-214 +30218 30218 Polonium 208 Po-208 +30219 30219 Polonium 210 Po-210 +30220 30220 Polonium 212 Po-212 +30221 30221 Polonium 213 Po-213 +30222 30222 Polonium 214 Po-214 +30223 30223 Polonium 215 Po-215 +30224 30224 Polonium 216 Po-216 +30225 30225 Polonium 218 Po-218 +30226 30226 Lead 209 Pb-209 +30227 30227 Lead 210 Pb-210 +30228 30228 Lead 211 Pb-211 +30229 30229 Lead 212 Pb-212 +30230 30230 Lead 214 Pb-214 +30231 30231 Astatine 217 At-217 +30232 30232 Radon 219 Rn-219 +30233 30233 Radon 220 Rn-220 +30234 30234 Radon 222 Rn-222 +30235 30235 Francium 221 Fr-221 +30236 30236 Francium 223 Fr-223 +30237 30237 Radium 223 Ra-223 +30238 30238 Radium 224 Ra-224 +30239 30239 Radium 225 Ra-225 +30240 30240 Radium 226 Ra-226 +30241 30241 Radium 228 Ra-228 +30242 30242 Actinium 225 Ac-225 +30243 30243 Actinium 227 Ac-227 +30244 30244 Actinium 228 Ac-228 +30245 30245 Thorium 227 Th-227 +30246 30246 Thorium 228 Th-228 +30247 30247 Thorium 229 Th-229 +30248 30248 Thorium 230 Th-230 +30249 30249 Thorium 231 Th-231 +30250 30250 Thorium 232 Th-232 +30251 30251 Thorium 234 Th-234 +30252 30252 Protactinium 231 Pa-231 +30253 30253 Protactinium 233 Pa-233 +30254 30254 Protactinium 234 metastable Pa-234m +30255 30255 Uranium 232 U-232 +30256 30256 Uranium 233 U-233 +30257 30257 Uranium 234 U-234 +30258 30258 Uranium 235 U-235 +30259 30259 Uranium 236 U-236 +30260 30260 Uranium 237 U-237 +30261 30261 Uranium 238 U-238 +30262 30262 Plutonium 236 Pu-236 +30263 30263 Plutonium 238 Pu-238 +30264 30264 Plutonium 239 Pu-239 +30265 30265 Plutonium 240 Pu-240 +30266 30266 Plutonium 241 Pu-241 +30267 30267 Plutonium 242 Pu-242 +30268 30268 Plutonium 244 Pu-244 +30269 30269 Neptunium 237 Np-237 +30270 30270 Neptunium 238 Np-238 +30271 30271 Neptunium 239 Np-239 +30272 30272 Americium 241 Am-241 +30273 30273 Americium 242 Am-242 +30274 30274 Americium 242 metastable Am-242m +30275 30275 Americium 243 Am-243 +30276 30276 Curium 242 Cm-242 +30277 30277 Curium 243 Cm-243 +30278 30278 Curium 244 Cm-244 +30279 30279 Curium 245 Cm-245 +30280 30280 Curium 246 Cm-246 +30281 30281 Curium 247 Cm-247 +30282 30282 Curium 248 Cm-248 +30283 30283 Curium 243/244 Cm-243244 +30284 30284 Plutonium 238/Americium 241 Pu-238Am-241 +30285 30285 Plutonium 239/240 Pu-239240 +30286 30286 Berkelium 249 Bk-249 +30287 30287 Californium 249 Cf-249 +30288 30288 Californium 250 Cf-250 +30289 30289 Californium 252 Cf-252 +30290 30290 Sum aerosol particulates SumAer +30291 30291 Sum Iodine SumIod +30292 30292 Sum noble gas SumNG +30293 30293 Activation gas ActGas +30294 30294 Cs-137 Equivalent EquCs137 +30295 30295 Carbon-13 C-13 +30296 30296 Lead Pb +30297 30297 Tellurium 131 Te-131 +30298 30298 Neodymium 137 Nd-137 +30299 30299 Pseudo radionuclide +30300 30300 Silver 112 Ag-112 +30301 30301 Silver 115 Ag-115 +30302 30302 Barium 139 Ba-139 +30303 30303 Barium 141 Ba-141 +30304 30304 Barium 142 Ba-142 +30305 30305 Bromine 84 Br-84 +30306 30306 Cadminum 115 Cd-115 +30307 30307 Cadminum 117 Cd-117 +30308 30308 Cadminum 117 metastable Cd-117m +30309 30309 Cerium 145 Ce-145 +30310 30310 Cerium 146 Ce-146 +30311 30311 Cobalt 58 metastable Co-58m +30312 30312 Ceasium 138 Cs-138 +30313 30313 Ceasium 139 Cs-139 +30314 30314 Iodine 130 aerosol I-130a +30315 30315 Iodine 130 elementary gaseous I-130e +30316 30316 Iodine 130 organic bounded I-130o +30317 30317 Iodine 132 metastable I-132m +30318 30318 Iodine 134 metastable I-134m +30319 30319 Indium 115 metastable In-115m +30320 30320 Indium 117 metastable In-117m +30321 30321 Krypton 83 metastable Kr-83m +30322 30322 Lanthanum 142 La-142 +30323 30323 Lanthanum 143 La-143 +30324 30324 Manganese 56 Mn-56 +30325 30325 Molybdenum 101 Mo-101 +30326 30326 Molybdenum 102 Mo-102 +30327 30327 Neodymium 149 Nd-149 +30328 30328 Neodymium 151 Nd-151 +30329 30329 Palladium 109 Pd-109 +30330 30330 Palladium 112 Pd-112 +30331 30331 Praseodymium 145 Pr-145 +30332 30332 Praseodymium 146 Pr-146 +30333 30333 Praseodymium 147 Pr-147 +30334 30334 Rubidium 89 Rb-89 +30335 30335 Rubidium 90 Rb-90 +30336 30336 Rubidium 90 metastable Rb-90m +30337 30337 Rhodium 105 metastable Rh-105m +30338 30338 Rhodium 107 Rh-107 +30339 30339 Antimony 128 Sb-128 +30340 30340 Antimony 128 metastable Sb-128m +30341 30341 Antimony 129 metastable Sb-129m +30342 30342 Antimony 130 Sb-130 +30343 30343 Antimony 130 metastable Sb-130m +30344 30344 Antimony 131 Sb-131 +30345 30345 Antimony 132 Sb-132 +30346 30346 Antimony 132 metastable Sb-132m +30347 30347 Antimony 133 Sb-133 +30348 30348 Selenium 83 Se-83 +30349 30349 Tin 127 Sn-127 +30350 30350 Tin 127 metastable Sn-127m +30351 30351 Tin 128 Sn-128 +30352 30352 Tin 129 metastable Sn-129m +30353 30353 Tin 130 Sn-130 +30354 30354 Strontium 93 Sr-93 +30355 30355 Technetium 101 Tc-101 +30356 30356 Technetium 102 Tc-102 +30357 30357 Technetium 104 Tc-104 +30358 30358 Technetium 105 Tc-105 +30359 30359 Tellurium 133 Te-133 +30360 30360 Tellurium 133 metastable Te-133m +30361 30361 Tellurium 134 Te-134 +30362 30362 Yttrium 93 metastable Y-93m +30363 30363 Yttrium 94 Y-94 +30364 30364 Yttrium 95 Y-95 +30365 30365 Zirconium 96 Zr-96 +# 30366-39999 Reserved +40000 40000 Singlet sigma oxygen (dioxygen (sigma singlet)) O2 +40001 40001 Singlet delta oxygen (dioxygen (delta singlet)) O2 +40002 40002 Singlet excited oxygen atom O(1D) +40003 40003 Triplet ground state oxygen atom O(3P) +# 40004-59999 Reserved +60000 60000 HOx radical (OH+HO2) HOx* +60001 60001 Total inorganic and organic peroxy radicals (HOO* + ROO*) ROO* +60002 60002 Passive Ozone +60003 60003 NOx expressed as nitrogen NOx +60004 60004 All nitrogen oxides (NOy) expressed as nitrogen NOy +60005 60005 Total inorganic chlorine Clx +60006 60006 Total inorganic bromine Brx +60007 60007 Total inorganic chlorine except HCl, ClONO2: ClOx +60008 60008 Total inorganic bromine except HBr, BrONO2: BrOx +60009 60009 Lumped alkanes +60010 60010 Lumped alkenes +60011 60011 Lumped aromatic compounds +60012 60012 Lumped terpenes +60013 60013 Non-methane volatile organic compounds expressed as carbon NMVOC +60014 60014 Anthropogenic non-methane volatile organic compounds expressed as carbon aNMVOC +60015 60015 Biogenic non-methane volatile organic compounds expressed as carbon bNMVOC +60016 60016 Lumped oxygenated hydrocarbons OVOC +60017 60017 NOx expressed as nitrogen dioxide (NO2) NOx +60018 60018 Organic aldehydes RCHO +60019 60019 Organic peroxides ROOH +60020 60020 Organic nitrates RNO3 +60021 60021 Ethers ROR' +60022 60022 Amines NRR'R'' +60023 60023 Ketones RC(O)R' +60024 60024 Dicarbonyls unsaturated RC(O)CH2C(O)R' +60025 60025 Hydroxy dicarbonyls unsaturated RC(O)CHOHC(O)R' +60026 60026 Hydroxy ketones RC(OH)C(O)R' +60027 60027 Oxides Ox +60028 60028 Peroxyacyl nitrates RC(O)OONO2 +60029 60029 Aromatic peroxide radical (Aryl dioxydanyl radicals) ArOO* +60030 60030 Biogenic secondary organic compound +60031 60031 Anthropogenic secondary organic compound +60032 60032 All hydroxy-peroxides products of the reaction of hydroxy-isoprene adducts with O2 ISOPOOH +60033 60033 Anthropogenic volatile organic compounds aVOC +60034 60034 Biomass burning volatile organic compounds bbVOC +# 60035-61999 Reserved +62000 62000 Total aerosol +62001 62001 Dust dry +62002 62002 Water in ambient +62003 62003 Ammonium dry +62004 62004 Nitrate dry +62005 62005 Nitric acid trihydrate +62006 62006 Sulphate dry +62007 62007 Mercury dry +62008 62008 Sea salt dry +62009 62009 Black carbon dry +62010 62010 Particulate organic matter dry +62011 62011 Primary particulate organic matter dry +62012 62012 Secondary particulate organic matter dry +62013 62013 Black carbon hydrophilic dry +62014 62014 Black carbon hydrophobic dry +62015 62015 Particulate organic matter hydrophilic dry +62016 62016 Particulate organic matter hydrophobic dry +62017 62017 Nitrate hydrophilic dry +62018 62018 Nitrate hydrophobic dry +# 62019 Reserved +62020 62020 Smoke - high absorption +62021 62021 Smoke - low absorption +62022 62022 Aerosol - high absorption +62023 62023 Aerosol - low absorption +# 62024 Reserved +62025 62025 Volcanic ash +62026 62026 Particulate matter (PM) +# 62027 Reserved +62028 62028 Total aerosol hydrophilic +62029 62029 Total aerosol hydrophobic +62030 62030 Primary particulate inorganic matter dry +62031 62031 Secondary particulate inorganic matter dry +62032 62032 Biogenic secondary organic aerosol +62033 62033 Anthropogenic secondary organic aerosol +62034 62034 Rain water H2Orain +62035 62035 Cloud water H2Ocloud +62036 62036 Brown carbon dry +# 62037-62099 Reserved +62100 62100 Alnus (alder) pollen +62101 62101 Betula (birch) pollen +62102 62102 Castanea (chestnut) pollen +62103 62103 Carpinus (hornbeam) pollen +62104 62104 Corylus (hazel) pollen +62105 62105 Fagus (beech) pollen +62106 62106 Fraxinus (ash) pollen +62107 62107 Pinus (pine) pollen +62108 62108 Platanus (plane) pollen +62109 62109 Populus (cottonwood, poplar) pollen +62110 62110 Quercus (oak) pollen +62111 62111 Salix (willow) pollen +62112 62112 Taxus (yew) pollen +62113 62113 Tilia (lime, linden) pollen +62114 62114 Ulmus (elm) pollen +62115 62115 Olea (olive) pollen +# 62116-62199 Reserved +62200 62200 Ambrosia (ragweed, burr-ragweed) pollen +62201 62201 Artemisia (sagebrush, wormwood, mugwort) pollen +62202 62202 Brassica (rape, broccoli, Brussels sprouts, cabbage, cauliflower, collards, kale, kohlrabi, mustard, rutabaga) pollen +62203 62203 Plantago (plantain) pollen +62204 62204 Rumex (dock, sorrel) pollen +62205 62205 Urtica (nettle) pollen +# 62206-62299 Reserved +62300 62300 Poaceae (grass family) pollen +# 62301-62999 Reserved +# 63000-65534 For experimental use at local level +65535 65535 Missing diff --git a/definitions/grib2/tables/33/4.233.table b/definitions/grib2/tables/33/4.233.table new file mode 100644 index 000000000..00b837c93 --- /dev/null +++ b/definitions/grib2/tables/33/4.233.table @@ -0,0 +1,601 @@ +# Code table 4.233 - Aerosol type +0 0 Ozone O3 +1 1 Water vapour H2O +2 2 Methane CH4 +3 3 Carbon dioxide CO2 +4 4 Carbon monoxide CO +5 5 Nitrogen dioxide NO2 +6 6 Nitrous oxide N2O +7 7 Formaldehyde HCHO +8 8 Sulphur dioxide SO2 +9 9 Ammonia NH3 +10 10 Ammonium cation NH4+ +11 11 Nitrogen monoxide NO +12 12 Atomic oxygen O +13 13 Nitrate radical NO3* +14 14 Hydroperoxyl radical HOO* +15 15 Dinitrogen pentoxide N2O5 +16 16 Nitrous acid HONO +17 17 Nitric acid HNO3 +18 18 Peroxynitric acid HO2NO2 +19 19 Hydrogen peroxide H2O2 +20 20 Dihydrogen H2 +21 21 Atomic nitrogen N +22 22 Sulphate anion SO42- +23 23 Atomic Radon Rn +24 24 Mercury vapour Hg(0) +25 25 Mercury(II) cation Hg2+ +26 26 Atomic chlorine Cl +27 27 Chlorine monoxide ClO +28 28 Dichlorine peroxide Cl2O2 +29 29 Hypochlorous acid HClO +30 30 Chlorine nitrate ClONO2 +31 31 Chlorine dioxide ClO2 +32 32 Atomic bromine Br +33 33 Bromine monoxide BrO +34 34 Bromine chloride BrCl +35 35 Hydrogen bromide HBr +36 36 Hypobromous acid HBrO +37 37 Bromine nitrate BrONO2 +38 38 Dioxygen O2 +39 39 Nitryl chloride NO2Cl +40 40 Sulphuric acid H2SO4 +41 41 Hydrogen sulphide H2S +42 42 Sulphur trioxide SO3 +43 43 Bromine Br2 +44 44 Hydrofluoric acid HF +45 45 Sulphur hexafluoride SF6 +46 46 Chlorine Cl2 +# 47-9999 Reserved +10000 10000 Hydroxyl radical HO* +10001 10001 Methyl peroxy radical CH3OO* +10002 10002 Methyl hydroperoxide CH3OOH +10004 10004 Methanol CH3OH +10005 10005 Formic acid HCOOH +10006 10006 Hydrogen cyanide HCN +10007 10007 Aceto nitrile CH3CN +10008 10008 Ethane C2H6 +10009 10009 Ethene (= Ethylene) C2H4 +10010 10010 Ethyne (= Acetylene) C2H2 +10011 10011 Ethanol C2H5OH +10012 10012 Acetic acid C2H5OOH +10013 10013 Peroxyacetyl nitrate CH3C(O)OONO2 +10014 10014 Propane C3H8 +10015 10015 Propene C3H6 +10016 10016 Butane (all isomers) C4H10 +10017 10017 Isoprene C5H10 +10018 10018 Alpha pinene C10H16 +10019 10019 Beta pinene C10H16 +10020 10020 Limonene C10H16 +10021 10021 Benzene C6H6 +10022 10022 Toluene C7H8 +10023 10023 Xylene C8H10 +10024 10024 Methanesulphonic acid CH3SO3H +10025 10025 Methylglyoxal (2-oxopropanal) CH3C(O)CHO +10026 10026 Peroxyacetyl radical CH3C(O)OO* +10027 10027 Methacrylic acid (2-methylprop-2-enoic acid) CH2C(CH3)COOH +10028 10028 Methacrolein (2-methylprop-2-enal) CH2C(CH3)CHO +10029 10029 Acetone (propan-2-one) CH3C(O)CH3 +10030 10030 Ethyl dioxidanyl radical CH3CH2OO* +10031 10031 Butadiene (buta-1,3-diene) (CH2CH)2 +10032 10032 Acetaldehyde (ethanal) CH3CHO +10033 10033 Glycolaldehyde (hydroxyethanal) HOCH2CHO +10034 10034 Cresol (methylphenol), all isomers CH3C6H4OH +10035 10035 Peracetic acid (ethaneperoxoic acid) CH3C(O)OOH +10036 10036 2-hydroxyethyl oxidanyl radical HOCH2CH2O* +10037 10037 2-hydroxyethyl dioxidanyl radical HOCH2CH2OO* +10038 10038 Glyoxal (oxaldehyde) OCHCHO +10039 10039 Isopropyl dioxidanyl radical (CH3)2CHOO* +10040 10040 Isopropyl hydroperoxide (2-hydroperoxypropane) (CH3)2CHOOH +10041 10041 Hydroxyacetone (1-hydroxypropan-2-one) CH3C(O)CH2OH +10042 10042 Peroxyacetic acid (ethaneperoxoic acid) CH3C(O)OOH +10043 10043 Methyl vinyl ketone (but-3-en-2-one) CH3C(O)CHCH2 +10044 10044 Phenoxy radical C6H5O* +10045 10045 Methyl radical CH3* +10046 10046 Carbonyl sulphide (carbon oxide sulphide) OCS +10047 10047 Dibromomethane CH2Br2 +10048 10048 Methoxy radical CH3O* +10049 10049 Tribromomethane CHBr3 +10050 10050 Formyl radical (oxomethyl radical) HOC* +10051 10051 Hydroxymethyl dioxidanyl radical HOCH2OO* +10052 10052 Ethyl hydroperoxide CH3CH2OOH +10053 10053 3-hydroxypropyl dioxidanyl radical HOCH2CH2CH2OO* +10054 10054 3-hydroxypropyl hydroperoxide HOCH2CH2CH2OOH +10055 10055 Methyl-peroxy-nitrate (nitroperoxy-methane) CH3OONO2 +10056 10056 2-lambda^1-oxidanyloxy-2-methylbut-3-en-1-ol (4-hydroxy-3-methyl-1-butene-3-ylperoxy radical) HOCH2C(CH3)(OO*)CHCH2 +10057 10057 2-lambda^1-oxidanyloxy-3-methylbut-3-en-1-ol (2-hydroxy-1-isopropenylethylperoxy radical) HOCH2CH(OO*)C(CH3)CH2 +10058 10058 (Z)-4-hydroperoxy-2-methyl-2-butenal CH2(OOH)CHC(CH3)CHO +10059 10059 (Z)-4-hydroperoxy-3-methyl-2-butenal CH2(OOH)C(CH3)CHCHO +# 10060-10499 Reserved for other simple organic molecules (e.g. higher aldehydes, alcohols, peroxides, etc.) +10500 10500 Dimethyl sulphide CH3SCH3 (DMS) +10501 10501 DMSO (dimethyl sulfoxide) (CH3)2SO +# 10502-20000 Reserved +20001 20001 Hydrogen chloride HCl +20002 20002 CFC-11 (trichlorofluoromethane) CCl3F +20003 20003 CFC-12 (dichlorodifluoromethane) CCl2F2 +20004 20004 CFC-113 (1,1,2-trichloro-1,2,2-trifluoroethane) Cl2FC-CClF2 +20005 20005 CFC-113a (1,1,1-trichloro-2,2,2-trifluoroethane) Cl3C-CF3 +20006 20006 CFC-114 (1,2-dichloro-1,1,2,2-tetrafluoroethane) ClF2C-CClF2 +20007 20007 CFC-115 (1-chloro-1,1,2,2,2-pentafluoroethane) ClF2C-CF3 +20008 20008 HCFC-22 (chlorodifluoromethane) CHClF2 +20009 20009 HCFC-141b (1,1-dichloro-1-fluoroethane) Cl2FC-CH3 +20010 20010 HCFC-142b (1-chloro-1,1-difluoroethane) ClF2C-CH3 +20011 20011 Halon-1202 (dibromodifluoromethane) CBr2F2 +20012 20012 Halon-1211 (bromochlorodifluoromethane) CBrClF2 +20013 20013 Halon-1301 (bromotrifluoromethane) CBrF3 +20014 20014 Halon-2402 (1,2-dibromo-1,1,2,2-tetrafluoroethane) BrF2C-CBrF2 +20015 20015 HCC-40 (methyl chloride) CH3Cl +20016 20016 HCC-10 (carbon tetrachloride) CCl4 +20017 20017 HCC-140a (1,1,1-trichloroethane) Cl3C-CH3 +20018 20018 HBC-40B1 (methyl bromide) CH3Br +20019 20019 HCH (hexachlorocyclohexane) all isomers C6H6Cl6 +20020 20020 alpha-HCH (alpha-hexachlorocyclohexane) both enantiomers alpha-C6H6Cl6 +20021 20021 PCB-153 (2,2',4,4',5,5'-hexachlorobiphenyl) (C6H2Cl3)2 +20022 20022 HCFC-141a (1,1-dichloro-2-fluoroethane) Cl2HC-CH2F +# 20023-29999 Reserved +30000 30000 Radioactive pollutant (tracer, defined by originating centre) +# 30001-30009 Reserved +30010 30010 Tritium (Hydrogen 3) H-3 +30011 30011 Tritium organic bounded H-3o +30012 30012 Tritium inorganic H-3a +30013 30013 Beryllium 7 Be-7 +30014 30014 Beryllium 10 Be-10 +30015 30015 Carbon 14 C-14 +30016 30016 Carbon 14 CO2 C-14CO2 +30017 30017 Carbon 14 other gases C-14og +30018 30018 Nitrogen 13 N-13 +30019 30019 Nitrogen 16 N-16 +30020 30020 Fluorine 18 F-18 +30021 30021 Sodium 22 Na-22 +30022 30022 Phosphate 32 P-32 +30023 30023 Phosphate 33 P-33 +30024 30024 Sulphur 35 S-35 +30025 30025 Chlorine 36 Cl-36 +30026 30026 Potassium 40 K-40 +30027 30027 Argon 41 Ar-41 +30028 30028 Calcium 41 Ca-41 +30029 30029 Calcium 45 Ca-45 +30030 30030 Titanium 44 Ti-44 +30031 30031 Scandium 46 Sc-46 +30032 30032 Vanadium 48 V-48 +30033 30033 Vanadium 49 V-49 +30034 30034 Chrome 51 Cr-51 +30035 30035 Manganese 52 Mn-52 +30036 30036 Manganese 54 Mn-54 +30037 30037 Iron 55 Fe-55 +30038 30038 Iron 59 Fe-59 +30039 30039 Cobalt 56 Co-56 +30040 30040 Cobalt 57 Co-57 +30041 30041 Cobalt 58 Co-58 +30042 30042 Cobalt 60 Co-60 +30043 30043 Nickel 59 Ni-59 +30044 30044 Nickel 63 Ni-63 +30045 30045 Zinc 65 Zn-65 +30046 30046 Gallium 67 Ga-67 +30047 30047 Gallium 68 Ga-68 +30048 30048 Germanium 68 Ge-68 +30049 30049 Germanium 69 Ge-69 +30050 30050 Arsenic 73 As-73 +30051 30051 Selenium 75 Se-75 +30052 30052 Selenium 79 Se-79 +30053 30053 Rubidium 81 Rb-81 +30054 30054 Rubidium 83 Rb-83 +30055 30055 Rubidium 84 Rb-84 +30056 30056 Rubidium 86 Rb-86 +30057 30057 Rubidium 87 Rb-87 +30058 30058 Rubidium 88 Rb-88 +30059 30059 Krypton 85 Kr-85 +30060 30060 Krypton 85 metastable Kr-85m +30061 30061 Krypton 87 Kr-87 +30062 30062 Krypton 88 Kr-88 +30063 30063 Krypton 89 Kr-89 +30064 30064 Strontium 85 Sr-85 +30065 30065 Strontium 89 Sr-89 +30066 30066 Strontium 89/90 Sr-8990 +30067 30067 Strontium 90 Sr-90 +30068 30068 Strontium 91 Sr-91 +30069 30069 Strontium 92 Sr-92 +30070 30070 Yttrium 87 Y-87 +30071 30071 Yttrium 88 Y-88 +30072 30072 Yttrium 90 Y-90 +30073 30073 Yttrium 91 Y-91 +30074 30074 Yttrium 91 metastable Y-91m +30075 30075 Yttrium 92 Y-92 +30076 30076 Yttrium 93 Y-93 +30077 30077 Zirconium 89 Zr-89 +30078 30078 Zirconium 93 Zr-93 +30079 30079 Zirconium 95 Zr-95 +30080 30080 Zirconium 97 Zr-97 +30081 30081 Niobium 93 metastable Nb-93m +30082 30082 Niobium 94 Nb-94 +30083 30083 Niobium 95 Nb-95 +30084 30084 Niobium 95 metastable Nb-95m +30085 30085 Niobium 97 Nb-97 +30086 30086 Niobium 97 metastable Nb-97m +30087 30087 Molybdenum 93 Mo-93 +30088 30088 Molybdenum 99 Mo-99 +30089 30089 Technetium 95 metastable Tc-95m +30090 30090 Technetium 96 Tc-96 +30091 30091 Technetium 99 Tc-99 +30092 30092 Technetium 99 metastable Tc-99m +30093 30093 Rhodium 99 Rh-99 +30094 30094 Rhodium 101 Rh-101 +30095 30095 Rhodium 102 metastable Rh-102m +30096 30096 Rhodium 103 metastable Rh-103m +30097 30097 Rhodium 105 Rh-105 +30098 30098 Rhodium 106 Rh-106 +30099 30099 Palladium 100 Pd-100 +30100 30100 Palladium 103 Pd-103 +30101 30101 Palladium 107 Pd-107 +30102 30102 Ruthenium 103 Ru-103 +30103 30103 Ruthenium 105 Ru-105 +30104 30104 Ruthenium 106 Ru-106 +30105 30105 Silver 108 metastable Ag-108m +30106 30106 Silver 110 metastable Ag-110m +30107 30107 Cadmium 109 Cd-109 +30108 30108 Cadmium 113 metastable Cd-113m +30109 30109 Cadmium 115 metastable Cd-115m +30110 30110 Indium 114 metastable In-114m +30111 30111 Tin 113 Sn-113 +30112 30112 Tin 119 metastable Sn-119m +30113 30113 Tin 121 metastable Sn-121m +30114 30114 Tin 122 Sn-122 +30115 30115 Tin 123 Sn-123 +30116 30116 Tin 126 Sn-126 +30117 30117 Antimony 124 Sb-124 +30118 30118 Antimony 125 Sb-125 +30119 30119 Antimony 126 Sb-126 +30120 30120 Antimony 127 Sb-127 +30121 30121 Antimony 129 Sb-129 +30122 30122 Tellurium 123 metastable Te-123m +30123 30123 Tellurium 125 metastable Te-125m +30124 30124 Tellurium 127 Te-127 +30125 30125 Tellurium 127 metastable Te-127m +30126 30126 Tellurium 129 Te-129 +30127 30127 Tellurium 129 metastable Te-129m +30128 30128 Tellurium 131 metastable Te-131m +30129 30129 Tellurium 132 Te-132 +30130 30130 Iodine 123 I-123 +30131 30131 Iodine 124 I-124 +30132 30132 Iodine 125 I-125 +30133 30133 Iodine 126 I-126 +30134 30134 Iodine 129 I-129 +30135 30135 Iodine 129 elementary gaseous I-129g +30136 30136 Iodine 129 organic bounded I-129o +30137 30137 Iodine 131 I-131 +30138 30138 Iodine 131 elementary gaseous I-131g +30139 30139 Iodine 131 organic bounded I-131o +30140 30140 Iodine 131 gaseous elementary and organic bounded I-131go +30141 30141 Iodine 131 aerosol I-131a +30142 30142 Iodine 132 I-132 +30143 30143 Iodine 132 elementary gaseous I-132g +30144 30144 Iodine 132 organic bounded I-132o +30145 30145 Iodine 132 gaseous elementary and organic bounded I-132go +30146 30146 Iodine 132 aerosol I-132a +30147 30147 Iodine 133 I-133 +30148 30148 Iodine 133 elementary gaseous I-133g +30149 30149 Iodine 133 organic bounded I-133o +30150 30150 Iodine 133 gaseous elementary and organic bounded I-133go +30151 30151 Iodine 133 aerosol I-133a +30152 30152 Iodine 134 I-134 +30153 30153 Iodine 134 elementary gaseous I-134g +30154 30154 Iodine 134 organic bounded I-134o +30155 30155 Iodine 135 I-135 +30156 30156 Iodine 135 elementary gaseous I-135g +30157 30157 Iodine 135 organic bounded I-135o +30158 30158 Iodine 135 gaseous elementary and organic bounded I-135go +30159 30159 Iodine 135 aerosol I-135a +30160 30160 Xenon 131 metastable Xe-131m +30161 30161 Xenon 133 Xe-133 +30162 30162 Xenon 133 metastable Xe-133m +30163 30163 Xenon 135 Xe-135 +30164 30164 Xenon 135 metastable Xe-135m +30165 30165 Xenon 137 Xe-137 +30166 30166 Xenon 138 Xe-138 +30167 30167 Xenon sum of all Xenon isotopes Xe-sum +30168 30168 Caesium 131 Cs-131 +30169 30169 Caesium 134 Cs-134 +30170 30170 Caesium 135 Cs-135 +30171 30171 Caesium 136 Cs-136 +30172 30172 Caesium 137 Cs-137 +30173 30173 Barium 133 Ba-133 +30174 30174 Barium 137 metastable Ba-137m +30175 30175 Barium 140 Ba-140 +30176 30176 Cerium 139 Ce-139 +30177 30177 Cerium 141 Ce-141 +30178 30178 Cerium 143 Ce-143 +30179 30179 Cerium 144 Ce-144 +30180 30180 Lanthanum 140 La-140 +30181 30181 Lanthanum 141 La-141 +30182 30182 Praseodymium 143 Pr-143 +30183 30183 Praseodymium 144 Pr-144 +30184 30184 Praseodymium 144 metastable Pr-144m +30185 30185 Samarium 145 Sm-145 +30186 30186 Samarium 147 Sm-147 +30187 30187 Samarium 151 Sm-151 +30188 30188 Neodymium 147 Nd-147 +30189 30189 Promethium 146 Pm-146 +30190 30190 Promethium 147 Pm-147 +30191 30191 Promethium 151 Pm-151 +30192 30192 Europium 152 Eu-152 +30193 30193 Europium 154 Eu-154 +30194 30194 Europium 155 Eu-155 +30195 30195 Gadolinium 153 Gd-153 +30196 30196 Terbium 160 Tb-160 +30197 30197 Holmium 166 metastable Ho-166m +30198 30198 Thulium 170 Tm-170 +30199 30199 Ytterbium 169 Yb-169 +30200 30200 Hafnium 175 Hf-175 +30201 30201 Hafnium 181 Hf-181 +30202 30202 Tantalum 179 Ta-179 +30203 30203 Tantalum 182 Ta-182 +30204 30204 Rhenium 184 Re-184 +30205 30205 Iridium 192 Ir-192 +30206 30206 Mercury 203 Hg-203 +30207 30207 Thallium 204 Tl-204 +30208 30208 Thallium 207 Tl-207 +30209 30209 Thallium 208 Tl-208 +30210 30210 Thallium 209 Tl-209 +30211 30211 Bismuth 205 Bi-205 +30212 30212 Bismuth 207 Bi-207 +30213 30213 Bismuth 210 Bi-210 +30214 30214 Bismuth 211 Bi-211 +30215 30215 Bismuth 212 Bi-212 +30216 30216 Bismuth 213 Bi-213 +30217 30217 Bismuth 214 Bi-214 +30218 30218 Polonium 208 Po-208 +30219 30219 Polonium 210 Po-210 +30220 30220 Polonium 212 Po-212 +30221 30221 Polonium 213 Po-213 +30222 30222 Polonium 214 Po-214 +30223 30223 Polonium 215 Po-215 +30224 30224 Polonium 216 Po-216 +30225 30225 Polonium 218 Po-218 +30226 30226 Lead 209 Pb-209 +30227 30227 Lead 210 Pb-210 +30228 30228 Lead 211 Pb-211 +30229 30229 Lead 212 Pb-212 +30230 30230 Lead 214 Pb-214 +30231 30231 Astatine 217 At-217 +30232 30232 Radon 219 Rn-219 +30233 30233 Radon 220 Rn-220 +30234 30234 Radon 222 Rn-222 +30235 30235 Francium 221 Fr-221 +30236 30236 Francium 223 Fr-223 +30237 30237 Radium 223 Ra-223 +30238 30238 Radium 224 Ra-224 +30239 30239 Radium 225 Ra-225 +30240 30240 Radium 226 Ra-226 +30241 30241 Radium 228 Ra-228 +30242 30242 Actinium 225 Ac-225 +30243 30243 Actinium 227 Ac-227 +30244 30244 Actinium 228 Ac-228 +30245 30245 Thorium 227 Th-227 +30246 30246 Thorium 228 Th-228 +30247 30247 Thorium 229 Th-229 +30248 30248 Thorium 230 Th-230 +30249 30249 Thorium 231 Th-231 +30250 30250 Thorium 232 Th-232 +30251 30251 Thorium 234 Th-234 +30252 30252 Protactinium 231 Pa-231 +30253 30253 Protactinium 233 Pa-233 +30254 30254 Protactinium 234 metastable Pa-234m +30255 30255 Uranium 232 U-232 +30256 30256 Uranium 233 U-233 +30257 30257 Uranium 234 U-234 +30258 30258 Uranium 235 U-235 +30259 30259 Uranium 236 U-236 +30260 30260 Uranium 237 U-237 +30261 30261 Uranium 238 U-238 +30262 30262 Plutonium 236 Pu-236 +30263 30263 Plutonium 238 Pu-238 +30264 30264 Plutonium 239 Pu-239 +30265 30265 Plutonium 240 Pu-240 +30266 30266 Plutonium 241 Pu-241 +30267 30267 Plutonium 242 Pu-242 +30268 30268 Plutonium 244 Pu-244 +30269 30269 Neptunium 237 Np-237 +30270 30270 Neptunium 238 Np-238 +30271 30271 Neptunium 239 Np-239 +30272 30272 Americium 241 Am-241 +30273 30273 Americium 242 Am-242 +30274 30274 Americium 242 metastable Am-242m +30275 30275 Americium 243 Am-243 +30276 30276 Curium 242 Cm-242 +30277 30277 Curium 243 Cm-243 +30278 30278 Curium 244 Cm-244 +30279 30279 Curium 245 Cm-245 +30280 30280 Curium 246 Cm-246 +30281 30281 Curium 247 Cm-247 +30282 30282 Curium 248 Cm-248 +30283 30283 Curium 243/244 Cm-243244 +30284 30284 Plutonium 238/Americium 241 Pu-238Am-241 +30285 30285 Plutonium 239/240 Pu-239240 +30286 30286 Berkelium 249 Bk-249 +30287 30287 Californium 249 Cf-249 +30288 30288 Californium 250 Cf-250 +30289 30289 Californium 252 Cf-252 +30290 30290 Sum aerosol particulates SumAer +30291 30291 Sum Iodine SumIod +30292 30292 Sum noble gas SumNG +30293 30293 Activation gas ActGas +30294 30294 Cs-137 Equivalent EquCs137 +30295 30295 Carbon-13 C-13 +30296 30296 Lead Pb +30297 30297 Tellurium 131 Te-131 +30298 30298 Neodymium 137 Nd-137 +30299 30299 Pseudo radionuclide +30300 30300 Silver 112 Ag-112 +30301 30301 Silver 115 Ag-115 +30302 30302 Barium 139 Ba-139 +30303 30303 Barium 141 Ba-141 +30304 30304 Barium 142 Ba-142 +30305 30305 Bromine 84 Br-84 +30306 30306 Cadminum 115 Cd-115 +30307 30307 Cadminum 117 Cd-117 +30308 30308 Cadminum 117 metastable Cd-117m +30309 30309 Cerium 145 Ce-145 +30310 30310 Cerium 146 Ce-146 +30311 30311 Cobalt 58 metastable Co-58m +30312 30312 Ceasium 138 Cs-138 +30313 30313 Ceasium 139 Cs-139 +30314 30314 Iodine 130 aerosol I-130a +30315 30315 Iodine 130 elementary gaseous I-130e +30316 30316 Iodine 130 organic bounded I-130o +30317 30317 Iodine 132 metastable I-132m +30318 30318 Iodine 134 metastable I-134m +30319 30319 Indium 115 metastable In-115m +30320 30320 Indium 117 metastable In-117m +30321 30321 Krypton 83 metastable Kr-83m +30322 30322 Lanthanum 142 La-142 +30323 30323 Lanthanum 143 La-143 +30324 30324 Manganese 56 Mn-56 +30325 30325 Molybdenum 101 Mo-101 +30326 30326 Molybdenum 102 Mo-102 +30327 30327 Neodymium 149 Nd-149 +30328 30328 Neodymium 151 Nd-151 +30329 30329 Palladium 109 Pd-109 +30330 30330 Palladium 112 Pd-112 +30331 30331 Praseodymium 145 Pr-145 +30332 30332 Praseodymium 146 Pr-146 +30333 30333 Praseodymium 147 Pr-147 +30334 30334 Rubidium 89 Rb-89 +30335 30335 Rubidium 90 Rb-90 +30336 30336 Rubidium 90 metastable Rb-90m +30337 30337 Rhodium 105 metastable Rh-105m +30338 30338 Rhodium 107 Rh-107 +30339 30339 Antimony 128 Sb-128 +30340 30340 Antimony 128 metastable Sb-128m +30341 30341 Antimony 129 metastable Sb-129m +30342 30342 Antimony 130 Sb-130 +30343 30343 Antimony 130 metastable Sb-130m +30344 30344 Antimony 131 Sb-131 +30345 30345 Antimony 132 Sb-132 +30346 30346 Antimony 132 metastable Sb-132m +30347 30347 Antimony 133 Sb-133 +30348 30348 Selenium 83 Se-83 +30349 30349 Tin 127 Sn-127 +30350 30350 Tin 127 metastable Sn-127m +30351 30351 Tin 128 Sn-128 +30352 30352 Tin 129 metastable Sn-129m +30353 30353 Tin 130 Sn-130 +30354 30354 Strontium 93 Sr-93 +30355 30355 Technetium 101 Tc-101 +30356 30356 Technetium 102 Tc-102 +30357 30357 Technetium 104 Tc-104 +30358 30358 Technetium 105 Tc-105 +30359 30359 Tellurium 133 Te-133 +30360 30360 Tellurium 133 metastable Te-133m +30361 30361 Tellurium 134 Te-134 +30362 30362 Yttrium 93 metastable Y-93m +30363 30363 Yttrium 94 Y-94 +30364 30364 Yttrium 95 Y-95 +30365 30365 Zirconium 96 Zr-96 +# 30366-39999 Reserved +40000 40000 Singlet sigma oxygen (dioxygen (sigma singlet)) O2 +40001 40001 Singlet delta oxygen (dioxygen (delta singlet)) O2 +40002 40002 Singlet excited oxygen atom O(1D) +40003 40003 Triplet ground state oxygen atom O(3P) +# 40004-59999 Reserved +60000 60000 HOx radical (OH+HO2) HOx* +60001 60001 Total inorganic and organic peroxy radicals (HOO* + ROO*) ROO* +60002 60002 Passive Ozone +60003 60003 NOx expressed as nitrogen NOx +60004 60004 All nitrogen oxides (NOy) expressed as nitrogen NOy +60005 60005 Total inorganic chlorine Clx +60006 60006 Total inorganic bromine Brx +60007 60007 Total inorganic chlorine except HCl, ClONO2: ClOx +60008 60008 Total inorganic bromine except HBr, BrONO2: BrOx +60009 60009 Lumped alkanes +60010 60010 Lumped alkenes +60011 60011 Lumped aromatic compounds +60012 60012 Lumped terpenes +60013 60013 Non-methane volatile organic compounds expressed as carbon NMVOC +60014 60014 Anthropogenic non-methane volatile organic compounds expressed as carbon aNMVOC +60015 60015 Biogenic non-methane volatile organic compounds expressed as carbon bNMVOC +60016 60016 Lumped oxygenated hydrocarbons OVOC +60017 60017 NOx expressed as nitrogen dioxide (NO2) NOx +60018 60018 Organic aldehydes RCHO +60019 60019 Organic peroxides ROOH +60020 60020 Organic nitrates RNO3 +60021 60021 Ethers ROR' +60022 60022 Amines NRR'R'' +60023 60023 Ketones RC(O)R' +60024 60024 Dicarbonyls unsaturated RC(O)CH2C(O)R' +60025 60025 Hydroxy dicarbonyls unsaturated RC(O)CHOHC(O)R' +60026 60026 Hydroxy ketones RC(OH)C(O)R' +60027 60027 Oxides Ox +60028 60028 Peroxyacyl nitrates RC(O)OONO2 +60029 60029 Aromatic peroxide radical (Aryl dioxydanyl radicals) ArOO* +60030 60030 Biogenic secondary organic compound +60031 60031 Anthropogenic secondary organic compound +60032 60032 All hydroxy-peroxides products of the reaction of hydroxy-isoprene adducts with O2 ISOPOOH +60033 60033 Anthropogenic volatile organic compounds aVOC +60034 60034 Biomass burning volatile organic compounds bbVOC +# 60035-61999 Reserved +62000 62000 Total aerosol +62001 62001 Dust dry +62002 62002 Water in ambient +62003 62003 Ammonium dry +62004 62004 Nitrate dry +62005 62005 Nitric acid trihydrate +62006 62006 Sulphate dry +62007 62007 Mercury dry +62008 62008 Sea salt dry +62009 62009 Black carbon dry +62010 62010 Particulate organic matter dry +62011 62011 Primary particulate organic matter dry +62012 62012 Secondary particulate organic matter dry +62013 62013 Black carbon hydrophilic dry +62014 62014 Black carbon hydrophobic dry +62015 62015 Particulate organic matter hydrophilic dry +62016 62016 Particulate organic matter hydrophobic dry +62017 62017 Nitrate hydrophilic dry +62018 62018 Nitrate hydrophobic dry +# 62019 Reserved +62020 62020 Smoke - high absorption +62021 62021 Smoke - low absorption +62022 62022 Aerosol - high absorption +62023 62023 Aerosol - low absorption +# 62024 Reserved +62025 62025 Volcanic ash +62026 62026 Particulate matter (PM) +# 62027 Reserved +62028 62028 Total aerosol hydrophilic +62029 62029 Total aerosol hydrophobic +62030 62030 Primary particulate inorganic matter dry +62031 62031 Secondary particulate inorganic matter dry +62032 62032 Biogenic secondary organic aerosol +62033 62033 Anthropogenic secondary organic aerosol +62034 62034 Rain water H2Orain +62035 62035 Cloud water H2Ocloud +62036 62036 Brown carbon dry +# 62037-62099 Reserved +62100 62100 Alnus (alder) pollen +62101 62101 Betula (birch) pollen +62102 62102 Castanea (chestnut) pollen +62103 62103 Carpinus (hornbeam) pollen +62104 62104 Corylus (hazel) pollen +62105 62105 Fagus (beech) pollen +62106 62106 Fraxinus (ash) pollen +62107 62107 Pinus (pine) pollen +62108 62108 Platanus (plane) pollen +62109 62109 Populus (cottonwood, poplar) pollen +62110 62110 Quercus (oak) pollen +62111 62111 Salix (willow) pollen +62112 62112 Taxus (yew) pollen +62113 62113 Tilia (lime, linden) pollen +62114 62114 Ulmus (elm) pollen +62115 62115 Olea (olive) pollen +# 62116-62199 Reserved +62200 62200 Ambrosia (ragweed, burr-ragweed) pollen +62201 62201 Artemisia (sagebrush, wormwood, mugwort) pollen +62202 62202 Brassica (rape, broccoli, Brussels sprouts, cabbage, cauliflower, collards, kale, kohlrabi, mustard, rutabaga) pollen +62203 62203 Plantago (plantain) pollen +62204 62204 Rumex (dock, sorrel) pollen +62205 62205 Urtica (nettle) pollen +# 62206-62299 Reserved +62300 62300 Poaceae (grass family) pollen +# 62301-62999 Reserved +# 63000-65534 For experimental use at local level +65535 65535 Missing diff --git a/definitions/grib2/tables/33/4.234.table b/definitions/grib2/tables/33/4.234.table new file mode 100644 index 000000000..3b05b4515 --- /dev/null +++ b/definitions/grib2/tables/33/4.234.table @@ -0,0 +1,21 @@ +# Code table 4.234 - Canopy cover fraction (to be used as partitioned parameter in product definition template 4.53 or 4.54) +1 1 Crops, mixed farming +2 2 Short grass +3 3 Evergreen needleleaf trees +4 4 Deciduous needleleaf trees +5 5 Deciduous broadleaf trees +6 6 Evergreen broadleaf trees +7 7 Tall grass +8 8 Desert +9 9 Tundra +10 10 Irrigated crops +11 11 Semidesert +12 12 Ice caps and glaciers +13 13 Bogs and marshes +14 14 Inland water +15 15 Ocean +16 16 Evergreen shrubs +17 17 Deciduous shrubs +18 18 Mixed forest +19 19 Interrupted forest +20 20 Water and land mixtures diff --git a/definitions/grib2/tables/33/4.236.table b/definitions/grib2/tables/33/4.236.table new file mode 100644 index 000000000..9c58b488c --- /dev/null +++ b/definitions/grib2/tables/33/4.236.table @@ -0,0 +1,8 @@ +# Code table 4.236 - Soil texture fraction (to be used as partitioned parameter in product definition template 4.53 or 4.54) +1 1 Coarse +2 2 Medium +3 3 Medium-fine +4 4 Fine +5 5 Very-fine +6 6 Organic +7 7 Tropical-organic diff --git a/definitions/grib2/tables/33/4.238.table b/definitions/grib2/tables/33/4.238.table new file mode 100644 index 000000000..cd8b5cba8 --- /dev/null +++ b/definitions/grib2/tables/33/4.238.table @@ -0,0 +1,34 @@ +# Code table 4.238 - Source or sink +0 0 Other +1 1 Aviation +2 2 Lightning +3 3 Biogenic sources +4 4 Anthropogenic sources +5 5 Wild fires +6 6 Natural sources +7 7 Volcanoes +8 8 Bio-fuel +9 9 Fossil-fuel +10 10 Wetlands +11 11 Oceans +12 12 Elevated anthropogenic sources +13 13 Surface anthropogenic sources +14 14 Agriculture livestock +15 15 Agriculture soils +16 16 Agriculture waste burning +17 17 Agriculture (all) +18 18 Residential, commercial and other combustion +19 19 Power generation +20 20 Super power stations +21 21 Fugitives +22 22 Industrial process +23 23 Solvents +24 24 Ships +25 25 Wastes (solid and water) +26 26 Road transportation +27 27 Off-road transportation +28 28 Nuclear power plant +29 29 Nuclear weapon +# 30-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.239.table b/definitions/grib2/tables/33/4.239.table new file mode 100644 index 000000000..f095b14a0 --- /dev/null +++ b/definitions/grib2/tables/33/4.239.table @@ -0,0 +1,17 @@ +# Code table 4.239 - Wetland Type +0 0 Reserved +1 1 Bog +2 2 Drained +3 3 Fen +4 4 Floodplain +5 5 Mangrove +6 6 Marsh +7 7 Rice +8 8 Riverine +9 9 Salt marsh +10 10 Swamp +11 11 Upland +12 12 Wet tundra +# 13-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.240.table b/definitions/grib2/tables/33/4.240.table new file mode 100644 index 000000000..2a31fb2ab --- /dev/null +++ b/definitions/grib2/tables/33/4.240.table @@ -0,0 +1,13 @@ +# Code table 4.240 - Type of distribution function +0 0 No specific distribution function given +1 1 Delta functions with spatially variable concentration and fixed diameters Dl (p1) in metre +2 2 Delta functions with spatially variable concentration and fixed masses Ml (p1) in kg +3 3 Gaussian (normal) distribution with spatially variable concentration and fixed mean diameter Dl(p1) and variance(p2) +4 4 Gaussian (normal) distribution with spatially variable concentration, mean diameter and variance +5 5 Log-normal distribution with spatially variable number density, mean diameter and variance +6 6 Log-normal distribution with spatially variable number density, mean diameter and fixed variance(p1) +7 7 Log-normal distribution with spatially variable number density and mass density and fixed variance(p1) and fixed particle density(p2) +8 8 No distribution function. The encoded variable is derived from variables characterized by type of distribution function of type No. 7 (see above) with fixed variance(p1) and fixed particle density(p2) +# 9-49151 Reserved +# 49152-65534 Reserved for local use +65535 65535 Missing value diff --git a/definitions/grib2/tables/33/4.241.table b/definitions/grib2/tables/33/4.241.table new file mode 100644 index 000000000..743e5f6e2 --- /dev/null +++ b/definitions/grib2/tables/33/4.241.table @@ -0,0 +1,12 @@ +# Code table 4.241 - Coverage attributes +0 UNDEF Undefined +1 UNMOD Unmodified +2 SNOW Snow covered +3 FLOOD Flooded +4 ICE Ice covered +5 ITCW With intercepted water +6 ITCS With intercepted snow +7 AGG Aggregated +# 8-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/33/4.242.table b/definitions/grib2/tables/33/4.242.table new file mode 100644 index 000000000..9574142da --- /dev/null +++ b/definitions/grib2/tables/33/4.242.table @@ -0,0 +1,10 @@ +# Code table 4.242 - Tile classification +0 0 Reserved +1 GCV2009 Land use classes according to ESA-GlobCover GCV2009 +2 GLC2000 Land use classes according to European Commission-Global Land Cover Project GLC2000 +3 ECOCLIMAP Land use classes according to ECOCLIMAP +4 ECOCLIMAP-SG Land use classes according to ECOCLIMAP-SG +5 GLCCv2BATS Land use classes according to USGS EROS Global Land Cover Characterization (GLCC) v2.0 BATS Classification +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/33/4.243.table b/definitions/grib2/tables/33/4.243.table new file mode 100644 index 000000000..24d21b719 --- /dev/null +++ b/definitions/grib2/tables/33/4.243.table @@ -0,0 +1,43 @@ +# Code table 4.243 - Tile class +0 0 Reserved +1 1 Evergreen broadleaved forest +2 2 Deciduous broadleaved closed forest +3 3 Deciduous broadleaved open forest +4 4 Evergreen needle-leaf forest +5 5 Deciduous needle-leaf forest +6 6 Mixed leaf trees +7 7 Freshwater flooded trees +8 8 Saline water flooded trees +9 9 Mosaic tree/natural vegetation +10 10 Burnt tree cover +11 11 Evergreen shrubs closed-open +12 12 Deciduous shrubs closed-open +13 13 Herbaceous vegetation closed-open +14 14 Sparse herbaceous or grass +15 15 Flooded shrubs or herbaceous +16 16 Cultivated and managed areas +17 17 Mosaic crop/tree/natural vegetation +18 18 Mosaic crop/shrub/grass +19 19 Bare areas +20 20 Water +21 21 Snow and ice +22 22 Artificial surface +23 23 Ocean +24 24 Irrigated croplands +25 25 Rainfed croplands +26 26 Mosaic cropland (50-70%) - vegetation (20-50%) +27 27 Mosaic vegetation (50-70%) - cropland (20-50%) +28 28 Closed broadleaved evergreen forest +29 29 Closed needle-leaved evergreen forest +30 30 Open needle-leaved deciduous forest +31 31 Mixed broadleaved and needle-leaved forest +32 32 Mosaic shrubland (50-70%) - grassland (20-50%) +33 33 Mosaic grassland (50-70%) - shrubland (20-50%) +34 34 Closed to open shrubland +35 35 Sparse vegetation +36 36 Closed to open forest regularly flooded +37 37 Closed forest or shrubland permanently flooded +38 38 Closed to open grassland regularly flooded +39 39 Undefined +# 40-32767 Reserved +# 32768- Reserved for local use diff --git a/definitions/grib2/tables/33/4.244.table b/definitions/grib2/tables/33/4.244.table new file mode 100644 index 000000000..a4470cd56 --- /dev/null +++ b/definitions/grib2/tables/33/4.244.table @@ -0,0 +1,7 @@ +# Code table 4.244 - Quality indicator +0 0 No quality information available +1 1 Failed +2 2 Passed +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.246.table b/definitions/grib2/tables/33/4.246.table new file mode 100644 index 000000000..0ca9c0c98 --- /dev/null +++ b/definitions/grib2/tables/33/4.246.table @@ -0,0 +1,7 @@ +# Code table 4.246 - Thunderstorm intensity +0 0 No thunderstorm occurrence +1 1 Weak thunderstorm +2 2 Moderate thunderstorm +3 3 Severe thunderstorm +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/4.247.table b/definitions/grib2/tables/33/4.247.table new file mode 100644 index 000000000..6da16e396 --- /dev/null +++ b/definitions/grib2/tables/33/4.247.table @@ -0,0 +1,7 @@ +# Code table 4.247 - Precipitation intensity +0 0 No precipitation occurrence +1 1 Light precipitation +2 2 Moderate precipitation +3 3 Heavy precipitation +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/4.248.table b/definitions/grib2/tables/33/4.248.table new file mode 100644 index 000000000..04e365c97 --- /dev/null +++ b/definitions/grib2/tables/33/4.248.table @@ -0,0 +1,6 @@ +# Code table 4.248 - Method used to derive data values for a given local time +0 0 Nearest forecast or analysis time to specified local time +1 1 Interpolated to be valid at the specified local time +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.249.table b/definitions/grib2/tables/33/4.249.table new file mode 100644 index 000000000..bd1c944c4 --- /dev/null +++ b/definitions/grib2/tables/33/4.249.table @@ -0,0 +1,7 @@ +# Code table 4.249 - Character of precipitation +0 0 None +1 1 Showers +2 2 Intermittent +3 3 Continuous +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/4.250.table b/definitions/grib2/tables/33/4.250.table new file mode 100644 index 000000000..a249158ca --- /dev/null +++ b/definitions/grib2/tables/33/4.250.table @@ -0,0 +1,14 @@ +# Code table 4.250 - Drainage direction +0 0 Reserved +1 1 South-west +2 2 South +3 3 South-east +4 4 West +5 5 No direction +6 6 East +7 7 North-west +8 8 North +9 9 North-east +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.251.table b/definitions/grib2/tables/33/4.251.table new file mode 100644 index 000000000..3a78e713e --- /dev/null +++ b/definitions/grib2/tables/33/4.251.table @@ -0,0 +1,7 @@ +# Code table 4.251 - Wave direction and frequency formulae +0 0 Undefined sequence +1 1 Geometric sequence +2 2 Arithmetic sequence +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.252.table b/definitions/grib2/tables/33/4.252.table new file mode 100644 index 000000000..3baf4064c --- /dev/null +++ b/definitions/grib2/tables/33/4.252.table @@ -0,0 +1,165 @@ +# Code table 4.252 - Tile classes and groupings +0 0 Reserved +1 SEOC Seas and oceans +2 INWB Inland water bodies +3 BARE Bare areas +4 HIV High vegetation +5 LOV Low vegetation +6 URBAN Urban +# 7-1000 Reserved for intercomparison tile classes/groupings +1001 SEAO Sea and oceans +1002 LAKE Lakes +1003 RIVE Rivers +1004 NO Bare land +1005 ROCK Bare rock +1006 SNOW Permanent snow +1007 BOBD Boreal broadleaf deciduous +1008 TEBD Temperate broadleaf deciduous +1009 TRBD Tropical broadleaf deciduous +1010 TEBE Temperate broadleaf evergreen +1011 TRBE Tropical broadleaf evergreen +1012 BONE Boreal needleleaf evergreen +1013 TENE Temperate needleleaf evergreen +1014 BOND Boreal needleleaf deciduous +1015 SHRB Shrubs +1016 BOGR Boreal grassland +1017 GRAS Temperate grassland +1018 TROG Tropical grassland +1019 C3W Winter C3 crops +1020 C3S Summer C3 crops +1021 C4 C4 crops +1022 FLTR Flooded trees +1023 FLGR Flooded grassland +1024 LCZ1 Local climate zone 1: compact high-rise (buildings) +1025 LCZ2 Local climate zone 2: compact midrise (buildings) +1026 LCZ3 Local climate zone 3: compact low-rise (buildings) +1027 LCZ4 Local climate zone 4: open high-rise (buildings) +1028 LCZ5 Local climate zone 5: open midrise (buildings) +1029 LCZ6 Local climate zone 6: open low-rise (buildings) +1030 LCZ7 Local climate zone 7: lightweight low-rise (buildings) +1031 LCZ8 Local climate zone 8: large low-rise (buildings) +1032 LCZ9 Local climate zone 9: sparsely built (buildings) +1033 LCZ10 Local climate zone 10: heavy industry (buildings) +1034 TEBDU Urban temperate broadleaf deciduous +1035 TRBDU Urban tropical broadleaf deciduous +1036 TEBEU Urban temperate broadleaf evergreen +1037 TRBEU Urban tropical broadleaf evergreen +1038 BONEU Urban boreal needleleaf evergreen +1039 TENEU Urban temperate needleleaf evergreen +1040 BONDU Urban boreal needleleaf deciduous +# 1041-1500 Reserved for tile class entries for tile models using the ECOCLIMAP-SG land cover survey +# v8.1 groupings +1501 GNATU Nature grouping (NO + ROCK + SNOW + BOBD + TEBD + TRBD + TEBE + TRBE + BONE + TENE + BOND + SHRB + BOGR + GRAS + TROG + C3W + C3S + C4 + FLTR + FLGR) +1502 GNOFO Non-forest grouping (NO + ROCK + SNOW + BOGR + GRAS + TROG + C3W + C3S + C4 + FLTR + FLGR) +1503 GFORE Forest grouping (BOBD + TEBD + TRBD + TEBE + TRBE + BONE + TENE + BOND + SHRB) +1504 GNOVE Non-vegetated grouping (NO + ROCK + SNOW) +1505 GTREE Trees grouping (BOBD + TEBD + TRBD + TEBE + TRBE + BONE + TENE + BOND + SHRB + FLTR) +1506 GLVEG Low vegetation grouping (BOGR + GRAS + TROG + C3W + C3S + C4 + FLGR) +1507 GNFLV Non-flooded low vegetation grouping (BOGR + GRAS + TROG + C3W + C3S + C4) +1508 GCROP Crops grouping (C3W + C3S + C4) +1509 GGRAS Grassland grouping (BOGR + GRAS + TROG) +1510 GBARO Bare and rock grouping (NO + ROCK) +1511 GC3CR C3 crops grouping (C3W + C3S) +1512 GBFOR Broadleaf forest grouping (BOBD + TEBD + TRBD + TEBE + TRBE + SHRB) +1513 GNFOR Needleleaf forest grouping (BONE + TENE + BOND) +1514 GDBFO Deciduous broadleaf forest grouping (BOBD + TEBD + TRBD + TEBE + SHRB) +1515 GTGRA Temperate grassland grouping (BOGR + GRAS) +# v9.0 groupings +1516 GNFNF Non-forest (no FLTR) grouping (NO + ROCK + SNOW + BOGR + GRAS + TROG + C3W + C3S + C4 + FLGR) +1517 GBFFT Broadleaf forest (with FLTR) grouping (BOBD + TEBD + TRBD + TEBE + TRBE + SHRB + FLTR) +1518 GBTRE Broadleaf trees grouping (BOBD + TEBD + TRBD + TEBE + TRBE + FLTR) +1519 GCGRA C3/C4 grasslands grouping (BOGR + GRAS + FLGR) +1520 GBDTR Broadleaf deciduous trees grouping (BOBD + TEBD + TRBD + FLTR) +1521 GBETR Broadleaf evergreen trees grouping (TEBE + TRBE) +1522 GNETR Needleleaf evergreen trees grouping (BONE + TENE) +# Other groupings +1523 GLCZU LCZ or urban grouping (LCZ1 + LCZ2 + LCZ3 + LCZ4 + LCZ5 + LCZ6 + LCZ7 + LCZ8 + LCZ9 + LCZ10) +1524 GIWAT Inland water grouping (LAKE + RIVE) +1525 GPTEBD Urban parks and gardens TEBD grouping (NO + GRAS + TEBDU) +1526 GPTRBD Urban parks and gardens TRBD grouping (NO + GRAS + TRBDU) +1527 GPTEBE Urban parks and gardens TEBE grouping (NO + GRAS + TEBEU) +1528 GPTRBE Urban parks and gardens TRBE grouping (NO + GRAS + TRBEU) +1529 GPBONE Urban parks and gardens BONE grouping (NO + GRAS + BONEU) +1530 GPTENE Urban parks and gardens TENE grouping (NO + GRAS + TENEU) +1531 GPBOND Urban parks and gardens BOND grouping (NO + GRAS + BONDU) +# 1532-2000 Reserved for tile grouping entries for tile models using the ECOCLIMAP-SG land cover survey +2001 CRMF Crops, mixed farming +2002 SHGR Short grass +2003 EVNE Evergreen needleleaf trees +2004 DENE Deciduous needleleaf trees +2005 DEBR Deciduous broadleaf trees +2006 EVBR Evergreen broadleaf trees +2007 TAGR Tall grass +2008 DESE Desert +2009 TUND Tundra +2010 IRCR Irrigated crops +2011 SEDE Semidesert +2012 ICGL Ice caps and glaciers +2013 BOMA Bogs and marshes +2014 INWA Inland water +2015 OCEA Ocean +2016 EVSH Evergreen shrubs +2017 DESH Deciduous shrubs +2018 MFWO Mixed forest/woodland +2019 INFO Interrupted forest +2020 WLMI Water and land mixtures +2021 BASO Bare soil +2022 URBA Urban +2023 LORI Low-rise building +2024 HIRI High-rise building +# 2025-2500 Reserved for tile class entries for tile models using the GLCC v2.0 BATS Classification survey +2501 GLVE Low vegetation grouping (CRMF + SHGR + TAGR + TUND + IRCR + SEDE + BOMA + EVSH + DESH + WLMI) +2502 GHVE High vegetation grouping (EVNE + DENE + DEBR + EVBR + MFWO + INFO) +# 2503-3000 Reserved for tile grouping entries for tile models using the GLCC v2.0 BATS Classification survey +3001 PFIC Post-flooding or irrigated croplands +3002 RACR Rainfed croplands +3003 MCVE Mosaic cropland (50-70%) / vegetation (grassland, shrubland, forest) (20-50%) +3004 MVCR Mosaic vegetation (grassland, shrubland, forest) (50-70%) / cropland (20-50%) +3005 COBS Closed to open (>15%) broadleaved evergreen and/or semi-deciduous forest (>5m) +3006 CLBD Closed (>40%) broadleaved deciduous forest (>5m) +3007 OPBD Open (15-40%) broadleaved deciduous forest (>5m) +3008 CLNE Closed (>40%) needleleaved evergreen forest (>5m) +3009 ONDE Open (15-40%) needleleaved deciduous or evergreen forest (>5m) +3010 COBN Closed to open (>15%) mixed broadleaved and needleleaved forest (>5m) +3011 MFSG Mosaic forest/shrubland (50-70%) / grassland (20-50%) +3012 MGFS Mosaic grassland (50-70%) / forest / shrubland (20-50%) +3013 COSH Closed to open (>15%) shrubland (<5m) +3014 COHV Closed to open (>15%) herbaceous vegetation +3015 SPVE Sparse (<15%) vegetation (woody vegetation, shrubs, grassland) +3016 COBFF Closed to open (>15%) broadleaved forest regularly flooded (semi-permanently or temporarily) - fresh or brackish water +3017 CLBFF Closed (>40%) broadleaved forest or shrubland permanently flooded - saline or brackish water +3018 COVEF Closed to open (>15%) vegetation (grassland, shrubland, woody vegetation) on regularly flooded or waterlogged soil - fresh, brackish or saline water +3019 ASAA Artificial surfaces and associated areas (urban areas >50%) +3020 BAAR Bare areas +3021 WABO Water bodies +3022 PESI Permanent snow and ice +# 3023-3500 Reserved for tile class entries for tile models using the ESA-GlobCover GCV2009 survey +3501 GRDT Grouping using the dominant tiles approach (dominant tile varies per gridbox) +# 3502-4000 Reserved for tile grouping entries for tile models using the ESA-GlobCover GCV2009 survey +4001 TBECO Tree cover, broadleaved evergreen, closed to open (>15%) +4002 TBDC Tree cover, broadleaved deciduous, closed (>40%) +4003 TBDO Tree cover, broadleaved deciduous, open (15-40%) +4004 TNECO Tree cover, needleleaved evergreen, closed to open (>15%) +4005 TNDCO Tree cover, needleleaved decidous, closed to open (>15%) +4006 TMLCO Tree cover, mixed leaftype, closed to open (>15%) +4007 TCOFF Tree cover, closed to open (>15%), regularly flooded, fresh or brackish water: swamp forests +4008 TCOFS Tree cover, closed to open (>15%), regularly flooded, saline water: mangrove forests +4009 MTVG Mosaic of tree cover and other natural vegetation (crop component possible) +4010 TBURN Tree Cover, burnt (mainly boreal forests) +4011 SCOE Shrubcover, closed to open (>15%), evergreen (broadleaved or needleleaved) +4012 SCOD Shrubcover, closed to open (>15%), deciduous (broadleaved) +4013 HCCO Herbaceous cover, closed to open (>15%) +4014 SHSC Sparse herbaceous or sparse shrub cover +4015 FSHCO Regularly flooded (>2 month) shrub or herbaceous cover, closed to open +4016 CROP Cropland (upland crops or inundated/ flooded crops) +4017 MCTNV Mosaic of cropland / tree cover/ other natural vegetation +4018 MCSH Mosaic of cropland / shrub or herbaceous cover +4019 BAARE Bare areas +4020 WBNA Water bodies (natural or artificial) +4021 SINA Snow or ice (natural or artificial) +4022 URAR Urban areas +# 4023-4500 Reserved for tile class entries for tile models using the European Commission-Global Land Cover Project GLC2000 survey +# 4501-5000 Reserved for tile grouping entries for tile models using the European Commission-Global Land Cover Project GLC2000 survey +# 5001-32767 Reserved for additional land cover surveys +# 32768-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/33/4.3.table b/definitions/grib2/tables/33/4.3.table new file mode 100644 index 000000000..8ae36efc3 --- /dev/null +++ b/definitions/grib2/tables/33/4.3.table @@ -0,0 +1,26 @@ +# Code table 4.3 - Type of generating process +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +12 12 Post-processed analysis +13 13 Post-processed forecast +14 14 Nowcast +15 15 Hindcast +16 16 Physical retrieval +17 17 Regression analysis +18 18 Difference between two forecasts +19 19 First guess +20 20 Analysis increment +21 21 Initialization increment for analysis +# 22-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.333.table b/definitions/grib2/tables/33/4.333.table new file mode 100644 index 000000000..1367d35c6 --- /dev/null +++ b/definitions/grib2/tables/33/4.333.table @@ -0,0 +1,12 @@ +# Code table 4.333 - Transport dispersion model +1 1 DERMA (Danish Emergency Response Model of the Atmosphere) +2 2 E-EMEP (Emergency EMEP model) +3 3 FLEXPART (Particle dispersion model) +4 4 MLDP (Modèle lagrangien de dispersion de particules) +5 5 MATCH (Multi-scale Atmospheric Transport Model) +6 6 SILAM (System for Integrated modeLling of Atmospheric composition) +7 7 SNAP (Severe Nuclear Accident Program) +8 8 WRF-Chem (Weather Research and Forecasting Chemical model) +9 9 Trajectoire (Trajectory model) +# 10-254 Reserved +255 255 Missing value diff --git a/definitions/grib2/tables/33/4.335.table b/definitions/grib2/tables/33/4.335.table new file mode 100644 index 000000000..f47807cf6 --- /dev/null +++ b/definitions/grib2/tables/33/4.335.table @@ -0,0 +1,7 @@ +# Code table 4.335 - Emission scenario origin +1 1 ARGOS (Accident Reporting and Guiding Operational System) +2 2 JRODOS (Java version of Real time Online Decision SuppOrt System) +3 3 Assimilated (Scenario retrieved from measurements) +4 4 Centre (scenario by originating centre) +# 5-254 Reserved +255 255 Missing value diff --git a/definitions/grib2/tables/33/4.336.table b/definitions/grib2/tables/33/4.336.table new file mode 100644 index 000000000..c7855abea --- /dev/null +++ b/definitions/grib2/tables/33/4.336.table @@ -0,0 +1,13 @@ +# Code table 4.336 - NWP model +1 1 AROME (Meso scale NWP, Meteo-France) +2 2 ARPEGE (Global scale NWP, Meteo-France) +3 3 GFS (Global forecast system, NCEP) +4 4 HARMONIE (HIRLAM-ALADIN Research on Mesoscale Operational NWP) +5 5 HIRLAM (HIgh resolution Limited Area Model) +6 6 IFS (Integrated Forecast System) +7 7 GEM GDPS (Canadian Global Deterministic Prediction System) +8 8 GEM RDPS (Canadian Regional Deterministic Prediction System) +9 9 GEM HRDPS (Canadian High Resolution Deterministic Prediction System) +10 10 WRF (Weather Research and Forecasting) +# 11-254 Reserved +255 255 Missing value diff --git a/definitions/grib2/tables/33/4.4.table b/definitions/grib2/tables/33/4.4.table new file mode 100644 index 000000000..6e63e069c --- /dev/null +++ b/definitions/grib2/tables/33/4.4.table @@ -0,0 +1,17 @@ +# Code table 4.4 - Indicator of unit of time range +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.5.table b/definitions/grib2/tables/33/4.5.table new file mode 100644 index 000000000..f139bc109 --- /dev/null +++ b/definitions/grib2/tables/33/4.5.table @@ -0,0 +1,95 @@ +# Code table 4.5 - Fixed surface types and units +0 0 Reserved +1 sfc Ground or water surface (-) +2 2 Cloud base level (-) +3 3 Level of cloud tops (-) +4 4 Level of 0 degree C isotherm (-) +5 5 Level of adiabatic condensation lifted from the surface (-) +6 6 Maximum wind level (-) +7 sfc Tropopause (-) +8 sfc Nominal top of the atmosphere (-) +9 9 Sea bottom (-) +10 10 Entire atmosphere (-) +11 11 Cumulonimbus (CB) base (m) +12 12 Cumulonimbus (CB) top (m) +13 13 Lowest level where vertically integrated cloud cover exceeds the specified percentage (cloud base for a given percentage cloud cover) (%) +14 14 Level of free convection (LFC) (-) +15 15 Convective condensation level (CCL) (-) +16 16 Level of neutral buoyancy or equilibrium level (LNB) (-) +17 sfc Departure level of the most unstable parcel of air (MUDL) +18 sfc Departure level of a mixed layer parcel of air with specified layer depth (Pa) +19 19 Lowest level where cloud cover exceeds the specified percentage (%) +20 20 Isothermal level (K) +21 21 Lowest level where mass density exceeds the specified value (base for a given threshold of mass density) (kg m-3) +22 22 Highest level where mass density exceeds the specified value (top for a given threshold of mass density) (kg m-3) +23 23 Lowest level where air concentration exceeds the specified value (base for a given threshold of air concentration) (Bq m-3) +24 24 Highest level where air concentration exceeds the specified value (top for a given threshold of air concentration) (Bq m-3) +25 25 Highest level where radar reflectivity exceeds the specified value (echo top for a given threshold of reflectivity) (dBZ) +26 26 Convective cloud layer base (m) +27 27 Convective cloud layer top (m) +# 28-29 Reserved +30 30 Specified radius from the centre of the Sun (m) +31 31 Solar photosphere +32 32 Ionospheric D-region level +33 33 Ionospheric E-region level +34 34 Ionospheric F1-region level +35 35 Ionospheric F2-region level +# 36-99 Reserved +100 pl Isobaric surface (Pa) +101 sfc Mean sea level +102 102 Specific altitude above mean sea level (m) +103 sfc Specified height level above ground (m) +104 104 Sigma level (sigma value) +105 ml Hybrid level (-) +106 sfc Depth below land surface (m) +107 pt Isentropic (theta) level (K) +108 108 Level at specified pressure difference from ground to level (Pa) +109 pv Potential vorticity surface (K m2 kg-1 s-1) +110 110 Reserved +111 111 Eta level (-) +112 112 Reserved +113 113 Logarithmic hybrid level +114 sol Snow level (Numeric) +115 115 Sigma height level +# 116 Reserved +117 117 Mixed layer depth (m) +118 hhl Hybrid height level (-) +119 hpl Hybrid pressure level (-) +# 120-149 Reserved +150 150 Generalized vertical height coordinate +151 sol Soil level (Numeric) +152 sol Sea-ice level (Numeric) +# 153-159 Reserved +160 160 Depth below sea level (m) +161 161 Depth below water surface (m) +162 sfc Lake or river bottom (-) +163 163 Bottom of sediment layer (-) +164 164 Bottom of thermally active sediment layer (-) +165 165 Bottom of sediment layer penetrated by thermal wave (-) +166 sfc Mixing layer (-) +167 167 Bottom of root zone (-) +168 168 Ocean model level (Numeric) +169 169 Ocean level defined by water density (sigma-theta) difference from near-surface to level (kg m-3) +170 170 Ocean level defined by water potential temperature difference from near-surface to level (K) +171 171 Ocean level defined by vertical eddy diffusivity difference from near-surface to level (m2 s-1) +172 172 Ocean level defined by water density (rho) difference from near-surface to level (m) +173 173 Top of snow over sea ice on sea, lake or river +174 sfc Top surface of ice on sea, lake or river +175 175 Top surface of ice, under snow cover, on sea, lake or river +176 176 Bottom surface (underside) ice on sea, lake or river +177 sfc Deep soil (of indefinite depth) +# 178 Reserved +179 179 Top surface of glacier ice and inland ice +180 180 Deep inland or glacier ice (of indefinite depth) +181 181 Grid tile land fraction as a model surface +182 182 Grid tile water fraction as a model surface +183 183 Grid tile ice fraction on sea, lake or river as a model surface +184 184 Grid tile glacier ice and inland ice fraction as a model surface +185 185 Roof level +186 186 Wall level +187 187 Road level +188 188 Melt pond top surface +189 189 Melt pond bottom surface +# 190-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.6.table b/definitions/grib2/tables/33/4.6.table new file mode 100644 index 000000000..ce799721d --- /dev/null +++ b/definitions/grib2/tables/33/4.6.table @@ -0,0 +1,9 @@ +# Code table 4.6 - Type of ensemble forecast +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.7.table b/definitions/grib2/tables/33/4.7.table new file mode 100644 index 000000000..128fa317f --- /dev/null +++ b/definitions/grib2/tables/33/4.7.table @@ -0,0 +1,15 @@ +# Code table 4.7 - Derived forecast +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +10 10 Variance of all ensemble members +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.8.table b/definitions/grib2/tables/33/4.8.table new file mode 100644 index 000000000..78467454a --- /dev/null +++ b/definitions/grib2/tables/33/4.8.table @@ -0,0 +1,6 @@ +# Code table 4.8 - Clustering method +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.9.table b/definitions/grib2/tables/33/4.9.table new file mode 100644 index 000000000..8e481465e --- /dev/null +++ b/definitions/grib2/tables/33/4.9.table @@ -0,0 +1,14 @@ +# Code table 4.9 - Probability type +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +5 5 Probability of event equal to lower limit +6 6 Probability of event in above normal category +7 7 Probability of event in near normal category +8 8 Probability of event in below normal category +9 9 Probability based on counts of categorical boolean +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/4.91.table b/definitions/grib2/tables/33/4.91.table new file mode 100644 index 000000000..1a0f215f0 --- /dev/null +++ b/definitions/grib2/tables/33/4.91.table @@ -0,0 +1,16 @@ +# Code table 4.91 - Type of Interval +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/5.0.table b/definitions/grib2/tables/33/5.0.table new file mode 100644 index 000000000..5e00004b0 --- /dev/null +++ b/definitions/grib2/tables/33/5.0.table @@ -0,0 +1,22 @@ +# Code table 5.0 - Data representation template number +0 0 Grid point data - simple packing +1 1 Matrix value at grid point - simple packing +2 2 Grid point data - complex packing +3 3 Grid point data - complex packing and spatial differencing +4 4 Grid point data - IEEE floating point data +# 5-39 Reserved +40 40 Grid point data - JPEG 2000 code stream format +41 41 Grid point data - Portable Network Graphics (PNG) +42 42 Grid point data - CCSDS recommended lossless compression +# 43-49 Reserved +50 50 Spectral data - simple packing +51 51 Spherical harmonics data - complex packing +# 52 Reserved +53 53 Spectral data for limited area models - complex packing +# 54-60 Reserved +61 61 Grid point data - simple packing with logarithm pre-processing +# 62-199 Reserved +200 200 Run length packing with level values +# 201-49151 Reserved +# 49152-65534 Reserved for local use +65535 65535 Missing diff --git a/definitions/grib2/tables/33/5.1.table b/definitions/grib2/tables/33/5.1.table new file mode 100644 index 000000000..1189b5e46 --- /dev/null +++ b/definitions/grib2/tables/33/5.1.table @@ -0,0 +1,6 @@ +# Code table 5.1 - Type of original field values +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/5.2.table b/definitions/grib2/tables/33/5.2.table new file mode 100644 index 000000000..60d557a0d --- /dev/null +++ b/definitions/grib2/tables/33/5.2.table @@ -0,0 +1,8 @@ +# Code table 5.2 - Matrix coordinate value function definition +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/5.25.table b/definitions/grib2/tables/33/5.25.table new file mode 100644 index 000000000..79e9fd69a --- /dev/null +++ b/definitions/grib2/tables/33/5.25.table @@ -0,0 +1,9 @@ +# Code table 5.25 - type of bi-Fourier subtruncation +# 0-76 Reserved +77 77 Rectangular +# 78-87 Reserved +88 88 Elliptic +# 89-98 Reserved +99 99 Diamond +# 100-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/5.26.table b/definitions/grib2/tables/33/5.26.table new file mode 100644 index 000000000..298f3fcd0 --- /dev/null +++ b/definitions/grib2/tables/33/5.26.table @@ -0,0 +1,5 @@ +# Code table 5.26 - packing mode for axes +0 0 Spectral coefficients for axes are packed +1 1 Spectral coefficients for axes included in the unpacked subset +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/5.3.table b/definitions/grib2/tables/33/5.3.table new file mode 100644 index 000000000..481331791 --- /dev/null +++ b/definitions/grib2/tables/33/5.3.table @@ -0,0 +1,7 @@ +# Code table 5.3 - Matrix coordinate parameter +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/5.4.table b/definitions/grib2/tables/33/5.4.table new file mode 100644 index 000000000..e84ab1901 --- /dev/null +++ b/definitions/grib2/tables/33/5.4.table @@ -0,0 +1,6 @@ +# Code table 5.4 - Group splitting method +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/5.40.table b/definitions/grib2/tables/33/5.40.table new file mode 100644 index 000000000..97e8880ab --- /dev/null +++ b/definitions/grib2/tables/33/5.40.table @@ -0,0 +1,5 @@ +# Code table 5.40 - Type of compression +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/5.5.table b/definitions/grib2/tables/33/5.5.table new file mode 100644 index 000000000..f2316975a --- /dev/null +++ b/definitions/grib2/tables/33/5.5.table @@ -0,0 +1,7 @@ +# Code table 5.5 - Missing value management for complex packing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/5.6.table b/definitions/grib2/tables/33/5.6.table new file mode 100644 index 000000000..db68ead9c --- /dev/null +++ b/definitions/grib2/tables/33/5.6.table @@ -0,0 +1,7 @@ +# Code table 5.6 - Order of spatial differencing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/33/5.7.table b/definitions/grib2/tables/33/5.7.table new file mode 100644 index 000000000..e54862c19 --- /dev/null +++ b/definitions/grib2/tables/33/5.7.table @@ -0,0 +1,7 @@ +# Code table 5.7 - Precision of floating-point numbers +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/33/6.0.table b/definitions/grib2/tables/33/6.0.table new file mode 100644 index 000000000..a8f30f5a4 --- /dev/null +++ b/definitions/grib2/tables/33/6.0.table @@ -0,0 +1,6 @@ +# Code table 6.0 - Bit map indicator +0 0 A bit map applies to this product and is specified in this Section +1 1 A bit map pre-determined by the originating/generating centre applies to this product and is not specified in this Section +# 1-253 A bit map predetermined by the originating/generating centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/6/1.1.table b/definitions/grib2/tables/6/1.1.table index 6c5a60361..6ccac21de 100644 --- a/definitions/grib2/tables/6/1.1.table +++ b/definitions/grib2/tables/6/1.1.table @@ -1,5 +1,5 @@ # Code Table 1.1 GRIB Local Tables Version Number -0 0 Local tables not used +0 0 Local tables not used # . Only table entries and templates from the current Master table are valid. # 1-254 Number of local tables version used 255 255 Missing diff --git a/definitions/grib2/tables/6/4.5.table b/definitions/grib2/tables/6/4.5.table index 9be96e9da..5b80a90fc 100644 --- a/definitions/grib2/tables/6/4.5.table +++ b/definitions/grib2/tables/6/4.5.table @@ -1,13 +1,13 @@ #Code table 4.5: Fixed surface types and units 0 0 Reserved -1 sfc Ground or water surface -2 2 Cloud base level -3 3 Level of cloud tops -4 4 Level of 0 degree C isotherm +1 sfc Ground or water surface +2 2 Cloud base level +3 3 Level of cloud tops +4 4 Level of 0 degree C isotherm 5 5 Level of adiabatic condensation lifted from the surface -6 6 Maximum wind level -7 sfc Tropopause -8 sfc Nominal top of the atmosphere +6 6 Maximum wind level +7 sfc Tropopause +8 sfc Nominal top of the atmosphere 9 9 Sea bottom 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) diff --git a/definitions/grib2/tables/7/1.1.table b/definitions/grib2/tables/7/1.1.table index 6c5a60361..6ccac21de 100644 --- a/definitions/grib2/tables/7/1.1.table +++ b/definitions/grib2/tables/7/1.1.table @@ -1,5 +1,5 @@ # Code Table 1.1 GRIB Local Tables Version Number -0 0 Local tables not used +0 0 Local tables not used # . Only table entries and templates from the current Master table are valid. # 1-254 Number of local tables version used 255 255 Missing diff --git a/definitions/grib2/tables/7/3.10.table b/definitions/grib2/tables/7/3.10.table index e4a446b9a..04686d32e 100644 --- a/definitions/grib2/tables/7/3.10.table +++ b/definitions/grib2/tables/7/3.10.table @@ -5,4 +5,4 @@ 2 1 Points scan in -j direction, i.e. from east to west 3 0 Adjacent points in i direction are consecutive 3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +# 4-8 Reserved diff --git a/definitions/grib2/tables/7/3.4.table b/definitions/grib2/tables/7/3.4.table index 72e3343b7..d3cad225c 100644 --- a/definitions/grib2/tables/7/3.4.table +++ b/definitions/grib2/tables/7/3.4.table @@ -7,4 +7,4 @@ 3 1 Adjacent points in j (y) direction is consecutive 4 0 All rows scan in the same direction 4 1 Adjacent rows scans in the opposite direction -# 5-8 Reserved +# 5-8 Reserved diff --git a/definitions/grib2/tables/7/3.9.table b/definitions/grib2/tables/7/3.9.table index 5edac03a5..cc2e6104b 100644 --- a/definitions/grib2/tables/7/3.9.table +++ b/definitions/grib2/tables/7/3.9.table @@ -1,4 +1,4 @@ # FLAG TABLE 3.9, Numbering order of diamonds as seen from the corresponding pole 1 0 Clockwise orientation 1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +# 2-8 Reserved diff --git a/definitions/grib2/tables/7/4.5.table b/definitions/grib2/tables/7/4.5.table index 9be96e9da..5b80a90fc 100644 --- a/definitions/grib2/tables/7/4.5.table +++ b/definitions/grib2/tables/7/4.5.table @@ -1,13 +1,13 @@ #Code table 4.5: Fixed surface types and units 0 0 Reserved -1 sfc Ground or water surface -2 2 Cloud base level -3 3 Level of cloud tops -4 4 Level of 0 degree C isotherm +1 sfc Ground or water surface +2 2 Cloud base level +3 3 Level of cloud tops +4 4 Level of 0 degree C isotherm 5 5 Level of adiabatic condensation lifted from the surface -6 6 Maximum wind level -7 sfc Tropopause -8 sfc Nominal top of the atmosphere +6 6 Maximum wind level +7 sfc Tropopause +8 sfc Nominal top of the atmosphere 9 9 Sea bottom 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) diff --git a/definitions/grib2/tables/8/0.0.table b/definitions/grib2/tables/8/0.0.table index 1d3a90b49..88d8b2cb3 100644 --- a/definitions/grib2/tables/8/0.0.table +++ b/definitions/grib2/tables/8/0.0.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/1.0.table b/definitions/grib2/tables/8/1.0.table index dc3fcebf0..9f43a852b 100644 --- a/definitions/grib2/tables/8/1.0.table +++ b/definitions/grib2/tables/8/1.0.table @@ -1,13 +1,13 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 -6 6 Version implemented on 15 September 2010 -7 7 Version implemented on 4 May 2011 -8 8 Version implemented on 2 November 2011 -9 9 Pre-operational to be implemented by next amendment -# 10-254 Future versions +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 +6 6 Version implemented on 15 September 2010 +7 7 Version implemented on 4 May 2011 +8 8 Version implemented on 2 November 2011 +9 9 Pre-operational to be implemented by next amendment +# 10-254 Future versions 255 255 Master tables not used. Local table entries and local templates may use the entire range of the table, not just those sections marked Reserved for local used. diff --git a/definitions/grib2/tables/8/1.1.table b/definitions/grib2/tables/8/1.1.table index 91ef66244..55fa1eb63 100644 --- a/definitions/grib2/tables/8/1.1.table +++ b/definitions/grib2/tables/8/1.1.table @@ -1,4 +1,4 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/8/1.2.table b/definitions/grib2/tables/8/1.2.table index d90ad0109..606bf8300 100644 --- a/definitions/grib2/tables/8/1.2.table +++ b/definitions/grib2/tables/8/1.2.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/1.3.table b/definitions/grib2/tables/8/1.3.table index 35cd6a636..712bb2ba8 100644 --- a/definitions/grib2/tables/8/1.3.table +++ b/definitions/grib2/tables/8/1.3.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products -4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) -5 5 THORPEX Interactive Grand Global Ensemble (TIGGE) test -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products +4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) +5 5 THORPEX Interactive Grand Global Ensemble (TIGGE) test +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/1.4.table b/definitions/grib2/tables/8/1.4.table index d11a335a7..7f47afd96 100644 --- a/definitions/grib2/tables/8/1.4.table +++ b/definitions/grib2/tables/8/1.4.table @@ -1,13 +1,13 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/8/3.0.table b/definitions/grib2/tables/8/3.0.table index 4baed0aab..4269b25ad 100644 --- a/definitions/grib2/tables/8/3.0.table +++ b/definitions/grib2/tables/8/3.0.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/8/3.10.table b/definitions/grib2/tables/8/3.10.table index 23c1cdd36..da36dc664 100644 --- a/definitions/grib2/tables/8/3.10.table +++ b/definitions/grib2/tables/8/3.10.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/8/3.11.table b/definitions/grib2/tables/8/3.11.table index 560318d1b..0a299af98 100644 --- a/definitions/grib2/tables/8/3.11.table +++ b/definitions/grib2/tables/8/3.11.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 There is no appended list +0 0 There is no appended list 1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows 2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row 3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) diff --git a/definitions/grib2/tables/8/3.15.table b/definitions/grib2/tables/8/3.15.table index 55ca1688a..976862747 100644 --- a/definitions/grib2/tables/8/3.15.table +++ b/definitions/grib2/tables/8/3.15.table @@ -1,22 +1,22 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) -# 113-159 Reserved +# 113-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/3.2.table b/definitions/grib2/tables/8/3.2.table index 3d7a4f1fc..563efbdb5 100644 --- a/definitions/grib2/tables/8/3.2.table +++ b/definitions/grib2/tables/8/3.2.table @@ -1,13 +1,13 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -# 9-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +# 9-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/3.20.table b/definitions/grib2/tables/8/3.20.table index 3f7ab4cc4..63de6b1a9 100644 --- a/definitions/grib2/tables/8/3.20.table +++ b/definitions/grib2/tables/8/3.20.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/3.21.table b/definitions/grib2/tables/8/3.21.table index b0c77d135..2bc46aae9 100644 --- a/definitions/grib2/tables/8/3.21.table +++ b/definitions/grib2/tables/8/3.21.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/3.3.table b/definitions/grib2/tables/8/3.3.table index 5167ed6b7..bd47e2509 100644 --- a/definitions/grib2/tables/8/3.3.table +++ b/definitions/grib2/tables/8/3.3.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/8/3.4.table b/definitions/grib2/tables/8/3.4.table index 6253896b1..752c70757 100644 --- a/definitions/grib2/tables/8/3.4.table +++ b/definitions/grib2/tables/8/3.4.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -# 5-8 Reserved +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +# 5-8 Reserved diff --git a/definitions/grib2/tables/8/3.5.table b/definitions/grib2/tables/8/3.5.table index 8ccf0f13b..6d3ec036e 100644 --- a/definitions/grib2/tables/8/3.5.table +++ b/definitions/grib2/tables/8/3.5.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/8/3.7.table b/definitions/grib2/tables/8/3.7.table index 41bba8329..4b2e684d3 100644 --- a/definitions/grib2/tables/8/3.7.table +++ b/definitions/grib2/tables/8/3.7.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Reserved 1 1 The complex numbers Fnm (see code figure 1 in Code Table 3.6 above) are stored for m>=0 as pairs of real numbers Re(Fnm), Im(Fnm) ordered with n increasing from m to N(m), first for m=0 and then for m=1, 2, ... M. (see Note 1) -# 2-254 Reserved +# 2-254 Reserved 255 255 Missing diff --git a/definitions/grib2/tables/8/3.8.table b/definitions/grib2/tables/8/3.8.table index 4e811917b..6df554ae9 100644 --- a/definitions/grib2/tables/8/3.8.table +++ b/definitions/grib2/tables/8/3.8.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/3.9.table b/definitions/grib2/tables/8/3.9.table index f35b7ca53..530d1dee0 100644 --- a/definitions/grib2/tables/8/3.9.table +++ b/definitions/grib2/tables/8/3.9.table @@ -1,4 +1,4 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/8/4.0.table b/definitions/grib2/tables/8/4.0.table index faa4f59df..0852d9f0d 100644 --- a/definitions/grib2/tables/8/4.0.table +++ b/definitions/grib2/tables/8/4.0.table @@ -1,52 +1,52 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time 8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically-processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically-processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data # 33-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents 42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents 43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol 46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol 47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non continuous time interval for aerosol 48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of atmospheric aerosol -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time -# 52-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +# 52-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved +# 1102-32767 Reserved # 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data diff --git a/definitions/grib2/tables/8/4.1.0.table b/definitions/grib2/tables/8/4.1.0.table index 361108860..3413dbad5 100644 --- a/definitions/grib2/tables/8/4.1.0.table +++ b/definitions/grib2/tables/8/4.1.0.table @@ -1,27 +1,27 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.1.1.table b/definitions/grib2/tables/8/4.1.1.table index 29f1dec79..dea5bc49e 100644 --- a/definitions/grib2/tables/8/4.1.1.table +++ b/definitions/grib2/tables/8/4.1.1.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.1.10.table b/definitions/grib2/tables/8/4.1.10.table index 9c8c92b12..e6ce6faf7 100644 --- a/definitions/grib2/tables/8/4.1.10.table +++ b/definitions/grib2/tables/8/4.1.10.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Sub-surface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Sub-surface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.1.2.table b/definitions/grib2/tables/8/4.1.2.table index b90201c63..805836998 100644 --- a/definitions/grib2/tables/8/4.1.2.table +++ b/definitions/grib2/tables/8/4.1.2.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.1.3.table b/definitions/grib2/tables/8/4.1.3.table index 3c947b136..c96617665 100644 --- a/definitions/grib2/tables/8/4.1.3.table +++ b/definitions/grib2/tables/8/4.1.3.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Image format products -1 1 Quantitative products -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.10.table b/definitions/grib2/tables/8/4.10.table index 0e5170876..a13fb00b4 100644 --- a/definitions/grib2/tables/8/4.10.table +++ b/definitions/grib2/tables/8/4.10.table @@ -1,15 +1,15 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -# 11-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +# 11-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/8/4.11.table b/definitions/grib2/tables/8/4.11.table index 1257d1b09..af9ff29ad 100644 --- a/definitions/grib2/tables/8/4.11.table +++ b/definitions/grib2/tables/8/4.11.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.12.table b/definitions/grib2/tables/8/4.12.table index e06a3be5b..6cab67bf5 100644 --- a/definitions/grib2/tables/8/4.12.table +++ b/definitions/grib2/tables/8/4.12.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.13.table b/definitions/grib2/tables/8/4.13.table index 107ace60c..f090fb9ae 100644 --- a/definitions/grib2/tables/8/4.13.table +++ b/definitions/grib2/tables/8/4.13.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No quality control applied -1 1 Quality control applied -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No quality control applied +1 1 Quality control applied +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.14.table b/definitions/grib2/tables/8/4.14.table index 9ed9078a8..bcb04f328 100644 --- a/definitions/grib2/tables/8/4.14.table +++ b/definitions/grib2/tables/8/4.14.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No clutter filter used -1 1 Clutter filter used +0 0 No clutter filter used +1 1 Clutter filter used # 2-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/8/4.15.table b/definitions/grib2/tables/8/4.15.table index 97cdcd2ee..6e1ef5745 100644 --- a/definitions/grib2/tables/8/4.15.table +++ b/definitions/grib2/tables/8/4.15.table @@ -1,11 +1,11 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.0.table b/definitions/grib2/tables/8/4.2.0.0.table index debc0a6f4..8656f8974 100644 --- a/definitions/grib2/tables/8/4.2.0.0.table +++ b/definitions/grib2/tables/8/4.2.0.0.table @@ -20,6 +20,6 @@ 18 18 Snow temperature (top of snow) (K) 19 19 Turbulent transfer coefficient for heat (Numeric) 20 20 Turbulent diffusion coefficient for heat (m2/s) -# 21-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 21-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.1.table b/definitions/grib2/tables/8/4.2.0.1.table index 1922792a6..8ee93e99b 100644 --- a/definitions/grib2/tables/8/4.2.0.1.table +++ b/definitions/grib2/tables/8/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,10 +86,10 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rain water content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) -# 93-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 93-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.13.table b/definitions/grib2/tables/8/4.2.0.13.table index b9979f0d3..90ab7d1b9 100644 --- a/definitions/grib2/tables/8/4.2.0.13.table +++ b/definitions/grib2/tables/8/4.2.0.13.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.14.table b/definitions/grib2/tables/8/4.2.0.14.table index 4a2a4e128..fca42ccc7 100644 --- a/definitions/grib2/tables/8/4.2.0.14.table +++ b/definitions/grib2/tables/8/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.15.table b/definitions/grib2/tables/8/4.2.0.15.table index a7fa034b0..c89ecd203 100644 --- a/definitions/grib2/tables/8/4.2.0.15.table +++ b/definitions/grib2/tables/8/4.2.0.15.table @@ -14,6 +14,6 @@ 12 12 Reflectivity of rain (dB) 13 13 Reflectivity of graupel (dB) 14 14 Reflectivity of hail (dB) -# 15-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 15-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.16.table b/definitions/grib2/tables/8/4.2.0.16.table index 39215ab20..18dedb7c0 100644 --- a/definitions/grib2/tables/8/4.2.0.16.table +++ b/definitions/grib2/tables/8/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.18.table b/definitions/grib2/tables/8/4.2.0.18.table index 30060fd2d..165aa6008 100644 --- a/definitions/grib2/tables/8/4.2.0.18.table +++ b/definitions/grib2/tables/8/4.2.0.18.table @@ -8,11 +8,11 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) 13 13 Total deposition (wet + dry) (Bq m-2) -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.19.table b/definitions/grib2/tables/8/4.2.0.19.table index 1bbbd4243..1a2f91974 100644 --- a/definitions/grib2/tables/8/4.2.0.19.table +++ b/definitions/grib2/tables/8/4.2.0.19.table @@ -26,6 +26,6 @@ 24 24 Convective turbulent kinetic energy (J/kg) 25 25 Weather Interpretation ww (WMO) (-) 26 26 Convective outlook (Code table 4.224) -# 27-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 27-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.190.table b/definitions/grib2/tables/8/4.2.0.190.table index 39fb55746..3d9d5ff85 100644 --- a/definitions/grib2/tables/8/4.2.0.190.table +++ b/definitions/grib2/tables/8/4.2.0.190.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.191.table b/definitions/grib2/tables/8/4.2.0.191.table index 81230c0e0..4ff12e532 100644 --- a/definitions/grib2/tables/8/4.2.0.191.table +++ b/definitions/grib2/tables/8/4.2.0.191.table @@ -2,6 +2,6 @@ 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/8/4.2.0.2.table b/definitions/grib2/tables/8/4.2.0.2.table index 58428f66a..f93074e5e 100644 --- a/definitions/grib2/tables/8/4.2.0.2.table +++ b/definitions/grib2/tables/8/4.2.0.2.table @@ -33,6 +33,6 @@ 31 31 Turbulent diffusion coefficient for momentum (m2/s) 32 32 Eta coordinate vertical velocity (/s) 33 33 Wind fetch (m) -# 34-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 34-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.20.table b/definitions/grib2/tables/8/4.2.0.20.table index d0ef4b3a0..2bee70352 100644 --- a/definitions/grib2/tables/8/4.2.0.20.table +++ b/definitions/grib2/tables/8/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (Sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -25,7 +25,7 @@ 57 57 Total yearly average burden of the atmosphere (mol) 58 58 Total yearly averaged atmospheric loss (mol/s) 59 59 Aerosol number concentration (m-3) -# 60-99 Reserved +# 60-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Atmosphere optical thickness (m) 102 102 Aerosol optical thickness (Numeric) @@ -37,6 +37,6 @@ 108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) 109 109 Aerosol lidar extinction from satellite (m-1) 110 110 Aerosol lidar extinction from the ground (m-1) -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.3.table b/definitions/grib2/tables/8/4.2.0.3.table index b337cbd06..18c33fdf8 100644 --- a/definitions/grib2/tables/8/4.2.0.3.table +++ b/definitions/grib2/tables/8/4.2.0.3.table @@ -25,6 +25,6 @@ 23 23 Gravity wave dissipation (W m-2) 24 24 Anisotropy of sub-gridscale orography (Numeric) 25 25 Natural logarithm of pressure in Pa (Numeric) -# 26-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 26-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.4.table b/definitions/grib2/tables/8/4.2.0.4.table index fea4cafc3..336fdb421 100644 --- a/definitions/grib2/tables/8/4.2.0.4.table +++ b/definitions/grib2/tables/8/4.2.0.4.table @@ -12,9 +12,9 @@ 10 10 Photosynthetically active radiation (W m-2) 11 11 Net short-wave radiation flux, clear sky (W m-2) 12 12 Downward UV radiation (W m-2) -# 13-49 Reserved +# 13-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) -# 52-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.5.table b/definitions/grib2/tables/8/4.2.0.5.table index aae853bf9..607235064 100644 --- a/definitions/grib2/tables/8/4.2.0.5.table +++ b/definitions/grib2/tables/8/4.2.0.5.table @@ -6,6 +6,6 @@ 4 4 Upward long-wave radiation flux (W m-2) 5 5 Net long wave radiation flux (W m-2) 6 6 Net long-wave radiation flux, clear sky (W m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.6.table b/definitions/grib2/tables/8/4.2.0.6.table index 462727d0b..747fd8088 100644 --- a/definitions/grib2/tables/8/4.2.0.6.table +++ b/definitions/grib2/tables/8/4.2.0.6.table @@ -33,6 +33,6 @@ 31 31 Number density of cloud ice (m-3) 32 32 Fraction of cloud cover (Numeric) 33 33 Sunshine duration (s) -# 34-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 34-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.0.7.table b/definitions/grib2/tables/8/4.2.0.7.table index 7a7d2008b..6c1794c73 100644 --- a/definitions/grib2/tables/8/4.2.0.7.table +++ b/definitions/grib2/tables/8/4.2.0.7.table @@ -13,8 +13,8 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraft helicity (m2 s-2) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.1.0.table b/definitions/grib2/tables/8/4.2.1.0.table index bf1e3e93f..9c4d129da 100644 --- a/definitions/grib2/tables/8/4.2.1.0.table +++ b/definitions/grib2/tables/8/4.2.1.0.table @@ -6,6 +6,6 @@ 4 4 Snow water equivalent per cent of normal (%) 5 5 Baseflow-groundwater runoff (kg m-2) 6 6 Storm surface runoff (kg m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.1.1.table b/definitions/grib2/tables/8/4.2.1.1.table index cb5117dc8..aa560e479 100644 --- a/definitions/grib2/tables/8/4.2.1.1.table +++ b/definitions/grib2/tables/8/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.10.0.table b/definitions/grib2/tables/8/4.2.10.0.table index eb9d1fa65..c00ce058f 100644 --- a/definitions/grib2/tables/8/4.2.10.0.table +++ b/definitions/grib2/tables/8/4.2.10.0.table @@ -48,6 +48,6 @@ 46 46 2-dim spectral energy density (m2 s) 47 47 Frequency spectral energy density (m2 s) 48 48 Directional spectral energy density -# 49-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 49-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.10.1.table b/definitions/grib2/tables/8/4.2.10.1.table index 5a33bac5d..a076fb07c 100644 --- a/definitions/grib2/tables/8/4.2.10.1.table +++ b/definitions/grib2/tables/8/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.10.191.table b/definitions/grib2/tables/8/4.2.10.191.table index 14085ac9a..6cafbd3d4 100644 --- a/definitions/grib2/tables/8/4.2.10.191.table +++ b/definitions/grib2/tables/8/4.2.10.191.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.10.2.table b/definitions/grib2/tables/8/4.2.10.2.table index a69b2622c..80fe973be 100644 --- a/definitions/grib2/tables/8/4.2.10.2.table +++ b/definitions/grib2/tables/8/4.2.10.2.table @@ -9,6 +9,6 @@ 7 7 Ice divergence (/s) 8 8 Ice temperature (K) 9 9 Ice internal pressure (Pa m) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.10.3.table b/definitions/grib2/tables/8/4.2.10.3.table index 112af09d5..3b9a2df46 100644 --- a/definitions/grib2/tables/8/4.2.10.3.table +++ b/definitions/grib2/tables/8/4.2.10.3.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.10.4.table b/definitions/grib2/tables/8/4.2.10.4.table index d80a32780..91ffb2b29 100644 --- a/definitions/grib2/tables/8/4.2.10.4.table +++ b/definitions/grib2/tables/8/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2 s-1) 6 6 Ocean vertical momentum diffusivity (m2 s-1) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (m-1) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.2.0.table b/definitions/grib2/tables/8/4.2.2.0.table index b440b9426..083fc5913 100644 --- a/definitions/grib2/tables/8/4.2.2.0.table +++ b/definitions/grib2/tables/8/4.2.2.0.table @@ -32,6 +32,6 @@ 30 30 Deciduous forest (Numeric) 31 31 Normalized differential vegetation index (NDVI) (Numeric) 32 32 Root depth of vegetation (m) -# 33-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 33-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.2.3.table b/definitions/grib2/tables/8/4.2.2.3.table index 80113a4bd..a9ec602e6 100644 --- a/definitions/grib2/tables/8/4.2.2.3.table +++ b/definitions/grib2/tables/8/4.2.2.3.table @@ -22,6 +22,6 @@ 20 20 Column-integrated soil moisture (kg m-2) 21 21 Soil ice (kg m-3) 22 22 Column-integrated soil ice (kg m-2) -# 23-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 23-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.3.0.table b/definitions/grib2/tables/8/4.2.3.0.table index 254e56bc8..8c19d43b2 100644 --- a/definitions/grib2/tables/8/4.2.3.0.table +++ b/definitions/grib2/tables/8/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.2.3.1.table b/definitions/grib2/tables/8/4.2.3.1.table index 16eee69c4..d199aff60 100644 --- a/definitions/grib2/tables/8/4.2.3.1.table +++ b/definitions/grib2/tables/8/4.2.3.1.table @@ -17,12 +17,12 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +23 23 Angstrom coefficient +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.201.table b/definitions/grib2/tables/8/4.201.table index ebb698b38..e16d5d808 100644 --- a/definitions/grib2/tables/8/4.201.table +++ b/definitions/grib2/tables/8/4.201.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.202.table b/definitions/grib2/tables/8/4.202.table index 943c03f6f..aa93458f1 100644 --- a/definitions/grib2/tables/8/4.202.table +++ b/definitions/grib2/tables/8/4.202.table @@ -1,4 +1,4 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -# 0-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 0-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.203.table b/definitions/grib2/tables/8/4.203.table index fce5a15b1..9a8d29e01 100644 --- a/definitions/grib2/tables/8/4.203.table +++ b/definitions/grib2/tables/8/4.203.table @@ -1,25 +1,25 @@ -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.205.table b/definitions/grib2/tables/8/4.205.table index 8d425ab9d..3fadf7d80 100644 --- a/definitions/grib2/tables/8/4.205.table +++ b/definitions/grib2/tables/8/4.205.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.206.table b/definitions/grib2/tables/8/4.206.table index 0be7fd4f8..43b0ba137 100644 --- a/definitions/grib2/tables/8/4.206.table +++ b/definitions/grib2/tables/8/4.206.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.207.table b/definitions/grib2/tables/8/4.207.table index fde9eb477..815a5777e 100644 --- a/definitions/grib2/tables/8/4.207.table +++ b/definitions/grib2/tables/8/4.207.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.208.table b/definitions/grib2/tables/8/4.208.table index 196becaaf..23ea97317 100644 --- a/definitions/grib2/tables/8/4.208.table +++ b/definitions/grib2/tables/8/4.208.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.209.table b/definitions/grib2/tables/8/4.209.table index 351c0f431..53c6c5eba 100644 --- a/definitions/grib2/tables/8/4.209.table +++ b/definitions/grib2/tables/8/4.209.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Stable -2 2 Mechanically-driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically-driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.210.table b/definitions/grib2/tables/8/4.210.table index 1c00b8c6f..149b2ba06 100644 --- a/definitions/grib2/tables/8/4.210.table +++ b/definitions/grib2/tables/8/4.210.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.211.table b/definitions/grib2/tables/8/4.211.table index 66ef656f6..b5753f19f 100644 --- a/definitions/grib2/tables/8/4.211.table +++ b/definitions/grib2/tables/8/4.211.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.212.table b/definitions/grib2/tables/8/4.212.table index c59bd24e8..738c45d2c 100644 --- a/definitions/grib2/tables/8/4.212.table +++ b/definitions/grib2/tables/8/4.212.table @@ -1,18 +1,18 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.213.table b/definitions/grib2/tables/8/4.213.table index 0f5de0104..5cee0b798 100644 --- a/definitions/grib2/tables/8/4.213.table +++ b/definitions/grib2/tables/8/4.213.table @@ -1,21 +1,21 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -12 12 Loam -13 13 Peat -14 14 Rock -15 15 Ice -16 16 Water -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +12 12 Loam +13 13 Peat +14 14 Rock +15 15 Ice +16 16 Water +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.215.table b/definitions/grib2/tables/8/4.215.table index 460888217..5ed37c034 100644 --- a/definitions/grib2/tables/8/4.215.table +++ b/definitions/grib2/tables/8/4.215.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.216.table b/definitions/grib2/tables/8/4.216.table index cc62ca5e3..2fd143724 100644 --- a/definitions/grib2/tables/8/4.216.table +++ b/definitions/grib2/tables/8/4.216.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit # 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/8/4.217.table b/definitions/grib2/tables/8/4.217.table index 51a263a99..6a014c9c3 100644 --- a/definitions/grib2/tables/8/4.217.table +++ b/definitions/grib2/tables/8/4.217.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.218.table b/definitions/grib2/tables/8/4.218.table index d4b2ab843..b6087448f 100644 --- a/definitions/grib2/tables/8/4.218.table +++ b/definitions/grib2/tables/8/4.218.table @@ -1,38 +1,38 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation / crops -15 15 Permanent snow / ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -# 19-96 Reserved -97 97 Snow / ice on land -98 98 Snow / ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud / fog / Stratus -102 102 Low cloud / Stratocumulus -103 103 Low cloud / unknown type -104 104 Medium cloud / Nimbostratus -105 105 Medium cloud / Altostratus -106 106 Medium cloud / unknown type -107 107 High cloud / Cumulus -108 108 High cloud / Cirrus -109 109 High cloud / unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation / crops +15 15 Permanent snow / ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +# 19-96 Reserved +97 97 Snow / ice on land +98 98 Snow / ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud / fog / Stratus +102 102 Low cloud / Stratocumulus +103 103 Low cloud / unknown type +104 104 Medium cloud / Nimbostratus +105 105 Medium cloud / Altostratus +106 106 Medium cloud / unknown type +107 107 High cloud / Cumulus +108 108 High cloud / Cirrus +109 109 High cloud / unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.219.table b/definitions/grib2/tables/8/4.219.table index f10ce468e..a02452fc4 100644 --- a/definitions/grib2/tables/8/4.219.table +++ b/definitions/grib2/tables/8/4.219.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.220.table b/definitions/grib2/tables/8/4.220.table index 9c957eb01..7a18fa1fd 100644 --- a/definitions/grib2/tables/8/4.220.table +++ b/definitions/grib2/tables/8/4.220.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.221.table b/definitions/grib2/tables/8/4.221.table index 5466929c7..eb0b64502 100644 --- a/definitions/grib2/tables/8/4.221.table +++ b/definitions/grib2/tables/8/4.221.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.222.table b/definitions/grib2/tables/8/4.222.table index c54194e29..f554a7f3d 100644 --- a/definitions/grib2/tables/8/4.222.table +++ b/definitions/grib2/tables/8/4.222.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.223.table b/definitions/grib2/tables/8/4.223.table index b6a9be136..706abab78 100644 --- a/definitions/grib2/tables/8/4.223.table +++ b/definitions/grib2/tables/8/4.223.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing value +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing value diff --git a/definitions/grib2/tables/8/4.224.table b/definitions/grib2/tables/8/4.224.table index af846f841..cf67496b8 100644 --- a/definitions/grib2/tables/8/4.224.table +++ b/definitions/grib2/tables/8/4.224.table @@ -1,18 +1,18 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/8/4.3.table b/definitions/grib2/tables/8/4.3.table index 68e2cc83f..8a4e919c9 100644 --- a/definitions/grib2/tables/8/4.3.table +++ b/definitions/grib2/tables/8/4.3.table @@ -1,16 +1,16 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.4.table b/definitions/grib2/tables/8/4.4.table index df5272d2f..511c76aa9 100644 --- a/definitions/grib2/tables/8/4.4.table +++ b/definitions/grib2/tables/8/4.4.table @@ -1,17 +1,17 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.5.table b/definitions/grib2/tables/8/4.5.table index 4f36494e9..dfba82870 100644 --- a/definitions/grib2/tables/8/4.5.table +++ b/definitions/grib2/tables/8/4.5.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface 2 2 Cloud base level 3 3 Level of cloud tops @@ -12,11 +12,11 @@ 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,7 +25,7 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level 112 112 Reserved 113 113 Logarithmic hybrid coordinate @@ -35,14 +35,14 @@ 119 hpl Hybrid pressure level # 120-149 Reserved 150 150 Generalized vertical height coordinate -# 151-159 Reserved -160 160 Depth below sea level m +# 151-159 Reserved +160 160 Depth below sea level m 161 161 Depth below water surface (m) 162 sfc Lake or river bottom 163 163 Bottom of sediment layer 164 164 Bottom of thermally active sediment layer 165 165 Bottom of sediment layer penetrated by thermal wave 166 sfc Mixing layer -# 167-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 167-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.6.table b/definitions/grib2/tables/8/4.6.table index 54f2993c3..eaa5c4362 100644 --- a/definitions/grib2/tables/8/4.6.table +++ b/definitions/grib2/tables/8/4.6.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.7.table b/definitions/grib2/tables/8/4.7.table index 23e0d457e..e6d887bdb 100644 --- a/definitions/grib2/tables/8/4.7.table +++ b/definitions/grib2/tables/8/4.7.table @@ -1,14 +1,14 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.8.table b/definitions/grib2/tables/8/4.8.table index 37a6cf767..d06153079 100644 --- a/definitions/grib2/tables/8/4.8.table +++ b/definitions/grib2/tables/8/4.8.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.9.table b/definitions/grib2/tables/8/4.9.table index 19e64a3d2..5243e58dd 100644 --- a/definitions/grib2/tables/8/4.9.table +++ b/definitions/grib2/tables/8/4.9.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/4.91.table b/definitions/grib2/tables/8/4.91.table index 05c4579bd..cea421695 100644 --- a/definitions/grib2/tables/8/4.91.table +++ b/definitions/grib2/tables/8/4.91.table @@ -1,16 +1,16 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit -11 11 Equal to first limit. -# 12-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit. +# 12-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/8/5.1.table b/definitions/grib2/tables/8/5.1.table index 100d4106d..158a35850 100644 --- a/definitions/grib2/tables/8/5.1.table +++ b/definitions/grib2/tables/8/5.1.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/5.2.table b/definitions/grib2/tables/8/5.2.table index 4d0808be6..d9896e11f 100644 --- a/definitions/grib2/tables/8/5.2.table +++ b/definitions/grib2/tables/8/5.2.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use +# 12-191 Reserved +# 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/8/5.3.table b/definitions/grib2/tables/8/5.3.table index 705fa6524..6f228aeec 100644 --- a/definitions/grib2/tables/8/5.3.table +++ b/definitions/grib2/tables/8/5.3.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/5.4.table b/definitions/grib2/tables/8/5.4.table index 8133367a5..f844f557e 100644 --- a/definitions/grib2/tables/8/5.4.table +++ b/definitions/grib2/tables/8/5.4.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/5.40.table b/definitions/grib2/tables/8/5.40.table index 0d56ad0e0..2431eb547 100644 --- a/definitions/grib2/tables/8/5.40.table +++ b/definitions/grib2/tables/8/5.40.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/8/5.5.table b/definitions/grib2/tables/8/5.5.table index 5d625dbda..f2216e273 100644 --- a/definitions/grib2/tables/8/5.5.table +++ b/definitions/grib2/tables/8/5.5.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/5.6.table b/definitions/grib2/tables/8/5.6.table index 5838e994d..3b0892d37 100644 --- a/definitions/grib2/tables/8/5.6.table +++ b/definitions/grib2/tables/8/5.6.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/8/5.7.table b/definitions/grib2/tables/8/5.7.table index b93aa8130..f056d3059 100644 --- a/definitions/grib2/tables/8/5.7.table +++ b/definitions/grib2/tables/8/5.7.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/8/6.0.table b/definitions/grib2/tables/8/6.0.table index aecdc6e5e..9c9dba372 100644 --- a/definitions/grib2/tables/8/6.0.table +++ b/definitions/grib2/tables/8/6.0.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating Centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating Centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating Centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/9/0.0.table b/definitions/grib2/tables/9/0.0.table index 1d3a90b49..88d8b2cb3 100644 --- a/definitions/grib2/tables/9/0.0.table +++ b/definitions/grib2/tables/9/0.0.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Meteorological products -1 1 Hydrological products -2 2 Land surface products -3 3 Space products -# 4-9 Reserved -10 10 Oceanographic products -# 11-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Meteorological products +1 1 Hydrological products +2 2 Land surface products +3 3 Space products +# 4-9 Reserved +10 10 Oceanographic products +# 11-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/1.0.table b/definitions/grib2/tables/9/1.0.table index 045af30c3..4b1406c7e 100644 --- a/definitions/grib2/tables/9/1.0.table +++ b/definitions/grib2/tables/9/1.0.table @@ -1,14 +1,14 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Experimental -1 1 Version implemented on 7 November 2001 -2 2 Version implemented on 4 November 2003 -3 3 Version implemented on 2 November 2005 -4 4 Version implemented on 7 November 2007 -5 5 Version implemented on 4 November 2009 +0 0 Experimental +1 1 Version implemented on 7 November 2001 +2 2 Version implemented on 4 November 2003 +3 3 Version implemented on 2 November 2005 +4 4 Version implemented on 7 November 2007 +5 5 Version implemented on 4 November 2009 6 6 Version implemented on 15 September 2010 7 7 Version implemented on 4 May 2011 8 8 Version implemented on 2 November 2011 9 9 Version implemented on 2 May 2012 10 10 Pre-operational to be implemented by next amendment -# 11-254 Future versions +# 11-254 Future versions 255 255 Master tables not used. Local table entries and local templates may use the entire range of the table, not just those sections marked Reserved for local used. diff --git a/definitions/grib2/tables/9/1.1.table b/definitions/grib2/tables/9/1.1.table index 91ef66244..55fa1eb63 100644 --- a/definitions/grib2/tables/9/1.1.table +++ b/definitions/grib2/tables/9/1.1.table @@ -1,4 +1,4 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Local tables not used. Only table entries and templates from the current master table are valid -# 1-254 Number of local tables version used -255 255 Missing +0 0 Local tables not used. Only table entries and templates from the current master table are valid +# 1-254 Number of local tables version used +255 255 Missing diff --git a/definitions/grib2/tables/9/1.2.table b/definitions/grib2/tables/9/1.2.table index d90ad0109..606bf8300 100644 --- a/definitions/grib2/tables/9/1.2.table +++ b/definitions/grib2/tables/9/1.2.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Analysis -1 1 Start of forecast -2 2 Verifying time of forecast -3 3 Observation time -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Start of forecast +2 2 Verifying time of forecast +3 3 Observation time +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/1.3.table b/definitions/grib2/tables/9/1.3.table index 35cd6a636..712bb2ba8 100644 --- a/definitions/grib2/tables/9/1.3.table +++ b/definitions/grib2/tables/9/1.3.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Operational products -1 1 Operational test products -2 2 Research products -3 3 Re-analysis products -4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) -5 5 THORPEX Interactive Grand Global Ensemble (TIGGE) test -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Operational products +1 1 Operational test products +2 2 Research products +3 3 Re-analysis products +4 4 THORPEX Interactive Grand Global Ensemble (TIGGE) +5 5 THORPEX Interactive Grand Global Ensemble (TIGGE) test +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/1.4.table b/definitions/grib2/tables/9/1.4.table index d11a335a7..7f47afd96 100644 --- a/definitions/grib2/tables/9/1.4.table +++ b/definitions/grib2/tables/9/1.4.table @@ -1,13 +1,13 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 an Analysis products -1 fc Forecast products -2 af Analysis and forecast products -3 cf Control forecast products -4 pf Perturbed forecast products -5 cp Control and perturbed forecast products -6 sa Processed satellite observations -7 ra Processed radar observations -8 ep Event probability -# 9-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 an Analysis products +1 fc Forecast products +2 af Analysis and forecast products +3 cf Control forecast products +4 pf Perturbed forecast products +5 cp Control and perturbed forecast products +6 sa Processed satellite observations +7 ra Processed radar observations +8 ep Event probability +# 9-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/9/3.0.table b/definitions/grib2/tables/9/3.0.table index 4baed0aab..4269b25ad 100644 --- a/definitions/grib2/tables/9/3.0.table +++ b/definitions/grib2/tables/9/3.0.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Specified in Code table 3.1 +0 0 Specified in Code table 3.1 1 1 Predetermined grid definition (Defined by originating centre) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 A grid definition does not apply to this product +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 A grid definition does not apply to this product diff --git a/definitions/grib2/tables/9/3.10.table b/definitions/grib2/tables/9/3.10.table index 23c1cdd36..da36dc664 100644 --- a/definitions/grib2/tables/9/3.10.table +++ b/definitions/grib2/tables/9/3.10.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 0 Points scan in +i direction, i.e. from pole to Equator -1 1 Points scan in -i direction, i.e. from Equator to pole -2 0 Points scan in +j direction, i.e. from west to east -2 1 Points scan in -j direction, i.e. from east to west -3 0 Adjacent points in i direction are consecutive -3 1 Adjacent points in j direction are consecutive -# 4-8 Reserved +1 0 Points scan in +i direction, i.e. from pole to Equator +1 1 Points scan in -i direction, i.e. from Equator to pole +2 0 Points scan in +j direction, i.e. from west to east +2 1 Points scan in -j direction, i.e. from east to west +3 0 Adjacent points in i direction are consecutive +3 1 Adjacent points in j direction are consecutive +# 4-8 Reserved diff --git a/definitions/grib2/tables/9/3.11.table b/definitions/grib2/tables/9/3.11.table index 560318d1b..0a299af98 100644 --- a/definitions/grib2/tables/9/3.11.table +++ b/definitions/grib2/tables/9/3.11.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 There is no appended list +0 0 There is no appended list 1 1 Numbers define number of points corresponding to full coordinate circles (i.e. parallels), coordinate values on each circle are multiple of the circle mesh, and extreme coordinate values given in grid definition (i.e. extreme longitudes) may not be reached in all rows 2 2 Numbers define number of points corresponding to coordinate lines delimited by extreme coordinate values given in grid definition (i.e. extreme longitudes) which are present in each row 3 3 Numbers define the actual latitudes for each row in the grid. The list of numbers are integer values of the valid latitudes in microdegrees (scaled by 10-6) or in unit equal to the ratio of the basic angle and the subdivisions number for each row, in the same order as specified in the scanning mode flag (bit no. 2) diff --git a/definitions/grib2/tables/9/3.15.table b/definitions/grib2/tables/9/3.15.table index 94f6c8e04..44e7a0983 100644 --- a/definitions/grib2/tables/9/3.15.table +++ b/definitions/grib2/tables/9/3.15.table @@ -1,23 +1,23 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -# 0-19 Reserved +# 0-19 Reserved 20 20 Temperature (K) -# 21-99 Reserved +# 21-99 Reserved 100 100 Pressure (Pa) 101 101 Pressure deviation from mean sea level (Pa) 102 102 Altitude above mean sea level (m) 103 103 Height above ground (m) -104 104 Sigma coordinate -105 105 Hybrid coordinate +104 104 Sigma coordinate +105 105 Hybrid coordinate 106 106 Depth below land surface (m) 107 pt Potential temperature (theta) (K) 108 108 Pressure deviation from ground to level (Pa) 109 pv Potential vorticity (K m-2 kg-1 s-1) 110 110 Geometrical height (m) -111 111 Eta coordinate +111 111 Eta coordinate 112 112 Geopotential height (gpm) 113 113 Logarithmic hybrid coordinate -# 114-159 Reserved +# 114-159 Reserved 160 160 Depth below sea level (m) -# 161-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 161-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/3.2.table b/definitions/grib2/tables/9/3.2.table index 3d7a4f1fc..563efbdb5 100644 --- a/definitions/grib2/tables/9/3.2.table +++ b/definitions/grib2/tables/9/3.2.table @@ -1,13 +1,13 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Earth assumed spherical with radius = 6 367 470.0 m -1 1 Earth assumed spherical with radius specified (in m) by data producer -2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) -3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer -4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) -5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) -6 6 Earth assumed spherical with radius of 6 371 229.0 m -7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer -8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame -# 9-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Earth assumed spherical with radius = 6 367 470.0 m +1 1 Earth assumed spherical with radius specified (in m) by data producer +2 2 Earth assumed oblate spheroid with size as determined by IAU in 1965 (major axis = 6 378 160.0 m, minor axis = 6 356 775.0 m, f = 1/297.0) +3 3 Earth assumed oblate spheroid with major and minor axes specified (in km) by data producer +4 4 Earth assumed oblate spheroid as defined in IAG-GRS80 model (major axis = 6 378 137.0 m, minor axis = 6 356 752.314 m, f = 1/298.257 222 101) +5 5 Earth assumed represented by WGS84 (as used by ICAO since 1998) +6 6 Earth assumed spherical with radius of 6 371 229.0 m +7 7 Earth assumed oblate spheroid with major or minor axes specified (in m) by data producer +8 8 Earth model assumed spherical with radius of 6 371 200 m, but the horizontal datum of the resulting latitude/longitude field is the WGS84 reference frame +# 9-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/3.20.table b/definitions/grib2/tables/9/3.20.table index 3f7ab4cc4..63de6b1a9 100644 --- a/definitions/grib2/tables/9/3.20.table +++ b/definitions/grib2/tables/9/3.20.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Rhumb -1 1 Great circle -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Rhumb +1 1 Great circle +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/3.21.table b/definitions/grib2/tables/9/3.21.table index b0c77d135..2bc46aae9 100644 --- a/definitions/grib2/tables/9/3.21.table +++ b/definitions/grib2/tables/9/3.21.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 -# 2-10 Reserved -11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1) = C1, f(n) = f(n-1) + C2 +# 2-10 Reserved +11 11 Geometric coordinates f(1) = C1, f(n) = C2 * f(n-1) +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/3.3.table b/definitions/grib2/tables/9/3.3.table index 5167ed6b7..bd47e2509 100644 --- a/definitions/grib2/tables/9/3.3.table +++ b/definitions/grib2/tables/9/3.3.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -# 1-2 Reserved -3 0 i direction increments not given -3 1 i direction increments given -4 0 j direction increments not given -4 1 j direction increments given -5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions -5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively -# 6-8 Reserved - set to zero +# 1-2 Reserved +3 0 i direction increments not given +3 1 i direction increments given +4 0 j direction increments not given +4 1 j direction increments given +5 0 Resolved u- and v- components of vector quantities relative to easterly and northerly directions +5 1 Resolved u- and v- components of vector quantities relative to the defined grid in the direction of increasing x and y (or i and j) coordinates, respectively +# 6-8 Reserved - set to zero diff --git a/definitions/grib2/tables/9/3.4.table b/definitions/grib2/tables/9/3.4.table index 6253896b1..752c70757 100644 --- a/definitions/grib2/tables/9/3.4.table +++ b/definitions/grib2/tables/9/3.4.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 0 Points of first row or column scan in the +i (+x) direction -1 1 Points of first row or column scan in the -i (-x) direction -2 0 Points of first row or column scan in the -j (-y) direction -2 1 Points of first row or column scan in the +j (+y) direction -3 0 Adjacent points in i (x) direction are consecutive -3 1 Adjacent points in j (y) direction is consecutive -4 0 All rows scan in the same direction -4 1 Adjacent rows scans in the opposite direction -# 5-8 Reserved +1 0 Points of first row or column scan in the +i (+x) direction +1 1 Points of first row or column scan in the -i (-x) direction +2 0 Points of first row or column scan in the -j (-y) direction +2 1 Points of first row or column scan in the +j (+y) direction +3 0 Adjacent points in i (x) direction are consecutive +3 1 Adjacent points in j (y) direction is consecutive +4 0 All rows scan in the same direction +4 1 Adjacent rows scans in the opposite direction +# 5-8 Reserved diff --git a/definitions/grib2/tables/9/3.5.table b/definitions/grib2/tables/9/3.5.table index 8ccf0f13b..6d3ec036e 100644 --- a/definitions/grib2/tables/9/3.5.table +++ b/definitions/grib2/tables/9/3.5.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 0 North Pole is on the projection plane -1 1 South Pole is on the projection plane -2 0 Only one projection centre is used -2 1 Projection is bipolar and symmetric +1 0 North Pole is on the projection plane +1 1 South Pole is on the projection plane +2 0 Only one projection centre is used +2 1 Projection is bipolar and symmetric diff --git a/definitions/grib2/tables/9/3.7.table b/definitions/grib2/tables/9/3.7.table index 65693989a..4b2e684d3 100644 --- a/definitions/grib2/tables/9/3.7.table +++ b/definitions/grib2/tables/9/3.7.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved +0 0 Reserved 1 1 The complex numbers Fnm (see code figure 1 in Code Table 3.6 above) are stored for m>=0 as pairs of real numbers Re(Fnm), Im(Fnm) ordered with n increasing from m to N(m), first for m=0 and then for m=1, 2, ... M. (see Note 1) -# 2-254 Reserved +# 2-254 Reserved 255 255 Missing diff --git a/definitions/grib2/tables/9/3.8.table b/definitions/grib2/tables/9/3.8.table index 4e811917b..6df554ae9 100644 --- a/definitions/grib2/tables/9/3.8.table +++ b/definitions/grib2/tables/9/3.8.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Grid points at triangle vertices -1 1 Grid points at centres of triangles -2 2 Grid points at midpoints of triangle sides -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Grid points at triangle vertices +1 1 Grid points at centres of triangles +2 2 Grid points at midpoints of triangle sides +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/3.9.table b/definitions/grib2/tables/9/3.9.table index f35b7ca53..530d1dee0 100644 --- a/definitions/grib2/tables/9/3.9.table +++ b/definitions/grib2/tables/9/3.9.table @@ -1,4 +1,4 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 0 Clockwise orientation -1 1 Anti-clockwise (i.e. counter-clockwise) orientation -# 2-8 Reserved +1 0 Clockwise orientation +1 1 Anti-clockwise (i.e. counter-clockwise) orientation +# 2-8 Reserved diff --git a/definitions/grib2/tables/9/4.0.table b/definitions/grib2/tables/9/4.0.table index faa4f59df..0852d9f0d 100644 --- a/definitions/grib2/tables/9/4.0.table +++ b/definitions/grib2/tables/9/4.0.table @@ -1,52 +1,52 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time -1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time -2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time -3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time -4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time -5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time -6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time -7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time +0 0 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time +1 1 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time +2 2 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer at a point in time +3 3 Derived forecasts based on a cluster of ensemble members over a rectangular area at a horizontal level or in a horizontal layer at a point in time +4 4 Derived forecasts based on a cluster of ensemble members over a circular area at a horizontal level or in a horizontal layer at a point in time +5 5 Probability forecasts at a horizontal level or in a horizontal layer at a point in time +6 6 Percentile forecasts at a horizontal level or in a horizontal layer at a point in time +7 7 Analysis or forecast error at a horizontal level or in a horizontal layer at a point in time 8 8 Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval -15 15 Average, accumulation, extreme values, or other statistically-processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time -# 16-19 Reserved -20 20 Radar product -# 21-29 Reserved -30 30 Satellite product (deprecated) -31 31 Satellite product -32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data +9 9 Probability forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +10 10 Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +11 11 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +12 12 Derived forecasts based on all ensemble members at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +13 13 Derived forecasts based on a cluster of ensemble members over a rectangular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +14 14 Derived forecasts based on a cluster of ensemble members over a circular area, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval +15 15 Average, accumulation, extreme values, or other statistically-processed values over a spatial area at a horizontal level or in a horizontal layer at a point in time +# 16-19 Reserved +20 20 Radar product +# 21-29 Reserved +30 30 Satellite product (deprecated) +31 31 Satellite product +32 32 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data # 33-39 Reserved 311 311 Satellite product auxiliary information -40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents -41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +40 40 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents +41 41 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for atmospheric chemical constituents 42 42 Average, accumulation and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for atmospheric chemical constituents 43 43 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous time interval for atmospheric chemical constituents -44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol -45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol +44 44 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol +45 45 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for aerosol 46 46 Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for aerosol 47 47 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non continuous time interval for aerosol 48 48 Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for optical properties of atmospheric aerosol -51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time -# 52-90 Reserved -91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval -# 92-253 Reserved -254 254 CCITT IA5 character string -# 255-999 Reserved -1000 1000 Cross-section of analysis and forecast at a point in time -1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time -1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude -# 1003-1099 Reserved -1100 1100 Hovmoller-type grid with no averaging or other statistical processing -1101 1101 Hovmoller-type grid with averaging or other statistical processing +51 51 Categorical forecasts at a horizontal level or in a horizontal layer at a point in time +# 52-90 Reserved +91 91 Categorical forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# 92-253 Reserved +254 254 CCITT IA5 character string +# 255-999 Reserved +1000 1000 Cross-section of analysis and forecast at a point in time +1001 1001 Cross-section of averaged or otherwise statistically processed analysis or forecast over a range of time +1002 1002 Cross-section of analysis and forecast, averaged or otherwise statistically processed over latitude or longitude +# 1003-1099 Reserved +1100 1100 Hovmoller-type grid with no averaging or other statistical processing +1101 1101 Hovmoller-type grid with averaging or other statistical processing 50001 50001 Forecasting Systems with Variable Resolution in a point in time 50011 50011 Forecasting Systems with Variable Resolution in a continous or non countinous time interval -# 1102-32767 Reserved +# 1102-32767 Reserved # 32768-65534 Reserved for local use 40033 40033 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for simulated (synthetic) satellite data 40034 40034 Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer, in a continuous or non-continuous interval for simulated (synthetic) satellite data diff --git a/definitions/grib2/tables/9/4.1.0.table b/definitions/grib2/tables/9/4.1.0.table index 361108860..3413dbad5 100644 --- a/definitions/grib2/tables/9/4.1.0.table +++ b/definitions/grib2/tables/9/4.1.0.table @@ -1,27 +1,27 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Temperature -1 1 Moisture -2 2 Momentum -3 3 Mass -4 4 Short-wave radiation -5 5 Long-wave radiation -6 6 Cloud -7 7 Thermodynamic stability indices -8 8 Kinematic stability indices -9 9 Temperature probabilities -10 10 Moisture probabilities -11 11 Momentum probabilities -12 12 Mass probabilities -13 13 Aerosols -14 14 Trace gases (e.g. ozone, CO2) -15 15 Radar -16 16 Forecast radar imagery -17 17 Electrodynamics -18 18 Nuclear/radiology -19 19 Physical atmospheric properties -20 20 Atmospheric chemical constituents -# 21-189 Reserved -190 190 CCITT IA5 string -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Temperature +1 1 Moisture +2 2 Momentum +3 3 Mass +4 4 Short-wave radiation +5 5 Long-wave radiation +6 6 Cloud +7 7 Thermodynamic stability indices +8 8 Kinematic stability indices +9 9 Temperature probabilities +10 10 Moisture probabilities +11 11 Momentum probabilities +12 12 Mass probabilities +13 13 Aerosols +14 14 Trace gases (e.g. ozone, CO2) +15 15 Radar +16 16 Forecast radar imagery +17 17 Electrodynamics +18 18 Nuclear/radiology +19 19 Physical atmospheric properties +20 20 Atmospheric chemical constituents +# 21-189 Reserved +190 190 CCITT IA5 string +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.1.1.table b/definitions/grib2/tables/9/4.1.1.table index 29f1dec79..dea5bc49e 100644 --- a/definitions/grib2/tables/9/4.1.1.table +++ b/definitions/grib2/tables/9/4.1.1.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Hydrology basic products -1 1 Hydrology probabilities -2 2 Inland water and sediment properties -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Hydrology basic products +1 1 Hydrology probabilities +2 2 Inland water and sediment properties +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.1.10.table b/definitions/grib2/tables/9/4.1.10.table index 9c8c92b12..e6ce6faf7 100644 --- a/definitions/grib2/tables/9/4.1.10.table +++ b/definitions/grib2/tables/9/4.1.10.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Waves -1 1 Currents -2 2 Ice -3 3 Surface properties -4 4 Sub-surface properties -# 5-190 Reserved -191 191 Miscellaneous -# 192-254 Reserved for local use -255 255 Missing +0 0 Waves +1 1 Currents +2 2 Ice +3 3 Surface properties +4 4 Sub-surface properties +# 5-190 Reserved +191 191 Miscellaneous +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.1.2.table b/definitions/grib2/tables/9/4.1.2.table index b90201c63..805836998 100644 --- a/definitions/grib2/tables/9/4.1.2.table +++ b/definitions/grib2/tables/9/4.1.2.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Vegetation/biomass -1 1 Agri-/aquacultural special products -2 2 Transportation-related products -3 3 Soil products -4 4 Fire weather products -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Vegetation/biomass +1 1 Agri-/aquacultural special products +2 2 Transportation-related products +3 3 Soil products +4 4 Fire weather products +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.1.3.table b/definitions/grib2/tables/9/4.1.3.table index 3c947b136..c96617665 100644 --- a/definitions/grib2/tables/9/4.1.3.table +++ b/definitions/grib2/tables/9/4.1.3.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Image format products -1 1 Quantitative products -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Image format products +1 1 Quantitative products +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.10.table b/definitions/grib2/tables/9/4.10.table index 0e5170876..a13fb00b4 100644 --- a/definitions/grib2/tables/9/4.10.table +++ b/definitions/grib2/tables/9/4.10.table @@ -1,15 +1,15 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 avg Average -1 accum Accumulation -2 max Maximum -3 min Minimum -4 diff Difference (value at the end of time range minus value at the beginning) -5 rms Root mean square -6 sd Standard deviation -7 cov Covariance (temporal variance) -8 8 Difference (value at the start of time range minus value at the end) -9 ratio Ratio -10 10 Standardized anomaly -# 11-191 Reserved -# 192-254 Reserved for local use -255 missing Missing +0 avg Average +1 accum Accumulation +2 max Maximum +3 min Minimum +4 diff Difference (value at the end of time range minus value at the beginning) +5 rms Root mean square +6 sd Standard deviation +7 cov Covariance (temporal variance) +8 8 Difference (value at the start of time range minus value at the end) +9 ratio Ratio +10 10 Standardized anomaly +# 11-191 Reserved +# 192-254 Reserved for local use +255 missing Missing diff --git a/definitions/grib2/tables/9/4.11.table b/definitions/grib2/tables/9/4.11.table index 1257d1b09..af9ff29ad 100644 --- a/definitions/grib2/tables/9/4.11.table +++ b/definitions/grib2/tables/9/4.11.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Successive times processed have same forecast time, start time of forecast is incremented -2 2 Successive times processed have same start time of forecast, forecast time is incremented -3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant -4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant -5 5 Floating subinterval of time between forecast time and end of overall time interval -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Successive times processed have same forecast time, start time of forecast is incremented +2 2 Successive times processed have same start time of forecast, forecast time is incremented +3 3 Successive times processed have start time of forecast incremented and forecast time decremented so that valid time remains constant +4 4 Successive times processed have start time of forecast decremented and forecast time incremented so that valid time remains constant +5 5 Floating subinterval of time between forecast time and end of overall time interval +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.12.table b/definitions/grib2/tables/9/4.12.table index 680b6456d..6cab67bf5 100644 --- a/definitions/grib2/tables/9/4.12.table +++ b/definitions/grib2/tables/9/4.12.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Maintenance mode -1 1 Clear air -2 2 Precipitation +0 0 Maintenance mode +1 1 Clear air +2 2 Precipitation # 3-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/9/4.13.table b/definitions/grib2/tables/9/4.13.table index 0d0474d69..f090fb9ae 100644 --- a/definitions/grib2/tables/9/4.13.table +++ b/definitions/grib2/tables/9/4.13.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No quality control applied -1 1 Quality control applied +0 0 No quality control applied +1 1 Quality control applied # 2-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/9/4.14.table b/definitions/grib2/tables/9/4.14.table index 9ed9078a8..bcb04f328 100644 --- a/definitions/grib2/tables/9/4.14.table +++ b/definitions/grib2/tables/9/4.14.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No clutter filter used -1 1 Clutter filter used +0 0 No clutter filter used +1 1 Clutter filter used # 2-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/9/4.15.table b/definitions/grib2/tables/9/4.15.table index 4c8a88401..6e1ef5745 100644 --- a/definitions/grib2/tables/9/4.15.table +++ b/definitions/grib2/tables/9/4.15.table @@ -1,11 +1,11 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Data is calculated directly from the source grid with no interpolation -1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point -4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point -6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +0 0 Data is calculated directly from the source grid with no interpolation +1 1 Bilinear interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +2 2 Bicubic interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +3 3 Using the value from the source grid grid-point which is nearest to the nominal grid-point +4 4 Budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +5 5 Spectral interpolation using the 4 source grid grid-point values surrounding the nominal grid-point +6 6 Neighbor-budget interpolation using the 4 source grid grid-point values surrounding the nominal grid-point # 7-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.0.table b/definitions/grib2/tables/9/4.2.0.0.table index debc0a6f4..8656f8974 100644 --- a/definitions/grib2/tables/9/4.2.0.0.table +++ b/definitions/grib2/tables/9/4.2.0.0.table @@ -20,6 +20,6 @@ 18 18 Snow temperature (top of snow) (K) 19 19 Turbulent transfer coefficient for heat (Numeric) 20 20 Turbulent diffusion coefficient for heat (m2/s) -# 21-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 21-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.1.table b/definitions/grib2/tables/9/4.2.0.1.table index 1922792a6..8ee93e99b 100644 --- a/definitions/grib2/tables/9/4.2.0.1.table +++ b/definitions/grib2/tables/9/4.2.0.1.table @@ -62,7 +62,7 @@ 60 60 Snow depth water equivalent (kg m-2) 61 61 Snow density (kg m-3) 62 62 Snow evaporation (kg m-2) -63 63 Reserved +63 63 Reserved 64 64 Total column integrated water vapour (kg m-2) 65 65 Rain precipitation rate (kg m-2 s-1) 66 66 Snow precipitation rate (kg m-2 s-1) @@ -86,10 +86,10 @@ 84 84 Specific cloud ice water content (kg/kg) 85 85 Specific rain water content (kg/kg) 86 86 Specific snow water content (kg/kg) -# 87-89 Reserved +# 87-89 Reserved 90 90 Total kinematic moisture flux (kg kg-1 m s-1) 91 91 u-component (zonal) kinematic moisture flux (kg kg-1 m s-1) 92 92 v-component (meridional) kinematic moisture flux (kg kg-1 m s-1) -# 93-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 93-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.13.table b/definitions/grib2/tables/9/4.2.0.13.table index b9979f0d3..90ab7d1b9 100644 --- a/definitions/grib2/tables/9/4.2.0.13.table +++ b/definitions/grib2/tables/9/4.2.0.13.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Aerosol type (Code table 4.205) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.14.table b/definitions/grib2/tables/9/4.2.0.14.table index 4a2a4e128..fca42ccc7 100644 --- a/definitions/grib2/tables/9/4.2.0.14.table +++ b/definitions/grib2/tables/9/4.2.0.14.table @@ -2,6 +2,6 @@ 0 0 Total ozone (DU) 1 1 Ozone mixing ratio (kg/kg) 2 2 Total column integrated ozone (DU) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.15.table b/definitions/grib2/tables/9/4.2.0.15.table index 895892f86..66ccff19d 100644 --- a/definitions/grib2/tables/9/4.2.0.15.table +++ b/definitions/grib2/tables/9/4.2.0.15.table @@ -14,6 +14,6 @@ 12 12 Reflectivity of rain (dB) 13 13 Reflectivity of graupel (dB) 14 14 Reflectivity of hail (dB) -# 15-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 15-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.16.table b/definitions/grib2/tables/9/4.2.0.16.table index 39215ab20..18dedb7c0 100644 --- a/definitions/grib2/tables/9/4.2.0.16.table +++ b/definitions/grib2/tables/9/4.2.0.16.table @@ -5,6 +5,6 @@ 3 3 Echo top (m) 4 4 Reflectivity (dB) 5 5 Composite reflectivity (dB) -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.18.table b/definitions/grib2/tables/9/4.2.0.18.table index 30060fd2d..165aa6008 100644 --- a/definitions/grib2/tables/9/4.2.0.18.table +++ b/definitions/grib2/tables/9/4.2.0.18.table @@ -8,11 +8,11 @@ 6 6 Time-integrated air concentration of caesium pollutant (Bq s m-3) 7 7 Time-integrated air concentration of iodine pollutant (Bq s m-3) 8 8 Time-integrated air concentration of radioactive pollutant (Bq s m-3) -9 9 Reserved +9 9 Reserved 10 10 Air concentration (Bq m-3) 11 11 Wet deposition (Bq m-2) 12 12 Dry deposition (Bq m-2) 13 13 Total deposition (wet + dry) (Bq m-2) -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.19.table b/definitions/grib2/tables/9/4.2.0.19.table index 5831b567c..cbce2f76c 100644 --- a/definitions/grib2/tables/9/4.2.0.19.table +++ b/definitions/grib2/tables/9/4.2.0.19.table @@ -27,6 +27,6 @@ 25 25 Weather (Code table 4.225) 26 26 Convective outlook (Code table 4.224) 27 27 Icing scenario (Code table 4.227) -# 28-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 28-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.190.table b/definitions/grib2/tables/9/4.2.0.190.table index 39fb55746..3d9d5ff85 100644 --- a/definitions/grib2/tables/9/4.2.0.190.table +++ b/definitions/grib2/tables/9/4.2.0.190.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Arbitrary text string (CCITT IA5) -# 1-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 1-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.191.table b/definitions/grib2/tables/9/4.2.0.191.table index 81230c0e0..4ff12e532 100644 --- a/definitions/grib2/tables/9/4.2.0.191.table +++ b/definitions/grib2/tables/9/4.2.0.191.table @@ -2,6 +2,6 @@ 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Geographical latitude (deg N) 2 2 Geographical longitude (deg E) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing value +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing value diff --git a/definitions/grib2/tables/9/4.2.0.2.table b/definitions/grib2/tables/9/4.2.0.2.table index e8b59a998..68aa47ba6 100644 --- a/definitions/grib2/tables/9/4.2.0.2.table +++ b/definitions/grib2/tables/9/4.2.0.2.table @@ -35,6 +35,6 @@ 33 33 Wind fetch (m) 34 34 Normal wind component (m/s) 35 35 Tangential wind component (m/s) -# 36-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 36-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.20.table b/definitions/grib2/tables/9/4.2.0.20.table index cc2dbcc52..898a774eb 100644 --- a/definitions/grib2/tables/9/4.2.0.20.table +++ b/definitions/grib2/tables/9/4.2.0.20.table @@ -14,7 +14,7 @@ 12 12 Dry deposition mass flux (kg m-2 s-1) 13 13 Transfer from hydrophobic to hydrophilic (kg kg-1 s-1) 14 14 Transfer from SO2 (Sulphur dioxide) to SO4 (sulphate) (kg kg-1 s-1) -# 15-49 Reserved +# 15-49 Reserved 50 50 Amount in atmosphere (mol) 51 51 Concentration in air (mol m-3) 52 52 Volume mixing ratio (fraction in air) (mol/mol) @@ -25,7 +25,7 @@ 57 57 Total yearly average burden of the atmosphere (mol) 58 58 Total yearly averaged atmospheric loss (mol/s) 59 59 Aerosol number concentration (m-3) -# 60-99 Reserved +# 60-99 Reserved 100 100 Surface area density (aerosol) (/m) 101 101 Vertical visual range (m) 102 102 Aerosol optical thickness (Numeric) @@ -37,6 +37,6 @@ 108 108 Aerosol lidar backscatter from the ground (m-1 sr-1) 109 109 Aerosol lidar extinction from satellite (m-1) 110 110 Aerosol lidar extinction from the ground (m-1) -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.3.table b/definitions/grib2/tables/9/4.2.0.3.table index f718c6ea9..08c1c7bc3 100644 --- a/definitions/grib2/tables/9/4.2.0.3.table +++ b/definitions/grib2/tables/9/4.2.0.3.table @@ -26,6 +26,6 @@ 24 24 Anisotropy of sub-gridscale orography (Numeric) 25 25 Natural logarithm of pressure in Pa (Numeric) 26 26 Exner pressure (Numeric) -# 27-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 27-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.4.table b/definitions/grib2/tables/9/4.2.0.4.table index fea4cafc3..336fdb421 100644 --- a/definitions/grib2/tables/9/4.2.0.4.table +++ b/definitions/grib2/tables/9/4.2.0.4.table @@ -12,9 +12,9 @@ 10 10 Photosynthetically active radiation (W m-2) 11 11 Net short-wave radiation flux, clear sky (W m-2) 12 12 Downward UV radiation (W m-2) -# 13-49 Reserved +# 13-49 Reserved 50 50 UV index (under clear sky) (Numeric) 51 51 UV index (Numeric) -# 52-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 52-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.5.table b/definitions/grib2/tables/9/4.2.0.5.table index aae853bf9..607235064 100644 --- a/definitions/grib2/tables/9/4.2.0.5.table +++ b/definitions/grib2/tables/9/4.2.0.5.table @@ -6,6 +6,6 @@ 4 4 Upward long-wave radiation flux (W m-2) 5 5 Net long wave radiation flux (W m-2) 6 6 Net long-wave radiation flux, clear sky (W m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.6.table b/definitions/grib2/tables/9/4.2.0.6.table index fd4b23014..fb935344e 100644 --- a/definitions/grib2/tables/9/4.2.0.6.table +++ b/definitions/grib2/tables/9/4.2.0.6.table @@ -35,6 +35,6 @@ 33 33 Sunshine duration (s) 34 34 Surface long wave effective total cloudiness (Numeric) 35 35 Surface short wave effective total cloudiness (Numeric) -# 36-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 36-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.0.7.table b/definitions/grib2/tables/9/4.2.0.7.table index 7a7d2008b..6c1794c73 100644 --- a/definitions/grib2/tables/9/4.2.0.7.table +++ b/definitions/grib2/tables/9/4.2.0.7.table @@ -13,8 +13,8 @@ 11 11 Best (4-layer) lifted index (K) 12 12 Richardson number (Numeric) 13 13 Showalter index (K) -14 14 Reserved +14 14 Reserved 15 15 Updraft helicity (m2 s-2) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.1.0.table b/definitions/grib2/tables/9/4.2.1.0.table index bf1e3e93f..9c4d129da 100644 --- a/definitions/grib2/tables/9/4.2.1.0.table +++ b/definitions/grib2/tables/9/4.2.1.0.table @@ -6,6 +6,6 @@ 4 4 Snow water equivalent per cent of normal (%) 5 5 Baseflow-groundwater runoff (kg m-2) 6 6 Storm surface runoff (kg m-2) -# 7-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 7-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.1.1.table b/definitions/grib2/tables/9/4.2.1.1.table index cb5117dc8..aa560e479 100644 --- a/definitions/grib2/tables/9/4.2.1.1.table +++ b/definitions/grib2/tables/9/4.2.1.1.table @@ -2,6 +2,6 @@ 0 0 Conditional per cent precipitation amount fractile for an overall period (Encoded as an accumulation) (kg m-2) 1 1 Per cent precipitation in a sub-period of an overall period (Encoded as per cent accumulation over the sub-period) (%) 2 2 Probability of 0.01 inch of precipitation (POP) (%) -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.10.0.table b/definitions/grib2/tables/9/4.2.10.0.table index d4321d955..8bba32cf5 100644 --- a/definitions/grib2/tables/9/4.2.10.0.table +++ b/definitions/grib2/tables/9/4.2.10.0.table @@ -45,6 +45,6 @@ 43 43 Kurtosis of the sea surface elevation due to waves (-) 44 44 Benjamin-Feir index (-) 45 45 Spectral peakedness factor (s-1) -# 46-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 46-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.10.1.table b/definitions/grib2/tables/9/4.2.10.1.table index 5a33bac5d..a076fb07c 100644 --- a/definitions/grib2/tables/9/4.2.10.1.table +++ b/definitions/grib2/tables/9/4.2.10.1.table @@ -3,6 +3,6 @@ 1 1 Current speed (m/s) 2 2 u-component of current (m/s) 3 3 v-component of current (m/s) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.10.191.table b/definitions/grib2/tables/9/4.2.10.191.table index 14085ac9a..6cafbd3d4 100644 --- a/definitions/grib2/tables/9/4.2.10.191.table +++ b/definitions/grib2/tables/9/4.2.10.191.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Seconds prior to initial reference time (defined in Section 1) (s) 1 1 Meridional overturning stream function (m3/s) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.10.2.table b/definitions/grib2/tables/9/4.2.10.2.table index a69b2622c..80fe973be 100644 --- a/definitions/grib2/tables/9/4.2.10.2.table +++ b/definitions/grib2/tables/9/4.2.10.2.table @@ -9,6 +9,6 @@ 7 7 Ice divergence (/s) 8 8 Ice temperature (K) 9 9 Ice internal pressure (Pa m) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.10.3.table b/definitions/grib2/tables/9/4.2.10.3.table index 112af09d5..3b9a2df46 100644 --- a/definitions/grib2/tables/9/4.2.10.3.table +++ b/definitions/grib2/tables/9/4.2.10.3.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 Water temperature (K) 1 1 Deviation of sea level from mean (m) -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.10.4.table b/definitions/grib2/tables/9/4.2.10.4.table index d80a32780..91ffb2b29 100644 --- a/definitions/grib2/tables/9/4.2.10.4.table +++ b/definitions/grib2/tables/9/4.2.10.4.table @@ -7,12 +7,12 @@ 5 5 Ocean vertical salt diffusivity (m2 s-1) 6 6 Ocean vertical momentum diffusivity (m2 s-1) 7 7 Bathymetry (m) -# 8-10 Reserved +# 8-10 Reserved 11 11 Shape factor with respect to salinity profile (-) 12 12 Shape factor with respect to temperature profile in thermocline (-) 13 13 Attenuation coefficient of water with respect to solar radiation (m-1) 14 14 Water depth (m) 15 15 Water temperature (K) -# 16-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 16-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.2.0.table b/definitions/grib2/tables/9/4.2.2.0.table index ed4a85093..bbd328f0a 100644 --- a/definitions/grib2/tables/9/4.2.2.0.table +++ b/definitions/grib2/tables/9/4.2.2.0.table @@ -32,6 +32,6 @@ 30 30 Deciduous forest cover (Proportion) 31 31 Normalized differential vegetation index (NDVI) (Numeric) 32 32 Root depth of vegetation (m) -# 33-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 33-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.2.3.table b/definitions/grib2/tables/9/4.2.2.3.table index 80113a4bd..a9ec602e6 100644 --- a/definitions/grib2/tables/9/4.2.2.3.table +++ b/definitions/grib2/tables/9/4.2.2.3.table @@ -22,6 +22,6 @@ 20 20 Column-integrated soil moisture (kg m-2) 21 21 Soil ice (kg m-3) 22 22 Column-integrated soil ice (kg m-2) -# 23-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 23-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.3.0.table b/definitions/grib2/tables/9/4.2.3.0.table index 254e56bc8..8c19d43b2 100644 --- a/definitions/grib2/tables/9/4.2.3.0.table +++ b/definitions/grib2/tables/9/4.2.3.0.table @@ -9,6 +9,6 @@ 7 7 Cloud mask (Code table 4.217) 8 8 Pixel scene type (Code table 4.218) 9 9 Fire detection indicator (Code table 4.223) -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.2.3.1.table b/definitions/grib2/tables/9/4.2.3.1.table index 16eee69c4..d199aff60 100644 --- a/definitions/grib2/tables/9/4.2.3.1.table +++ b/definitions/grib2/tables/9/4.2.3.1.table @@ -17,12 +17,12 @@ 15 15 Clear-sky brightness temperature (K) 16 16 Cloudy radiance (with respect to wave number) (W m-1 sr-1) 17 17 Clear-sky radiance (with respect to wave number) (W m-1 sr-1) -18 18 Reserved +18 18 Reserved 19 19 Wind speed (m/s) 20 20 Aerosol optical thickness at 0.635 um 21 21 Aerosol optical thickness at 0.810 um 22 22 Aerosol optical thickness at 1.640 um -23 23 Angstrom coefficient -# 24-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +23 23 Angstrom coefficient +# 24-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.201.table b/definitions/grib2/tables/9/4.201.table index d1aa3491d..e16d5d808 100644 --- a/definitions/grib2/tables/9/4.201.table +++ b/definitions/grib2/tables/9/4.201.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Rain -2 2 Thunderstorm -3 3 Freezing rain -4 4 Mixed/ice -5 5 Snow +0 0 Reserved +1 1 Rain +2 2 Thunderstorm +3 3 Freezing rain +4 4 Mixed/ice +5 5 Snow # 6-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/9/4.203.table b/definitions/grib2/tables/9/4.203.table index fce5a15b1..9a8d29e01 100644 --- a/definitions/grib2/tables/9/4.203.table +++ b/definitions/grib2/tables/9/4.203.table @@ -1,25 +1,25 @@ -0 0 Clear -1 1 Cumulonimbus -2 2 Stratus -3 3 Stratocumulus -4 4 Cumulus -5 5 Altostratus -6 6 Nimbostratus -7 7 Altocumulus -8 8 Cirrostratus -9 9 Cirrocumulus -10 10 Cirrus -11 11 Cumulonimbus - ground-based fog beneath the lowest layer -12 12 Stratus - ground-based fog beneath the lowest layer -13 13 Stratocumulus - ground-based fog beneath the lowest layer -14 14 Cumulus - ground-based fog beneath the lowest layer -15 15 Altostratus - ground-based fog beneath the lowest layer -16 16 Nimbostratus - ground-based fog beneath the lowest layer -17 17 Altocumulus - ground-based fog beneath the lowest layer -18 18 Cirrostratus - ground-based fog beneath the lowest layer -19 19 Cirrocumulus - ground-based fog beneath the lowest layer -20 20 Cirrus - ground-based fog beneath the lowest layer -# 21-190 Reserved -191 191 Unknown -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear +1 1 Cumulonimbus +2 2 Stratus +3 3 Stratocumulus +4 4 Cumulus +5 5 Altostratus +6 6 Nimbostratus +7 7 Altocumulus +8 8 Cirrostratus +9 9 Cirrocumulus +10 10 Cirrus +11 11 Cumulonimbus - ground-based fog beneath the lowest layer +12 12 Stratus - ground-based fog beneath the lowest layer +13 13 Stratocumulus - ground-based fog beneath the lowest layer +14 14 Cumulus - ground-based fog beneath the lowest layer +15 15 Altostratus - ground-based fog beneath the lowest layer +16 16 Nimbostratus - ground-based fog beneath the lowest layer +17 17 Altocumulus - ground-based fog beneath the lowest layer +18 18 Cirrostratus - ground-based fog beneath the lowest layer +19 19 Cirrocumulus - ground-based fog beneath the lowest layer +20 20 Cirrus - ground-based fog beneath the lowest layer +# 21-190 Reserved +191 191 Unknown +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.204.table b/definitions/grib2/tables/9/4.204.table index a1bdcdf05..8d8bca9b2 100644 --- a/definitions/grib2/tables/9/4.204.table +++ b/definitions/grib2/tables/9/4.204.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 None -1 1 Isolated (1-2%) -2 2 Few (3-5%) -3 3 Scattered (16-45%) -4 4 Numerous (> 45%) +0 0 None +1 1 Isolated (1-2%) +2 2 Few (3-5%) +3 3 Scattered (16-45%) +4 4 Numerous (> 45%) # 5-191 Reserved # 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/9/4.205.table b/definitions/grib2/tables/9/4.205.table index 8d425ab9d..3fadf7d80 100644 --- a/definitions/grib2/tables/9/4.205.table +++ b/definitions/grib2/tables/9/4.205.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Aerosol not present -1 1 Aerosol present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Aerosol not present +1 1 Aerosol present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.206.table b/definitions/grib2/tables/9/4.206.table index 0be7fd4f8..43b0ba137 100644 --- a/definitions/grib2/tables/9/4.206.table +++ b/definitions/grib2/tables/9/4.206.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Not present -1 1 Present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not present +1 1 Present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.207.table b/definitions/grib2/tables/9/4.207.table index fde9eb477..815a5777e 100644 --- a/definitions/grib2/tables/9/4.207.table +++ b/definitions/grib2/tables/9/4.207.table @@ -1,10 +1,10 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 None -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Trace -5 5 Heavy -# 6-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Trace +5 5 Heavy +# 6-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.208.table b/definitions/grib2/tables/9/4.208.table index 196becaaf..23ea97317 100644 --- a/definitions/grib2/tables/9/4.208.table +++ b/definitions/grib2/tables/9/4.208.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 None (smooth) -1 1 Light -2 2 Moderate -3 3 Severe -4 4 Extreme -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 None (smooth) +1 1 Light +2 2 Moderate +3 3 Severe +4 4 Extreme +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.209.table b/definitions/grib2/tables/9/4.209.table index 351c0f431..53c6c5eba 100644 --- a/definitions/grib2/tables/9/4.209.table +++ b/definitions/grib2/tables/9/4.209.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Stable -2 2 Mechanically-driven turbulence -3 3 Forced convection -4 4 Free convection -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Stable +2 2 Mechanically-driven turbulence +3 3 Forced convection +4 4 Free convection +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.210.table b/definitions/grib2/tables/9/4.210.table index 1c00b8c6f..149b2ba06 100644 --- a/definitions/grib2/tables/9/4.210.table +++ b/definitions/grib2/tables/9/4.210.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Contrail not present -1 1 Contrail present -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Contrail not present +1 1 Contrail present +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.211.table b/definitions/grib2/tables/9/4.211.table index 66ef656f6..b5753f19f 100644 --- a/definitions/grib2/tables/9/4.211.table +++ b/definitions/grib2/tables/9/4.211.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Low bypass -1 1 High bypass -2 2 Non-bypass -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Low bypass +1 1 High bypass +2 2 Non-bypass +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.212.table b/definitions/grib2/tables/9/4.212.table index c59bd24e8..738c45d2c 100644 --- a/definitions/grib2/tables/9/4.212.table +++ b/definitions/grib2/tables/9/4.212.table @@ -1,18 +1,18 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Urban land -2 2 Agriculture -3 3 Range land -4 4 Deciduous forest -5 5 Coniferous forest -6 6 Forest/wetland -7 7 Water -8 8 Wetlands -9 9 Desert -10 10 Tundra -11 11 Ice -12 12 Tropical forest -13 13 Savannah -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Urban land +2 2 Agriculture +3 3 Range land +4 4 Deciduous forest +5 5 Coniferous forest +6 6 Forest/wetland +7 7 Water +8 8 Wetlands +9 9 Desert +10 10 Tundra +11 11 Ice +12 12 Tropical forest +13 13 Savannah +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.213.table b/definitions/grib2/tables/9/4.213.table index 0f5de0104..5cee0b798 100644 --- a/definitions/grib2/tables/9/4.213.table +++ b/definitions/grib2/tables/9/4.213.table @@ -1,21 +1,21 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 Sand -2 2 Loamy sand -3 3 Sandy loam -4 4 Silt loam -5 5 Organic (redefined) -6 6 Sandy clay loam -7 7 Silt clay loam -8 8 Clay loam -9 9 Sandy clay -10 10 Silty clay -11 11 Clay -12 12 Loam -13 13 Peat -14 14 Rock -15 15 Ice -16 16 Water -# 17-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Reserved +1 1 Sand +2 2 Loamy sand +3 3 Sandy loam +4 4 Silt loam +5 5 Organic (redefined) +6 6 Sandy clay loam +7 7 Silt clay loam +8 8 Clay loam +9 9 Sandy clay +10 10 Silty clay +11 11 Clay +12 12 Loam +13 13 Peat +14 14 Rock +15 15 Ice +16 16 Water +# 17-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.215.table b/definitions/grib2/tables/9/4.215.table index 460888217..5ed37c034 100644 --- a/definitions/grib2/tables/9/4.215.table +++ b/definitions/grib2/tables/9/4.215.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -# 0-49 Reserved -50 50 No-snow/no-cloud -# 51-99 Reserved -100 100 Clouds -# 101-249 Reserved -250 250 Snow -# 251-254 Reserved for local use -255 255 Missing +# 0-49 Reserved +50 50 No-snow/no-cloud +# 51-99 Reserved +100 100 Clouds +# 101-249 Reserved +250 250 Snow +# 251-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.216.table b/definitions/grib2/tables/9/4.216.table index cc62ca5e3..2fd143724 100644 --- a/definitions/grib2/tables/9/4.216.table +++ b/definitions/grib2/tables/9/4.216.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit # 0-90 Elevation in increments of 100 m -# 91-253 Reserved -254 254 Clouds -255 255 Missing +# 91-253 Reserved +254 254 Clouds +255 255 Missing diff --git a/definitions/grib2/tables/9/4.217.table b/definitions/grib2/tables/9/4.217.table index 51a263a99..6a014c9c3 100644 --- a/definitions/grib2/tables/9/4.217.table +++ b/definitions/grib2/tables/9/4.217.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Clear over water -1 1 Clear over land -2 2 Cloud -3 3 No data -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Clear over water +1 1 Clear over land +2 2 Cloud +3 3 No data +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.218.table b/definitions/grib2/tables/9/4.218.table index d4b2ab843..b6087448f 100644 --- a/definitions/grib2/tables/9/4.218.table +++ b/definitions/grib2/tables/9/4.218.table @@ -1,38 +1,38 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No scene identified -1 1 Green needle-leafed forest -2 2 Green broad-leafed forest -3 3 Deciduous needle-leafed forest -4 4 Deciduous broad-leafed forest -5 5 Deciduous mixed forest -6 6 Closed shrub-land -7 7 Open shrub-land -8 8 Woody savannah -9 9 Savannah -10 10 Grassland -11 11 Permanent wetland -12 12 Cropland -13 13 Urban -14 14 Vegetation / crops -15 15 Permanent snow / ice -16 16 Barren desert -17 17 Water bodies -18 18 Tundra -# 19-96 Reserved -97 97 Snow / ice on land -98 98 Snow / ice on water -99 99 Sun-glint -100 100 General cloud -101 101 Low cloud / fog / Stratus -102 102 Low cloud / Stratocumulus -103 103 Low cloud / unknown type -104 104 Medium cloud / Nimbostratus -105 105 Medium cloud / Altostratus -106 106 Medium cloud / unknown type -107 107 High cloud / Cumulus -108 108 High cloud / Cirrus -109 109 High cloud / unknown -110 110 Unknown cloud type -# 111-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No scene identified +1 1 Green needle-leafed forest +2 2 Green broad-leafed forest +3 3 Deciduous needle-leafed forest +4 4 Deciduous broad-leafed forest +5 5 Deciduous mixed forest +6 6 Closed shrub-land +7 7 Open shrub-land +8 8 Woody savannah +9 9 Savannah +10 10 Grassland +11 11 Permanent wetland +12 12 Cropland +13 13 Urban +14 14 Vegetation / crops +15 15 Permanent snow / ice +16 16 Barren desert +17 17 Water bodies +18 18 Tundra +# 19-96 Reserved +97 97 Snow / ice on land +98 98 Snow / ice on water +99 99 Sun-glint +100 100 General cloud +101 101 Low cloud / fog / Stratus +102 102 Low cloud / Stratocumulus +103 103 Low cloud / unknown type +104 104 Medium cloud / Nimbostratus +105 105 Medium cloud / Altostratus +106 106 Medium cloud / unknown type +107 107 High cloud / Cumulus +108 108 High cloud / Cirrus +109 109 High cloud / unknown +110 110 Unknown cloud type +# 111-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.219.table b/definitions/grib2/tables/9/4.219.table index f10ce468e..a02452fc4 100644 --- a/definitions/grib2/tables/9/4.219.table +++ b/definitions/grib2/tables/9/4.219.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Nominal cloud top height quality -1 1 Fog in segment -2 2 Poor quality height estimation -3 3 Fog in segment and poor quality height estimation -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Nominal cloud top height quality +1 1 Fog in segment +2 2 Poor quality height estimation +3 3 Fog in segment and poor quality height estimation +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.220.table b/definitions/grib2/tables/9/4.220.table index 9c957eb01..7a18fa1fd 100644 --- a/definitions/grib2/tables/9/4.220.table +++ b/definitions/grib2/tables/9/4.220.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Latitude -1 1 Longitude -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Latitude +1 1 Longitude +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.221.table b/definitions/grib2/tables/9/4.221.table index 5466929c7..eb0b64502 100644 --- a/definitions/grib2/tables/9/4.221.table +++ b/definitions/grib2/tables/9/4.221.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Not included -1 1 Extrapolated -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Not included +1 1 Extrapolated +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.222.table b/definitions/grib2/tables/9/4.222.table index c54194e29..f554a7f3d 100644 --- a/definitions/grib2/tables/9/4.222.table +++ b/definitions/grib2/tables/9/4.222.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No -1 1 Yes -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No +1 1 Yes +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.223.table b/definitions/grib2/tables/9/4.223.table index b6a9be136..706abab78 100644 --- a/definitions/grib2/tables/9/4.223.table +++ b/definitions/grib2/tables/9/4.223.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No fire detected -1 1 Possible fire detected -2 2 Probable fire detected -3 3 Missing value +0 0 No fire detected +1 1 Possible fire detected +2 2 Probable fire detected +3 3 Missing value diff --git a/definitions/grib2/tables/9/4.224.table b/definitions/grib2/tables/9/4.224.table index af846f841..cf67496b8 100644 --- a/definitions/grib2/tables/9/4.224.table +++ b/definitions/grib2/tables/9/4.224.table @@ -1,18 +1,18 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No risk area -1 1 Reserved -2 2 General thunderstorm risk area -3 3 Reserved -4 4 Slight risk area -5 5 Reserved -6 6 Moderate risk area -7 7 Reserved -8 8 High risk area -# 9-10 Reserved -11 11 Dry thunderstorm (dry lightning) risk area -# 12-13 Reserved -14 14 Critical risk area -# 15-17 Reserved -18 18 Extremely critical risk area -# 19-254 Reserved -255 255 Missing +0 0 No risk area +1 1 Reserved +2 2 General thunderstorm risk area +3 3 Reserved +4 4 Slight risk area +5 5 Reserved +6 6 Moderate risk area +7 7 Reserved +8 8 High risk area +# 9-10 Reserved +11 11 Dry thunderstorm (dry lightning) risk area +# 12-13 Reserved +14 14 Critical risk area +# 15-17 Reserved +18 18 Extremely critical risk area +# 19-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/9/4.227.table b/definitions/grib2/tables/9/4.227.table index 56fa0e752..5a0771c0f 100644 --- a/definitions/grib2/tables/9/4.227.table +++ b/definitions/grib2/tables/9/4.227.table @@ -5,6 +5,6 @@ 2 2 Convective 3 3 Stratiform 4 4 Freezing -# 5-191 Reserved +# 5-191 Reserved # 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/9/4.3.table b/definitions/grib2/tables/9/4.3.table index 68e2cc83f..8a4e919c9 100644 --- a/definitions/grib2/tables/9/4.3.table +++ b/definitions/grib2/tables/9/4.3.table @@ -1,16 +1,16 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Analysis -1 1 Initialization -2 2 Forecast -3 3 Bias corrected forecast -4 4 Ensemble forecast -5 5 Probability forecast -6 6 Forecast error -7 7 Analysis error -8 8 Observation -9 9 Climatological -10 10 Probability-weighted forecast -11 11 Bias-corrected ensemble forecast -# 12-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Analysis +1 1 Initialization +2 2 Forecast +3 3 Bias corrected forecast +4 4 Ensemble forecast +5 5 Probability forecast +6 6 Forecast error +7 7 Analysis error +8 8 Observation +9 9 Climatological +10 10 Probability-weighted forecast +11 11 Bias-corrected ensemble forecast +# 12-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.4.table b/definitions/grib2/tables/9/4.4.table index df5272d2f..511c76aa9 100644 --- a/definitions/grib2/tables/9/4.4.table +++ b/definitions/grib2/tables/9/4.4.table @@ -1,17 +1,17 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 m Minute -1 h Hour -2 D Day -3 M Month -4 Y Year -5 10Y Decade (10 years) -6 30Y Normal (30 years) -7 C Century (100 years) -# 8-9 Reserved -10 3h 3 hours -11 6h 6 hours -12 12h 12 hours -13 s Second -# 14-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 m Minute +1 h Hour +2 D Day +3 M Month +4 Y Year +5 10Y Decade (10 years) +6 30Y Normal (30 years) +7 C Century (100 years) +# 8-9 Reserved +10 3h 3 hours +11 6h 6 hours +12 12h 12 hours +13 s Second +# 14-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.5.table b/definitions/grib2/tables/9/4.5.table index 9a46a3aa0..d07c799a8 100644 --- a/definitions/grib2/tables/9/4.5.table +++ b/definitions/grib2/tables/9/4.5.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface 2 2 Cloud base level 3 3 Level of cloud tops @@ -12,11 +12,11 @@ 10 10 Entire atmosphere 11 11 Cumulonimbus (CB) base (m) 12 12 Cumulonimbus (CB) top (m) -# 13-19 Reserved +# 13-19 Reserved 20 20 Isothermal level (K) -# 21-99 Reserved +# 21-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -25,7 +25,7 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level 112 112 Reserved 113 113 Logarithmic hybrid level @@ -35,14 +35,14 @@ 119 hpl Hybrid pressure level # 120-149 Reserved 150 150 Generalized vertical height coordinate -# 151-159 Reserved -160 160 Depth below sea level m +# 151-159 Reserved +160 160 Depth below sea level m 161 161 Depth below water surface (m) 162 sfc Lake or river bottom 163 163 Bottom of sediment layer 164 164 Bottom of thermally active sediment layer 165 165 Bottom of sediment layer penetrated by thermal wave 166 sfc Mixing layer -# 167-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +# 167-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.6.table b/definitions/grib2/tables/9/4.6.table index 54f2993c3..eaa5c4362 100644 --- a/definitions/grib2/tables/9/4.6.table +++ b/definitions/grib2/tables/9/4.6.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Unperturbed high-resolution control forecast -1 1 Unperturbed low-resolution control forecast -2 2 Negatively perturbed forecast -3 3 Positively perturbed forecast -4 4 Multi-model forecast -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unperturbed high-resolution control forecast +1 1 Unperturbed low-resolution control forecast +2 2 Negatively perturbed forecast +3 3 Positively perturbed forecast +4 4 Multi-model forecast +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.7.table b/definitions/grib2/tables/9/4.7.table index 23e0d457e..e6d887bdb 100644 --- a/definitions/grib2/tables/9/4.7.table +++ b/definitions/grib2/tables/9/4.7.table @@ -1,14 +1,14 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Unweighted mean of all members -1 1 Weighted mean of all members -2 2 Standard deviation with respect to cluster mean -3 3 Standard deviation with respect to cluster mean, normalized -4 4 Spread of all members -5 5 Large anomaly index of all members -6 6 Unweighted mean of the cluster members -7 7 Interquartile range (range between the 25th and 75th quantile) -8 8 Minimum of all ensemble members -9 9 Maximum of all ensemble members -# 10-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Unweighted mean of all members +1 1 Weighted mean of all members +2 2 Standard deviation with respect to cluster mean +3 3 Standard deviation with respect to cluster mean, normalized +4 4 Spread of all members +5 5 Large anomaly index of all members +6 6 Unweighted mean of the cluster members +7 7 Interquartile range (range between the 25th and 75th quantile) +8 8 Minimum of all ensemble members +9 9 Maximum of all ensemble members +# 10-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.8.table b/definitions/grib2/tables/9/4.8.table index 37a6cf767..d06153079 100644 --- a/definitions/grib2/tables/9/4.8.table +++ b/definitions/grib2/tables/9/4.8.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Anomaly correlation -1 1 Root mean square -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Anomaly correlation +1 1 Root mean square +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.9.table b/definitions/grib2/tables/9/4.9.table index 19e64a3d2..5243e58dd 100644 --- a/definitions/grib2/tables/9/4.9.table +++ b/definitions/grib2/tables/9/4.9.table @@ -1,9 +1,9 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Probability of event below lower limit -1 1 Probability of event above upper limit -2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) -3 3 Probability of event above lower limit -4 4 Probability of event below upper limit -# 5-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Probability of event below lower limit +1 1 Probability of event above upper limit +2 2 Probability of event between lower and upper limits (the range includes the lower limit but not the upper limit) +3 3 Probability of event above lower limit +4 4 Probability of event below upper limit +# 5-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/4.91.table b/definitions/grib2/tables/9/4.91.table index 5d975ad8e..cea421695 100644 --- a/definitions/grib2/tables/9/4.91.table +++ b/definitions/grib2/tables/9/4.91.table @@ -1,16 +1,16 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Smaller than first limit -1 1 Greater than second limit -2 2 Between first and second limit. The range includes the first limit but not the second limit -3 3 Greater than first limit -4 4 Smaller than second limit -5 5 Smaller or equal first limit -6 6 Greater or equal second limit -7 7 Between first and second. The range includes the first limit and the second limit -8 8 Greater or equal first limit -9 9 Smaller or equal second limit -10 10 Between first and second limit. The range includes the second limit but not the first limit -11 11 Equal to first limit. +0 0 Smaller than first limit +1 1 Greater than second limit +2 2 Between first and second limit. The range includes the first limit but not the second limit +3 3 Greater than first limit +4 4 Smaller than second limit +5 5 Smaller or equal first limit +6 6 Greater or equal second limit +7 7 Between first and second. The range includes the first limit and the second limit +8 8 Greater or equal first limit +9 9 Smaller or equal second limit +10 10 Between first and second limit. The range includes the second limit but not the first limit +11 11 Equal to first limit. # 12-191 Reserved # 192-254 Reserved for local use -255 missing Missing +255 missing Missing diff --git a/definitions/grib2/tables/9/5.1.table b/definitions/grib2/tables/9/5.1.table index 100d4106d..158a35850 100644 --- a/definitions/grib2/tables/9/5.1.table +++ b/definitions/grib2/tables/9/5.1.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Floating point -1 1 Integer -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Floating point +1 1 Integer +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/5.2.table b/definitions/grib2/tables/9/5.2.table index 4d0808be6..d9896e11f 100644 --- a/definitions/grib2/tables/9/5.2.table +++ b/definitions/grib2/tables/9/5.2.table @@ -1,8 +1,8 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Explicit coordinate values set -1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 -# 2-10 Reserved +0 0 Explicit coordinate values set +1 1 Linear coordinates f(1)=C1, f(n)=f(n-1)+C2 +# 2-10 Reserved 11 11 Geometric coordinates f(1)=C1, f(n)=C2*f(n-1) -# 12-191 Reserved -# 192-254 Reserved for local use +# 12-191 Reserved +# 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/grib2/tables/9/5.3.table b/definitions/grib2/tables/9/5.3.table index 705fa6524..6f228aeec 100644 --- a/definitions/grib2/tables/9/5.3.table +++ b/definitions/grib2/tables/9/5.3.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -1 1 Direction degrees true -2 2 Frequency (s-1) -3 3 Radial number (2pi/lambda) (m-1) -# 4-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +1 1 Direction degrees true +2 2 Frequency (s-1) +3 3 Radial number (2pi/lambda) (m-1) +# 4-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/5.4.table b/definitions/grib2/tables/9/5.4.table index 8133367a5..f844f557e 100644 --- a/definitions/grib2/tables/9/5.4.table +++ b/definitions/grib2/tables/9/5.4.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Row by row splitting -1 1 General group splitting -# 2-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 Row by row splitting +1 1 General group splitting +# 2-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/5.40.table b/definitions/grib2/tables/9/5.40.table index 0d56ad0e0..2431eb547 100644 --- a/definitions/grib2/tables/9/5.40.table +++ b/definitions/grib2/tables/9/5.40.table @@ -1,5 +1,5 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Lossless -1 1 Lossy -# 2-254 Reserved -255 255 Missing +0 0 Lossless +1 1 Lossy +# 2-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/9/5.5.table b/definitions/grib2/tables/9/5.5.table index 5d625dbda..f2216e273 100644 --- a/definitions/grib2/tables/9/5.5.table +++ b/definitions/grib2/tables/9/5.5.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 No explicit missing values included within data values -1 1 Primary missing values included within data values -2 2 Primary and secondary missing values included within data values -# 3-191 Reserved -# 192-254 Reserved for local use -255 255 Missing +0 0 No explicit missing values included within data values +1 1 Primary missing values included within data values +2 2 Primary and secondary missing values included within data values +# 3-191 Reserved +# 192-254 Reserved for local use +255 255 Missing diff --git a/definitions/grib2/tables/9/5.6.table b/definitions/grib2/tables/9/5.6.table index 16f4c25f3..3b0892d37 100644 --- a/definitions/grib2/tables/9/5.6.table +++ b/definitions/grib2/tables/9/5.6.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 First-order spatial differencing -2 2 Second-order spatial differencing -# 3-191 Reserved +0 0 Reserved +1 1 First-order spatial differencing +2 2 Second-order spatial differencing +# 3-191 Reserved # 192-254 Reserved for local use -255 255 Missing +255 255 Missing diff --git a/definitions/grib2/tables/9/5.7.table b/definitions/grib2/tables/9/5.7.table index b93aa8130..f056d3059 100644 --- a/definitions/grib2/tables/9/5.7.table +++ b/definitions/grib2/tables/9/5.7.table @@ -1,7 +1,7 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit -0 0 Reserved -1 1 IEEE 32-bit (I=4 in section 7) -2 2 IEEE 64-bit (I=8 in section 7) -3 3 IEEE 128-bit (I=16 in section 7) -# 4-254 Reserved -255 255 Missing +0 0 Reserved +1 1 IEEE 32-bit (I=4 in section 7) +2 2 IEEE 64-bit (I=8 in section 7) +3 3 IEEE 128-bit (I=16 in section 7) +# 4-254 Reserved +255 255 Missing diff --git a/definitions/grib2/tables/9/6.0.table b/definitions/grib2/tables/9/6.0.table index aecdc6e5e..9c9dba372 100644 --- a/definitions/grib2/tables/9/6.0.table +++ b/definitions/grib2/tables/9/6.0.table @@ -1,6 +1,6 @@ # Automatically generated by ./create_tables.pl from database fm92_grib2@grib-param-db-prod.ecmwf.int, do not edit 0 0 A bit map applies to this product and is specified in this Section 1 1 A bit map pre-determined by the originating/generating Centre applies to this product and is not specified in this Section -# 1-253 A bit map predetermined by the originating/generating Centre applies to this product and is not specified in this Section -254 254 A bit map defined previously in the same GRIB message applies to this product -255 255 A bit map does not apply to this product +# 1-253 A bit map predetermined by the originating/generating Centre applies to this product and is not specified in this Section +254 254 A bit map defined previously in the same GRIB message applies to this product +255 255 A bit map does not apply to this product diff --git a/definitions/grib2/tables/local/ecmf/1/4.2.0.1.table b/definitions/grib2/tables/local/ecmf/1/4.2.0.1.table index 5e02901a1..1ee04a741 100644 --- a/definitions/grib2/tables/local/ecmf/1/4.2.0.1.table +++ b/definitions/grib2/tables/local/ecmf/1/4.2.0.1.table @@ -1,7 +1,7 @@ # Code table 4.2 - discipline=0 category=1 for ECMWF 192 192 Snow evaporation rate (kg m-2 s-1) 193 193 Total precipitation rate (m s-1) -194 194 Accumulated freezing rain (m) +194 194 Freezing rain precipitation rate (m s-1) 195 195 Convective precipitation rate (m s-1) 196 196 Large-scale precipitation rate (m s-1) 197 197 Snow evaporation rate (m of water equivalent s-1) diff --git a/definitions/grib2/tables/local/ecmf/obstat.5.0.table b/definitions/grib2/tables/local/ecmf/obstat.5.0.table index 71a9a0e8c..ef4ea724d 100644 --- a/definitions/grib2/tables/local/ecmf/obstat.5.0.table +++ b/definitions/grib2/tables/local/ecmf/obstat.5.0.table @@ -1,13 +1,13 @@ #Code Table obstat.5.0: List of satellite instruments -0 HIRS HIRS +0 HIRS HIRS 1 MSU MSU 2 SSU SSU 3 AMSUA AMSUA 4 AMSUB AMSUB 6 SSM/I SSM/I 9 TMI TMI -10 SSMI/S SSMI/S -11 AIRS AIRS +10 SSMI/S SSMI/S +11 AIRS AIRS 15 MHS MHS 16 IASI IASI 17 AMSRE AMSR-E @@ -33,20 +33,20 @@ 516 TANSO TANSO 624 SBUV-2 SBUV-2 2000 AMV_WV_CLOUDY AMV WV cloudy -2001 AMV_IR AMV IR +2001 AMV_IR AMV IR 2002 AMV_VIS AMV VIS 2003 AMV_WVMIX AMV WVMIX 2005 AMV_WV_Clear AMV Water Vapor clear 2100 AMV_WV_6.2_cloudy AMV WV 6.2 cloudy -2101 AMV_IR_ch1 AMV IR ch1 +2101 AMV_IR_ch1 AMV IR ch1 2102 AMV_VIS_ch1 AMV VIS ch1 -2105 AMV_WV_6.2_clear AMV WV_6.2 clear +2105 AMV_WV_6.2_clear AMV WV_6.2 clear 2200 AMV_WV_7.3_cloudy AMV WV 7.3 cloudy 2201 AMV_IR_ch2 AMV IR ch2 2202 AMV_VIS-2 AMV VIS-2 2205 AMV_WV_7.3_clear AMV WV 7.3 clear 2300 AMV_WV_cloudy_ch3 AMV WV cloudy ch 3 -2301 AMV_IR-10 AMV IR-10 +2301 AMV_IR-10 AMV IR-10 2305 AMV_WV_clear_Ch3 AMV WV clear Ch3 2350 QUIKSCAT QUIKSCAT 2150 SCAT SCAT diff --git a/definitions/grib2/tables/local/ecmf/obstat.7.0.table b/definitions/grib2/tables/local/ecmf/obstat.7.0.table index fcd1c2e02..688485882 100644 --- a/definitions/grib2/tables/local/ecmf/obstat.7.0.table +++ b/definitions/grib2/tables/local/ecmf/obstat.7.0.table @@ -1,5 +1,5 @@ #Code Table obstat.7.0: Vertical coordinate types -1 1 Channel +1 1 Channel 2 2 Pressure level 3 3 Pressure layer 4 4 Surface diff --git a/definitions/grib2/tables/local/ecmf/obstat.8.0.table b/definitions/grib2/tables/local/ecmf/obstat.8.0.table index 382402473..0e167b7dd 100644 --- a/definitions/grib2/tables/local/ecmf/obstat.8.0.table +++ b/definitions/grib2/tables/local/ecmf/obstat.8.0.table @@ -2,5 +2,5 @@ 1 Land Land 2 Sea Sea 3 Sea-ice Sea-ice -4 All_surfaces All surface types combined +4 All_surfaces All surface types combined #5-255 Reserved diff --git a/definitions/grib2/tables/local/ecmf/obstat.9.0.table b/definitions/grib2/tables/local/ecmf/obstat.9.0.table index 8520066bd..38be1bfe3 100644 --- a/definitions/grib2/tables/local/ecmf/obstat.9.0.table +++ b/definitions/grib2/tables/local/ecmf/obstat.9.0.table @@ -1,14 +1,14 @@ -#Code Table obstat.9.0: Observation diagnostics -1 count data count +# Code Table obstat.9.0: Observation diagnostics +1 count data count 2 obs Average of observed values -3 obs_stdv Standard deviation of observed values -4 fgdep Average of first guess departure +3 obs_stdv Standard deviation of observed values +4 fgdep Average of first guess departure 5 fgdep_stdv Standard deviation of first guess departure 6 andep Average of analysis departure 7 andep_stdv Standard deviation of analysis departure 8 obs_error Average of observation standard error 9 obs_error_stdv Standard deviation of observation standard error -10 bkg_error Average of background standard error +10 bkg_error Average of background standard error 11 bkg_error_stdv Standard deviation of background standard error 12 lr_andep1 Average of low resolution analysis departure update 1 13 lr_andep1_stdv Standard deviation of low resolution analysis departure update 1 @@ -19,7 +19,7 @@ 18 bcor Average of Bias correction 19 bcor_stdv Standard deviation of bias correction 20 vbcor average of Variational bias correction -21 vbcor_stdv Standard deviation of variational bias correction +21 vbcor_stdv Standard deviation of variational bias correction 22 fgdep_nbcor Average of background departure without bias correction 23 fgdep_nbcor_stdv Standard deviation of background departure without bias correction 24 windspeed Average of wind speed @@ -45,8 +45,7 @@ 60 far_rate False alarm rate 62 miss_rate Miss rate 64 hit_rate hit rate -66 corr_nul correct nuls +66 corr_nul correct nuls 68 est_fg_err Estimated variance of the first guess error 70 edafgspr EDA first guess variance 72 edaanspr EDA Analysis variance -#36-255 Reserved diff --git a/definitions/grib2/tables/local/era6/1.1.table b/definitions/grib2/tables/local/era6/1.1.table index 720161860..a0c8af15c 100644 --- a/definitions/grib2/tables/local/era6/1.1.table +++ b/definitions/grib2/tables/local/era6/1.1.table @@ -1,6 +1,6 @@ # Code Table 1.1 GRIB Local Tables Version Number -0 0 Local tables not used -# . Only table entries and templates from the current Master table are valid. +0 0 Local tables not used +# Only table entries and templates from the current Master table are valid. # 1-254 Number of local tables version used 1 1 ERA6 local tables version 1 255 255 Missing diff --git a/definitions/grib2/tables/local/kwbc/1/4.5.table b/definitions/grib2/tables/local/kwbc/1/4.5.table index f1cfbfbe6..f89c21674 100644 --- a/definitions/grib2/tables/local/kwbc/1/4.5.table +++ b/definitions/grib2/tables/local/kwbc/1/4.5.table @@ -1,5 +1,5 @@ # Code table 4.5 - Fixed surface types and units -0 0 Reserved +0 0 Reserved 1 sfc Ground or water surface (-) 2 2 Cloud base level (-) 3 3 Level of cloud tops (-) @@ -16,15 +16,15 @@ 14 14 Level of free convection (LFC) 15 15 Convective condensation level (CCL) 16 16 Level of neutral buoyancy or equilibrium level (LNB) -# 17-19 Reserved +# 17-19 Reserved 20 20 Isothermal level (K) 21 21 Lowest level where mass density exceeds the specified value (base for a given threshold of mass density) (kg m-3) 22 22 Highest level where mass density exceeds the specified value (top for a given threshold of mass density) (kg m-3) 23 23 Lowest level where air concentration exceeds the specified value (base for a given threshold of air concentration) (Bq m-3) 24 24 Highest level where air concentration exceeds the specified value (top for a given threshold of air concentration) (Bq m-3) -# 25-99 Reserved +# 25-99 Reserved 100 pl Isobaric surface (Pa) -101 sfc Mean sea level +101 sfc Mean sea level 102 102 Specific altitude above mean sea level (m) 103 sfc Specified height level above ground (m) 104 104 Sigma level (sigma value) @@ -33,20 +33,20 @@ 107 pt Isentropic (theta) level (K) 108 108 Level at specified pressure difference from ground to level (Pa) 109 pv Potential vorticity surface (K m2 kg-1 s-1) -110 110 Reserved +110 110 Reserved 111 111 Eta level (-) -112 112 Reserved -113 113 Logarithmic hybrid level +112 112 Reserved +113 113 Logarithmic hybrid level 114 114 Snow level (Numeric) 115 115 Sigma height level # 116 Reserved 117 117 Mixed layer depth (m) 118 hhl Hybrid height level (-) 119 hpl Hybrid pressure level (-) -# 120-149 Reserved -150 150 Generalized vertical height coordinate +# 120-149 Reserved +150 150 Generalized vertical height coordinate 151 sol Soil level (Numeric) -# 152-159 Reserved +# 152-159 Reserved 160 160 Depth below sea level (m) 161 161 Depth below water surface (m) 162 162 Lake or river bottom (-) @@ -55,7 +55,7 @@ 165 165 Bottom of sediment layer penetrated by thermal wave (-) 166 166 Mixing layer (-) 167 167 Bottom of root zone (-) -# 168-173 Reserved +# 168-173 Reserved 174 174 Top surface of ice on sea, lake or river 175 175 Top surface of ice, under snow cover, on sea, lake or river 176 176 Bottom surface (underside) ice on sea, lake or river diff --git a/definitions/grib2/template.3.1000.def b/definitions/grib2/template.3.1000.def index e76507aaf..8f825f393 100644 --- a/definitions/grib2/template.3.1000.def +++ b/definitions/grib2/template.3.1000.def @@ -1,6 +1,11 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 3.1000, Cross-section grid, with points equally spaced on the horizontal + +# This template is simply experimental, was not validated at the time of publication +# and should be used only for bilateral previously agreed tests +transient template_is_experimental = 1 : hidden ; + include "grib2/template.3.shape_of_the_earth.def" constant isGridded = true; diff --git a/definitions/grib2/template.3.1100.def b/definitions/grib2/template.3.1100.def index 26fe4a92a..de65bca94 100644 --- a/definitions/grib2/template.3.1100.def +++ b/definitions/grib2/template.3.1100.def @@ -1,6 +1,11 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 3.1100, Hovmoller diagram grid with points equally spaced on the horizontal + +# This template is simply experimental, was not validated at the time of publication +# and should be used only for bilateral previously agreed tests +transient template_is_experimental = 1 : hidden; + include "grib2/template.3.shape_of_the_earth.def" constant isGridded = true; diff --git a/definitions/grib2/template.3.1200.def b/definitions/grib2/template.3.1200.def index 0b7e234ae..06bb38c96 100644 --- a/definitions/grib2/template.3.1200.def +++ b/definitions/grib2/template.3.1200.def @@ -1,6 +1,10 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 3.1200, Time section grid +# This template is simply experimental, was not validated at the time of publication +# and should be used only for bilateral previously agreed tests +transient template_is_experimental = 1 : hidden; + constant isGridded = true; # NT - Number of time steps diff --git a/definitions/grib2/template.3.healpix.def b/definitions/grib2/template.3.healpix.def index bd59c3246..136904194 100644 --- a/definitions/grib2/template.3.healpix.def +++ b/definitions/grib2/template.3.healpix.def @@ -27,13 +27,13 @@ concept orderingConvention(unknown) { "ring" = { ordering = 0; } "nested" = { ordering = 1; } } : dump; -alias geography.pointsOrdering = orderingConvention; +alias geography.orderingConvention = orderingConvention; flags[1] scanningMode 'grib2/tables/[tablesVersion]/3.13.table'; flagbit iScansNegatively(scanningMode,7) : dump; # WMO bit 1 flagbit jScansPositively(scanningMode,6) : dump; # WMO bit 2 -transient iScansPositively = !iScansNegatively : constraint; -transient jScansNegatively = !jScansPositively : constraint; +transient iScansPositively = !iScansNegatively : constraint, read_only; +transient jScansNegatively = !jScansPositively : constraint, read_only; iterator healpix(numberOfPoints,missingValue,values,Nside,orderingConvention); nearest healpix(values,radius,Nx,Ny); diff --git a/definitions/grib2/template.3.scanning_mode.def b/definitions/grib2/template.3.scanning_mode.def index 2eb2ca71e..1be608f41 100644 --- a/definitions/grib2/template.3.scanning_mode.def +++ b/definitions/grib2/template.3.scanning_mode.def @@ -20,8 +20,8 @@ alias geography.iScansNegatively=iScansNegatively; alias geography.jScansPositively=jScansPositively; alias geography.jPointsAreConsecutive=jPointsAreConsecutive; -transient iScansPositively = !iScansNegatively : constraint; -transient jScansNegatively = !jScansPositively : constraint; +transient iScansPositively = !iScansNegatively : constraint, read_only; +transient jScansNegatively = !jScansPositively : constraint, read_only; flagbit scanningMode5(scanningMode,3) = 0: read_only; flagbit scanningMode6(scanningMode,2) = 0: read_only; diff --git a/definitions/grib2/template.4.10.def b/definitions/grib2/template.4.10.def index 1bcd610b0..84b437bdc 100644 --- a/definitions/grib2/template.4.10.def +++ b/definitions/grib2/template.4.10.def @@ -2,6 +2,9 @@ # TEMPLATE 4.10, Percentile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval +# This template was not validated at the time of publication and should be used with caution. +transient template_is_experimental = 1 : hidden; + include "grib2/template.4.parameter.def" include "grib2/template.4.generating_process.def" include "grib2/template.4.forecast_time.def" diff --git a/definitions/grib2/template.4.1000.def b/definitions/grib2/template.4.1000.def index a31654ff5..f179ae483 100644 --- a/definitions/grib2/template.4.1000.def +++ b/definitions/grib2/template.4.1000.def @@ -1,6 +1,9 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 4.1000, Cross section of analysis and forecast at a point in time +# This template is experimental, was not validated at the time of publication +# and should be used only for bilateral previously agreed tests +transient template_is_experimental = 1 : hidden; include "grib2/template.4.parameter.def" include "grib2/template.4.generating_process.def" diff --git a/definitions/grib2/template.4.1001.def b/definitions/grib2/template.4.1001.def index b0e1ca17e..5fafe70f3 100644 --- a/definitions/grib2/template.4.1001.def +++ b/definitions/grib2/template.4.1001.def @@ -1,6 +1,9 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 4.1001, Cross section of averaged or otherwise statistically processed analysis or forecast over a range of time +# This template is experimental, was not validated at the time of publication +# and should be used only for bilateral previously agreed tests +transient template_is_experimental = 1 : hidden; include "grib2/template.4.parameter.def" include "grib2/template.4.generating_process.def" diff --git a/definitions/grib2/template.4.1100.def b/definitions/grib2/template.4.1100.def index 87016a586..ac65bc69f 100644 --- a/definitions/grib2/template.4.1100.def +++ b/definitions/grib2/template.4.1100.def @@ -1,7 +1,9 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 4.1100, Hovmoller-type grid with no averaging or other statistical processing -# This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests +# This template is experimental, was not validated at the time of publication +# and should be used only for bilateral previously agreed tests +transient template_is_experimental = 1 : hidden; include "grib2/template.4.parameter.def" include "grib2/template.4.generating_process.def" diff --git a/definitions/grib2/template.4.1101.def b/definitions/grib2/template.4.1101.def index 6f27693f2..83e46a389 100644 --- a/definitions/grib2/template.4.1101.def +++ b/definitions/grib2/template.4.1101.def @@ -4,6 +4,7 @@ # This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests. # (Octets 35-50 are very similar to octets 43-58 of product definition template 4.8, but the meaning of some fields differs slightly) +transient template_is_experimental = 1 : hidden; include "grib2/template.4.parameter.def" include "grib2/template.4.generating_process.def" diff --git a/definitions/grib2/template.4.119.def b/definitions/grib2/template.4.119.def new file mode 100644 index 000000000..ef464a00f --- /dev/null +++ b/definitions/grib2/template.4.119.def @@ -0,0 +1,10 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.119, Probability forecasts from large ensembles at a horizontal level or in a horizontal layer at a point in time + +include "grib2/template.4.parameter.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.point_in_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.probabilityLargeEnsemble.def" diff --git a/definitions/grib2/template.4.120.def b/definitions/grib2/template.4.120.def new file mode 100644 index 000000000..9ad2f90bd --- /dev/null +++ b/definitions/grib2/template.4.120.def @@ -0,0 +1,10 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.120, Probability forecasts from large ensembles at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval + +include "grib2/template.4.parameter.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.probabilityLargeEnsemble.def" +include "grib2/template.4.statistical.def" diff --git a/definitions/grib2/template.4.121.def b/definitions/grib2/template.4.121.def new file mode 100644 index 000000000..73bba193b --- /dev/null +++ b/definitions/grib2/template.4.121.def @@ -0,0 +1,11 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.121, Probability forecasts with spatiotemporal processing based on focal (moving window) statistics at a horizontal level or in a horizontal layer at a point in time + +include "grib2/template.4.parameter.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.point_in_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.probabilityLargeEnsemble.def" +include "grib2/template.4.focalStatistics.def" diff --git a/definitions/grib2/template.4.122.def b/definitions/grib2/template.4.122.def new file mode 100644 index 000000000..40bf98240 --- /dev/null +++ b/definitions/grib2/template.4.122.def @@ -0,0 +1,11 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.122, Probability forecasts with spatiotemporal processing based on focal (moving window) statistics at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval + +include "grib2/template.4.parameter.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.probabilityLargeEnsemble.def" +include "grib2/template.4.statistical.def" +include "grib2/template.4.focalStatistics.def" diff --git a/definitions/grib2/template.4.123.def b/definitions/grib2/template.4.123.def new file mode 100644 index 000000000..a70b9643c --- /dev/null +++ b/definitions/grib2/template.4.123.def @@ -0,0 +1,12 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.123, Probability forecasts from large ensembles with spatiotemporal processing based on focal (moving window) statistics in relation to a reference period at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval + +include "grib2/template.4.parameter.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.statistical.def" +include "grib2/template.4.probabilityLargeEnsemble.def" +include "grib2/template.4.referenceperiod.def" +include "grib2/template.4.focalStatistics.def" diff --git a/definitions/grib2/template.4.124.def b/definitions/grib2/template.4.124.def new file mode 100644 index 000000000..a3b83980e --- /dev/null +++ b/definitions/grib2/template.4.124.def @@ -0,0 +1,12 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.124, Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for radionuclides + +include "grib2/template.4.parameter.def" +include "grib2/template.4.chemical.def" +include "grib2/template.4.source.def" +include "grib2/template.4.radionuclides.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.point_in_time.def" +include "grib2/template.4.horizontal.def" diff --git a/definitions/grib2/template.4.125.def b/definitions/grib2/template.4.125.def new file mode 100644 index 000000000..88ebd7894 --- /dev/null +++ b/definitions/grib2/template.4.125.def @@ -0,0 +1,13 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.125, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for radionuclides + +include "grib2/template.4.parameter.def" +include "grib2/template.4.chemical.def" +include "grib2/template.4.source.def" +include "grib2/template.4.radionuclides.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.point_in_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.eps.def" diff --git a/definitions/grib2/template.4.126.def b/definitions/grib2/template.4.126.def new file mode 100644 index 000000000..fed3fbac1 --- /dev/null +++ b/definitions/grib2/template.4.126.def @@ -0,0 +1,12 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.126, Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for radionuclides + +include "grib2/template.4.parameter.def" +include "grib2/template.4.chemical.def" +include "grib2/template.4.source.def" +include "grib2/template.4.radionuclides.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.statistical.def" diff --git a/definitions/grib2/template.4.127.def b/definitions/grib2/template.4.127.def new file mode 100644 index 000000000..baa754fca --- /dev/null +++ b/definitions/grib2/template.4.127.def @@ -0,0 +1,14 @@ +# (C) Copyright 2005- ECMWF. + +# TEMPLATE 4.127, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for radionuclides + +include "grib2/template.4.parameter.def" +include "grib2/template.4.chemical.def" +include "grib2/template.4.source.def" +include "grib2/template.4.radionuclides.def" +include "grib2/template.4.generating_process.def" +include "grib2/template.4.forecast_time.def" +include "grib2/template.4.horizontal.def" +include "grib2/template.4.eps.def" +include "grib2/template.4.statistical.def" + diff --git a/definitions/grib2/template.4.20.def b/definitions/grib2/template.4.20.def index b739bf6bb..882691250 100644 --- a/definitions/grib2/template.4.20.def +++ b/definitions/grib2/template.4.20.def @@ -1,60 +1,60 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 4.20, Radar product -codetable[1] parameterCategory ('4.1.[discipline:l].table',masterDir,localDir) : dump; +codetable[1] parameterCategory('4.1.[discipline:l].table',masterDir,localDir) : dump; # Parameter number -codetable[1] parameterNumber ('4.2.[discipline:l].[parameterCategory:l].table',masterDir,localDir) : dump; +codetable[1] parameterNumber('4.2.[discipline:l].[parameterCategory:l].table',masterDir,localDir) : dump; meta parameterUnits codetable_units(parameterNumber) : dump; meta parameterName codetable_title(parameterNumber) : dump; -codetable[1] typeOfGeneratingProcess ('4.3.table',masterDir,localDir) : dump; +codetable[1] typeOfGeneratingProcess('4.3.table',masterDir,localDir) : dump; # Number of radar sites used -unsigned[1] numberOfRadarSitesUsed : dump; +unsigned[1] numberOfRadarSitesUsed : dump; -codetable[1] indicatorOfUnitOfTimeRange ('4.4.table',masterDir,localDir) : dump; -alias indicatorOfUnitForForecastTime = indicatorOfUnitOfTimeRange; +codetable[1] indicatorOfUnitForForecastTime('4.4.table',masterDir,localDir) : dump; +alias indicatorOfUnitOfTimeRange = indicatorOfUnitForForecastTime; include "grib2/stepUnits.def" # Site latitude (in microdegrees) -unsigned[4] siteLatitude : dump; +unsigned[4] siteLatitude : dump; # Site longitude (in microdegrees) -unsigned[4] siteLongitude : dump; +unsigned[4] siteLongitude : dump; # Site elevation (meters) -unsigned[2] siteElevation : dump; +unsigned[2] siteElevation : dump; # Site ID (alphanumeric) -unsigned[4] siteId : dump; +unsigned[4] siteId : dump; # Site ID (numeric) -unsigned[2] siteId : dump; +unsigned[2] siteId : dump; # Operating mode -codetable[1] operatingMode ('4.12.table',masterDir,localDir) : dump; +codetable[1] operatingMode('4.12.table',masterDir,localDir) : dump; # Reflectivity calibration constant (tenths of dB) -unsigned[1] reflectivityCalibrationConstant : dump; +unsigned[1] reflectivityCalibrationConstant : dump; # Quality control indicator -codetable[1] qualityControlIndicator ('4.13.table',masterDir,localDir) : dump; +codetable[1] qualityControlIndicator('4.13.table',masterDir,localDir) : dump; # Clutter filter indicator -codetable[1] clutterFilterIndicator ('4.14.table',masterDir,localDir) : dump; +codetable[1] clutterFilterIndicator('4.14.table',masterDir,localDir) : dump; # Constant antenna elevation angle (tenths of degree true) -unsigned[1] constantAntennaElevationAngle : dump; +unsigned[1] constantAntennaElevationAngle : dump; # Accumulation interval (minutes) -unsigned[2] accumulationInterval : dump; +unsigned[2] accumulationInterval : dump; # Reference reflectivity for echo top (dB) -unsigned[1] referenceReflectivityForEchoTop : dump; +unsigned[1] referenceReflectivityForEchoTop : dump; # Range bin spacing (meters) -unsigned[3] rangeBinSpacing : dump; +unsigned[3] rangeBinSpacing : dump; # Radial angular spacing (tenths of degree true) -unsigned[2] radialAngularSpacing : dump; +unsigned[2] radialAngularSpacing : dump; diff --git a/definitions/grib2/template.4.30.def b/definitions/grib2/template.4.30.def index eef3b680d..9416d4789 100644 --- a/definitions/grib2/template.4.30.def +++ b/definitions/grib2/template.4.30.def @@ -2,6 +2,7 @@ # TEMPLATE 4.30, Satellite Product # Note: This template is deprecated. Template 4.31 should be used instead. +transient template_is_deprecated = 1 : hidden; include "grib2/template.4.parameter.def" diff --git a/definitions/grib2/template.4.44.def b/definitions/grib2/template.4.44.def index fa1bf2d74..1fbadeec8 100644 --- a/definitions/grib2/template.4.44.def +++ b/definitions/grib2/template.4.44.def @@ -2,6 +2,7 @@ # TEMPLATE 4.44, Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for aerosol # It is recommended not to use this template. PDT 4.48 should be used instead with optical wave length range set to missing +transient template_is_deprecated = 1 : hidden; # GRIB-530: Special case for aerosol thanks to WMO error diff --git a/definitions/grib2/template.4.47.def b/definitions/grib2/template.4.47.def index 64c222032..892820635 100644 --- a/definitions/grib2/template.4.47.def +++ b/definitions/grib2/template.4.47.def @@ -2,6 +2,7 @@ # TEMPLATE 4.47, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval # Note: This template is deprecated. Template 4.85 should be used instead. +transient template_is_deprecated = 1 : hidden; include "grib2/template.4.parameter.def" include "grib2/template.4.aerosol.def" diff --git a/definitions/grib2/template.4.56.def b/definitions/grib2/template.4.56.def index 23735e972..9f48c957b 100644 --- a/definitions/grib2/template.4.56.def +++ b/definitions/grib2/template.4.56.def @@ -1,6 +1,6 @@ - # TEMPLATE 4.56, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for spatio-temporal changing tile parameters # Note: This template is deprecated. Template 4.59 should be used instead. +transient template_is_deprecated = 1 : hidden; include "grib2/template.4.parameter.def" include "grib2/template.4.tile.def" diff --git a/definitions/grib2/template.4.7.def b/definitions/grib2/template.4.7.def index fa6f007c8..7c79ced72 100644 --- a/definitions/grib2/template.4.7.def +++ b/definitions/grib2/template.4.7.def @@ -1,2 +1,4 @@ # Note: This template is deprecated. Template 4.0 should be used instead. +transient template_is_deprecated = 1 : hidden; + include "grib2/template.4.0.def" diff --git a/definitions/grib2/template.4.83.def b/definitions/grib2/template.4.83.def index a92e3cfd4..395931e68 100644 --- a/definitions/grib2/template.4.83.def +++ b/definitions/grib2/template.4.83.def @@ -1,7 +1,9 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 4.83, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval with source/sink -# Note: This template is deprecated. Template 4.84 should be used instead. + +# It is recommended not to use this template. Product definition template 4.84 should be used instead because it contains an additional octet to specify the type of generating process +transient template_is_deprecated = 1 : hidden; include "grib2/template.4.parameter.def" include "grib2/template.4.aerosol.def" diff --git a/definitions/grib2/template.4.categorical.def b/definitions/grib2/template.4.categorical.def index 102d50e51..006e46a3a 100644 --- a/definitions/grib2/template.4.categorical.def +++ b/definitions/grib2/template.4.categorical.def @@ -5,10 +5,15 @@ unsigned[1] numberOfCategories : dump; # Categories categories list(numberOfCategories) { - codetable[1] categoryType ('4.91.table',masterDir,localDir): dump; unsigned[1] codeFigure : dump; + codetable[1] categoryType ('4.91.table',masterDir,localDir): dump; unsigned[1] scaleFactorOfLowerLimit : can_be_missing,dump ; unsigned[4] scaledValueOfLowerLimit : can_be_missing,dump ; unsigned[1] scaleFactorOfUpperLimit : can_be_missing,dump; unsigned[4] scaledValueOfUpperLimit : can_be_missing,dump; + + alias scaleFactorOfFirstLimit = scaleFactorOfLowerLimit; + alias scaledValueOfFirstLimit = scaledValueOfLowerLimit; + alias scaleFactorOfSecondLimit = scaleFactorOfUpperLimit; + alias scaledValueOfSecondLimit = scaledValueOfUpperLimit; } diff --git a/definitions/grib2/template.4.focalStatistics.def b/definitions/grib2/template.4.focalStatistics.def new file mode 100644 index 000000000..490919bbc --- /dev/null +++ b/definitions/grib2/template.4.focalStatistics.def @@ -0,0 +1,35 @@ +# (C) Copyright 2005- ECMWF. +codetable[1] spatialVicinityType ('4.103.table',masterDir,localDir)=255 ; + +unsigned[1] numberOfSpatialVicinityValues = 1 : edition_specific; +alias nspatvals = numberOfSpatialVicinityValues; + +spatialVicintiyList list(numberOfSpatialVicinityValues) +{ + # n-th spatial vicinity value + unsigned[4] spatialVicinityValue=0 : dump; +} + +codetable[1] spatialVicinityProcessing ('4.104.table',masterDir,localDir)=255 ; + +signed[2] spatialVicinityProcessingArgument1 = 255 : dump ; + +signed[2] spatialVicinityProcessingArgument2 = 255 : dump ; + +codetable[1] spatialVicinityMissingData ('4.105.table',masterDir,localDir)=0 ; + +## UUID of irregular kernel +#byte[16] uuidOfIrregularKernel : dump; + +## UUID of spatial vicinity weights +#byte[16] uuidOfSpatialVicinityWeights : dump; + +codetable[1] temporalVicinityProcessing ('4.104.table',masterDir,localDir)=255 ; + +codetable[1] temporalVicinityUnit ('4.4.table',masterDir,localDir)=255 ; + +unsigned[4] temporalVicinityTowardsPast : dump; +unsigned[4] temporalVicinityTowardsFuture : dump; + +## UUID of temporal vicinity weights +#byte[16] uuidOfTemporalVicinityWeights : dump; diff --git a/definitions/grib2/template.4.forecast_time.def b/definitions/grib2/template.4.forecast_time.def index c12da70e3..e1c2822d9 100644 --- a/definitions/grib2/template.4.forecast_time.def +++ b/definitions/grib2/template.4.forecast_time.def @@ -9,8 +9,8 @@ unsigned[1] minutesAfterDataCutoff = missing() : edition_specific,can_be_missin alias minutesAfterReferenceTimeOfDataCutoff=minutesAfterDataCutoff; # Indicator of unit for forecastTime (ECC-1709) -codetable[1] indicatorOfUnitOfTimeRange ('4.4.table',masterDir,localDir) : dump; -alias indicatorOfUnitForForecastTime = indicatorOfUnitOfTimeRange; +codetable[1] indicatorOfUnitForForecastTime ('4.4.table',masterDir,localDir) : dump; +alias indicatorOfUnitOfTimeRange = indicatorOfUnitForForecastTime; include "grib2/stepUnits.def" diff --git a/definitions/grib2/template.4.forecast_time_44.def b/definitions/grib2/template.4.forecast_time_44.def index 0b4ad445b..30723622e 100644 --- a/definitions/grib2/template.4.forecast_time_44.def +++ b/definitions/grib2/template.4.forecast_time_44.def @@ -11,8 +11,8 @@ unsigned[1] minutesAfterDataCutoff = missing() : edition_specific,can_be_missin alias minutesAfterReferenceTimeOfDataCutoff=minutesAfterDataCutoff; # Indicator of unit for forecastTime (ECC-1709) -codetable[1] indicatorOfUnitOfTimeRange ('4.4.table',masterDir,localDir) : dump; -alias indicatorOfUnitForForecastTime = indicatorOfUnitOfTimeRange; +codetable[1] indicatorOfUnitForForecastTime ('4.4.table',masterDir,localDir) : dump; +alias indicatorOfUnitOfTimeRange = indicatorOfUnitForForecastTime; include "grib2/stepUnits.def" diff --git a/definitions/grib2/template.4.horizontal.def b/definitions/grib2/template.4.horizontal.def index db0913dbc..2dc64c033 100644 --- a/definitions/grib2/template.4.horizontal.def +++ b/definitions/grib2/template.4.horizontal.def @@ -66,7 +66,9 @@ if (extraDim) { } else { # See GRIB-74 why we store the pressureUnits in a transient transient tempPressureUnits=pressureUnits; - if (!(typeOfLevel is "surface")) { + # Same as typeOfLevel != "surface" but much quicker to evaluate + # than via the concept + if ( ! (typeOfFirstFixedSurface == 1 && typeOfSecondFixedSurface == 255) ) { if (tempPressureUnits is "Pa") { meta marsLevel scale(level,one,hundred) : read_only; alias mars.levelist=marsLevel; @@ -77,7 +79,8 @@ if (extraDim) { # ECC-1333: levtype should be read-only in GRIB2 concept mars.levtype(unknown,"marsLevtypeConcept.def",conceptsDir2,conceptsDir1):no_copy, read_only; # GRIB-372: levelist alias does not pertain to surface parameters - if (levtype is "sfc" || levtype is "o2d") { + transient tempLevtype = levtype; # Faster to copy the concept so we evaluate it once + if (tempLevtype is "sfc" || tempLevtype is "o2d") { unalias mars.levelist; } } diff --git a/definitions/grib2/template.4.localtime.def b/definitions/grib2/template.4.localtime.def index 96d655d68..336d90068 100644 --- a/definitions/grib2/template.4.localtime.def +++ b/definitions/grib2/template.4.localtime.def @@ -34,7 +34,7 @@ localTimeForecastList list(numberOfForecastsUsedInLocalTime) unsigned[1] secondOfForecastUsedInLocalTime=0 : dump, edition_specific; # Indicator of unit of time for ForecastTime - codetable[1] indicatorOfUnitForForecastTime ('4.4.table',masterDir,localDir)=1 : dump; + codetable[1] indicatorOfUnitForForecastTime('4.4.table',masterDir,localDir)=1 : dump; # Length of the time range over which statistical processing is done, in units defined by the previous octet unsigned[4] forecastTime=0 : dump; @@ -43,7 +43,7 @@ localTimeForecastList list(numberOfForecastsUsedInLocalTime) unsigned[1] numberOfTimeIncrementsOfForecastsUsedInLocalTime=1 : dump; # Indicator of unit of time for the increment between the successive steps used - codetable[1] indicatorOfUnitForTimeIncrement ('4.4.table',masterDir,localDir)=255 : dump; + codetable[1] indicatorOfUnitForTimeIncrement('4.4.table',masterDir,localDir)=255 : dump; # Time increment between successive fields, in units defined by the previous octet unsigned[4] timeIncrement=0 : dump; diff --git a/definitions/grib2/template.4.optical.def b/definitions/grib2/template.4.optical.def index 385513edc..71dcf77e0 100644 --- a/definitions/grib2/template.4.optical.def +++ b/definitions/grib2/template.4.optical.def @@ -15,5 +15,5 @@ alias firstWavelengthInMetres = firstWavelength; alias secondWavelengthInMetres = secondWavelength; constant billion = 1000000000 : hidden; -meta firstWavelengthInNanometres multdouble(firstWavelength, billion); -meta secondWavelengthInNanometres multdouble(secondWavelength, billion); +meta firstWavelengthInNanometres multdouble(firstWavelength, billion) : read_only; +meta secondWavelengthInNanometres multdouble(secondWavelength, billion) : read_only; diff --git a/definitions/grib2/template.4.probabilityLargeEnsemble.def b/definitions/grib2/template.4.probabilityLargeEnsemble.def new file mode 100644 index 000000000..cb309e4a9 --- /dev/null +++ b/definitions/grib2/template.4.probabilityLargeEnsemble.def @@ -0,0 +1,27 @@ +# (C) Copyright 2005- ECMWF. + +# Type of ensemble forecast +codetable[1] typeOfEnsembleForecast ('4.6.table',masterDir,localDir) = 255 : dump; + +# Number of forecasts in ensemble +unsigned[4] numberOfForecastsInEnsemble : dump; +alias totalNumber=numberOfForecastsInEnsemble; + +unsigned[1] forecastProbabilityNumber : dump; + +unsigned[1] totalNumberOfForecastProbabilities : dump; + +codetable[1] probabilityType ('4.9.table',masterDir,localDir) : dump; +meta probabilityTypeName codetable_title(probabilityType): read_only; + +signed[1] scaleFactorOfLowerLimit : can_be_missing,dump ; +signed[4] scaledValueOfLowerLimit : can_be_missing,dump ; + +meta lowerLimit from_scale_factor_scaled_value( + scaleFactorOfLowerLimit, scaledValueOfLowerLimit): can_be_missing; + +signed[1] scaleFactorOfUpperLimit : can_be_missing,dump; +signed[4] scaledValueOfUpperLimit : can_be_missing,dump; + +meta upperLimit from_scale_factor_scaled_value( + scaleFactorOfUpperLimit, scaledValueOfUpperLimit): can_be_missing; diff --git a/definitions/grib2/template.4.radionuclides.def b/definitions/grib2/template.4.radionuclides.def new file mode 100644 index 000000000..c51ffa6c1 --- /dev/null +++ b/definitions/grib2/template.4.radionuclides.def @@ -0,0 +1,23 @@ +# (C) Copyright 2005- ECMWF + +codetable[2] transportModelUsed ('4.333.table',masterDir,localDir) = 255 : dump; + +codetable[2] requestedByEntity 'common/c-11.table' : dump,string_type; + +codetable[2] scenarioOrigin ('4.335.table',masterDir,localDir) = 255 : dump; + +codetable[2] NWPused ('4.336.table',masterDir,localDir) = 255 : dump; + +unsigned[2] releaseStartYear : dump; +unsigned[1] releaseStartMonth : dump; +unsigned[1] releaseStartDay : dump; +unsigned[1] releaseStartHour : dump; +unsigned[1] releaseStartMinute : dump; +unsigned[1] releaseStartSecond : dump; + +unsigned[2] wallClockInitialTimeOfExecutionYear : dump; +unsigned[1] wallClockInitialTimeOfExecutionMonth : dump; +unsigned[1] wallClockInitialTimeOfExecutionDay : dump; +unsigned[1] wallClockInitialTimeOfExecutionHour : dump; +unsigned[1] wallClockInitialTimeOfExecutionMinute : dump; +unsigned[1] wallClockInitialTimeOfExecutionSecond : dump; diff --git a/definitions/grib2/template.4.referenceperiod.def b/definitions/grib2/template.4.referenceperiod.def index 90c05351f..49a45d571 100644 --- a/definitions/grib2/template.4.referenceperiod.def +++ b/definitions/grib2/template.4.referenceperiod.def @@ -1,10 +1,11 @@ -# Type of reference dataset +# (C) Copyright 2005- ECMWF. +# Type of reference dataset codetable[1] typeOfReferenceDataset ('4.100.table',masterDir,localDir) = 255 : dump,edition_specific; -# Type of relation to reference dataset +# Type of relation to reference dataset codetable[1] typeOfRelationToReferenceDataset ('4.101.table',masterDir,localDir) = 255 : dump,edition_specific; -# number of additional parameters +# Number of additional parameters unsigned[1] numberOfAdditionalParametersForReferencePeriod=0 ; additionalParameter list(numberOfAdditionalParametersForReferencePeriod) { @@ -32,7 +33,7 @@ meta startDateOfReferencePeriod g2date(yearOfStartOfReferencePeriod,monthOfStart unsigned[4] sampleSizeOfReferencePeriod = 0; -# n - number of time range specifications describing the time intervals used to calculate the statistically-processed field +# Number of time range specifications describing the time intervals used to calculate the statistically-processed field unsigned[1] numberOfReferencePeriodTimeRanges = 1 : edition_specific; alias nref = numberOfReferencePeriodTimeRanges; diff --git a/definitions/grib2/template.4.reforecast.def b/definitions/grib2/template.4.reforecast.def index f415ce80a..a8a431936 100644 --- a/definitions/grib2/template.4.reforecast.def +++ b/definitions/grib2/template.4.reforecast.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. # The Model Version Date # This is the date when the reforecast is produced with a particular version of the model diff --git a/definitions/grib2/template.4.wave.def b/definitions/grib2/template.4.wave.def index 37c3f4523..742c0ece4 100644 --- a/definitions/grib2/template.4.wave.def +++ b/definitions/grib2/template.4.wave.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. # Template for wave parameters ## Direction part diff --git a/definitions/grib2/template.4.wave_period_range.def b/definitions/grib2/template.4.wave_period_range.def index 3bd02fa4f..278ddf689 100644 --- a/definitions/grib2/template.4.wave_period_range.def +++ b/definitions/grib2/template.4.wave_period_range.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. # Template for wave parameters defined on a certain period range # Type of period interval diff --git a/definitions/grib2/template.4.wave_spectra_formula.def b/definitions/grib2/template.4.wave_spectra_formula.def index c0893da1a..4a5e61fdd 100644 --- a/definitions/grib2/template.4.wave_spectra_formula.def +++ b/definitions/grib2/template.4.wave_spectra_formula.def @@ -1,3 +1,4 @@ +# (C) Copyright 2005- ECMWF. # Template for wave spectra defined using a formula for frequency and direction ## Direction part diff --git a/definitions/grib2/template.4.wave_spectra_list.def b/definitions/grib2/template.4.wave_spectra_list.def index 85fa6fc7d..ca7768604 100644 --- a/definitions/grib2/template.4.wave_spectra_list.def +++ b/definitions/grib2/template.4.wave_spectra_list.def @@ -1,3 +1,5 @@ +# (C) Copyright 2005- ECMWF. + # Template for wave spectra defined using an array of frequencies and directions ## Direction part diff --git a/definitions/grib2/template.5.1.def b/definitions/grib2/template.5.1.def index 8f1c22bea..14864c9f5 100644 --- a/definitions/grib2/template.5.1.def +++ b/definitions/grib2/template.5.1.def @@ -1,8 +1,9 @@ # (C) Copyright 2005- ECMWF. # TEMPLATE 5.1, Matrix values at grid point - simple packing -# Preliminary note: + # This template was not validated at the time of publication and should be used with caution +transient template_is_experimental = 1 : hidden; include "grib2/template.5.packing.def" diff --git a/definitions/grib2/template.5.61.def b/definitions/grib2/template.5.61.def index 9c8e73a9e..f19db39ee 100644 --- a/definitions/grib2/template.5.61.def +++ b/definitions/grib2/template.5.61.def @@ -2,8 +2,9 @@ # TEMPLATE 5.61, Grid point data - Simple packing with logarithmic preprocessing -# Note from WMO document: # This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests +transient template_is_experimental = 1 : hidden; + constant typeOfPreProcessing = 1; include "grib2/template.5.packing.def" diff --git a/definitions/grib2/template.7.1.def b/definitions/grib2/template.7.1.def index 7d49264b1..1426d4fe7 100644 --- a/definitions/grib2/template.7.1.def +++ b/definitions/grib2/template.7.1.def @@ -1,6 +1,8 @@ # (C) Copyright 2005- ECMWF. -# TEMPLATE 7.1, Matrix values at grid point -simple packing +# TEMPLATE 7.1, Matrix values at grid point - simple packing +# This template was not validated at the time of publication and should be used with caution +transient template_is_experimental = 1 : hidden; meta codedValues data_g2simple_packing( section7Length, diff --git a/definitions/grib2/template.7.61.def b/definitions/grib2/template.7.61.def index 328afbcaa..6f7f3fdd6 100644 --- a/definitions/grib2/template.7.61.def +++ b/definitions/grib2/template.7.61.def @@ -4,6 +4,7 @@ # Note from WMO document: # This template is experimental, was not validated at the time of publication and should be used only for bilateral previously agreed tests +transient template_is_deprecated = 1 : hidden; meta codedValues data_g2simple_packing_with_preprocessing( section7Length, diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index d96d6bd9e..4a6bde706 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -1239,12 +1239,6 @@ parameterCategory = 0 ; parameterNumber = 52 ; } -#Envelope-maximum individual wave height -'m' = { - discipline = 10 ; - parameterCategory = 0 ; - parameterNumber = 93 ; - } #Time domain maximum individual crest height 'm' = { discipline = 10 ; @@ -1305,6 +1299,34 @@ parameterCategory = 0 ; parameterNumber = 84 ; } +#Time-mean mean zero-crossing wave period +'s' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 28 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean significant height of combined wind waves and swell +'m' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 3 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean peak wave period +'s' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 34 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean mean wave period +'s' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 15 ; + typeOfStatisticalProcessing = 0 ; + } #Mean sea water temperature in the upper 300 m 'K' = { discipline = 10 ; @@ -3786,6 +3808,71 @@ typeOfFirstFixedSurface = 187 ; typeOfSecondFixedSurface = 185 ; } +#Convective snowfall water equivalent +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 55 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Large-scale snowfall water equivalent +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 56 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 1 ; + } +#Lake surface temperature +'K' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 255 ; + } +#Surface bulk Richardson number +'Numeric' = { + discipline = 0 ; + parameterCategory = 7 ; + parameterNumber = 16 ; + typeOfFirstFixedSurface = 1 ; + } +#Time-maximum 2 metre relative humidity +'%' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 2 ; + } +#Time-minimum 2 metre relative humidity +'%' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 3 ; + } +#Surface roughness for heat +'m' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 47 ; + typeOfFirstFixedSurface = 1 ; + } +#Surface roughness for moisture +'m' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 48 ; + typeOfFirstFixedSurface = 1 ; + } #Burned area '%' = { discipline = 2 ; @@ -4707,6 +4794,285 @@ typeOfFirstFixedSurface = 1 ; typeOfStatisticalProcessing = 0 ; } +#Time-mean snow density +'kg m**-3' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 61 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean low vegetation cover +'(0 - 1)' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 53 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean high vegetation cover +'(0 - 1)' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 54 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean sea ice area fraction +'(0 - 1)' = { + discipline = 10 ; + parameterCategory = 2 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean sea surface temperature +'K' = { + discipline = 10 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean leaf area index, low vegetation +'m**2 m**-2' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 55 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean leaf area index, high vegetation +'m**2 m**-2' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 56 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total column liquid water +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 69 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total column cloud ice water +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 70 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 2 metre specific humidity +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 103 ; + typeOfSecondFixedSurface = 255 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean lake mix-layer temperature +'K' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 166 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean lake mix-layer depth +'m' = { + discipline = 1 ; + parameterCategory = 2 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 166 ; + typeOfSecondFixedSurface = 255 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 2 metre relative humidity +'%' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean fraction of snow cover +'Proportion' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 121 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean soil temperature +'K' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow depth +'m' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 11 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean snow cover +'%' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 42 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean geopotential +'m**2 s**-2' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 4 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean temperature +'K' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean U component of wind +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean V component of wind +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean specific humidity +'kg kg**-1' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean surface pressure +'Pa' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean vertical velocity +'Pa s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total column water +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 51 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean total column vertically-integrated water vapour +'kg m**-2' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 64 ; + typeOfFirstFixedSurface = 1 ; + typeOfSecondFixedSurface = 8 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean mean sea level pressure +'Pa' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 0 ; + typeOfFirstFixedSurface = 101 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean relative humidity +'%' = { + discipline = 0 ; + parameterCategory = 1 ; + parameterNumber = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean boundary layer height +'m' = { + discipline = 0 ; + parameterCategory = 3 ; + parameterNumber = 18 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 10 metre U wind component +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 2 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 10 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 10 metre V wind component +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 3 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 10 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean 2 metre dewpoint temperature +'K' = { + discipline = 0 ; + parameterCategory = 0 ; + parameterNumber = 6 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 2 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean temperature of snow layer +'K' = { + discipline = 2 ; + parameterCategory = 3 ; + parameterNumber = 28 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast surface roughness +'m' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } +#Time-mean forecast logarithm of surface roughness for heat +'Numeric' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 54 ; + typeOfFirstFixedSurface = 1 ; + typeOfStatisticalProcessing = 0 ; + } #Cross sectional area of flow in channel 'm**2' = { discipline = 1 ; @@ -6442,6 +6808,13 @@ parameterCategory = 3 ; parameterNumber = 19 ; } +#Leaf Area Index +'Numeric' = { + discipline = 2 ; + parameterCategory = 0 ; + parameterNumber = 28 ; + typeOfFirstFixedSurface = 1 ; + } #Accumulated surface upward short-wave radiation flux, clear sky 'J m**-2' = { discipline = 0 ; @@ -6795,6 +7168,48 @@ typeOfFirstFixedSurface = 1 ; typeOfSecondFixedSurface = 8 ; } +#Standardised Precipitation Index (SPI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 0 ; + } +#Standardised Precipitation Evapotranspiration Index (SPEI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 1 ; + } +#Standardised Streamflow Index (SSFI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 2 ; + } +#Standardised Reservoir Supply Index (SRSI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 3 ; + } +#Standardised Water-level Index (SWI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 4 ; + } +#Standardised Snowmelt and Rain Index (SMRI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 5 ; + } +#Streamflow Drought Index (SDI) +'Numeric' = { + discipline = 0 ; + parameterCategory = 22 ; + parameterNumber = 6 ; + } #Universal thermal climate index 'K' = { discipline = 20 ; @@ -9821,18 +10236,6 @@ parameterCategory = 2 ; parameterNumber = 16 ; } -#U-component of current -'m s**-1' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 2 ; - } -#V-component of current -'m s**-1' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 3 ; - } #Precipitable water 'kg m**-2' = { discipline = 0 ; @@ -10007,11 +10410,11 @@ parameterCategory = 0 ; parameterNumber = 23 ; } -#Maximum individual wave height +#Envelop-maximum individual wave height 'm' = { discipline = 10 ; parameterCategory = 0 ; - parameterNumber = 24 ; + parameterNumber = 93 ; } #Model bathymetry 'm' = { @@ -10199,20 +10602,6 @@ parameterCategory = 0 ; parameterNumber = 44 ; } -#Eastward sea water velocity -'m s**-1' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 2 ; - typeOfFirstFixedSurface = 160 ; - } -#Northward sea water velocity -'m s**-1' = { - discipline = 10 ; - parameterCategory = 1 ; - parameterNumber = 3 ; - typeOfFirstFixedSurface = 160 ; - } #Skin reservoir content 'kg m**-2' = { discipline = 2 ; @@ -10518,6 +10907,16 @@ scaleFactorOfFirstFixedSurface = 0 ; typeOfStatisticalProcessing = 0 ; } +#Mean of 10 metre wind speed +'m s**-1' = { + discipline = 0 ; + parameterCategory = 2 ; + parameterNumber = 1 ; + typeOfFirstFixedSurface = 103 ; + scaledValueOfFirstFixedSurface = 10 ; + scaleFactorOfFirstFixedSurface = 0 ; + typeOfStatisticalProcessing = 0 ; + } #Lake total depth 'm' = { discipline = 1 ; diff --git a/definitions/grib2/units.legacy.def b/definitions/grib2/units.legacy.def index f05dae694..e3e8e590e 100644 --- a/definitions/grib2/units.legacy.def +++ b/definitions/grib2/units.legacy.def @@ -174,3 +174,9 @@ typeOfSecondFixedSurface = 168 ; typeOfStatisticalProcessing = 0 ; } +#Maximum individual wave height +'m' = { + discipline = 10 ; + parameterCategory = 0 ; + parameterNumber = 24 ; +} diff --git a/definitions/grib3/template.4.scanning_mode.def b/definitions/grib3/template.4.scanning_mode.def index 4fcd2fabb..31414321f 100644 --- a/definitions/grib3/template.4.scanning_mode.def +++ b/definitions/grib3/template.4.scanning_mode.def @@ -20,7 +20,7 @@ alias geography.iScansNegatively=iScansNegatively; alias geography.jScansPositively=jScansPositively; alias geography.jPointsAreConsecutive=jPointsAreConsecutive; -transient iScansPositively = !iScansNegatively : constraint; +transient iScansPositively = !iScansNegatively : constraint, read_only; flagbit scanningMode5(scanningMode,3) = 0: read_only; flagbit scanningMode6(scanningMode,2) = 0: read_only; diff --git a/definitions/mars/class.table b/definitions/mars/class.table index efe2be6b1..bb740e63a 100644 --- a/definitions/mars/class.table +++ b/definitions/mars/class.table @@ -50,6 +50,7 @@ 49 gh C3S Global hydrology 50 ci CERISE project 51 ai Operational AIFS +52 ed EERIE project 99 te Test 100 at Austria 101 be Belgium diff --git a/definitions/mars/grib.mmsf.fc.def b/definitions/mars/grib.mmsf.fc.def index f1820336a..c002f9d76 100644 --- a/definitions/mars/grib.mmsf.fc.def +++ b/definitions/mars/grib.mmsf.fc.def @@ -8,6 +8,7 @@ if (class is "od") { alias mars.system = systemNumber; } if (class is "me") { alias mars.system = systemNumber; } if (class is "en") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } +if (class is "ci") { alias mars.system = systemNumber; } alias mars.number = perturbationNumber; alias mars.method = methodNumber; diff --git a/definitions/mars/grib.msmm.fcmean.def b/definitions/mars/grib.msmm.fcmean.def index 800a49134..a13ca9918 100644 --- a/definitions/mars/grib.msmm.fcmean.def +++ b/definitions/mars/grib.msmm.fcmean.def @@ -10,6 +10,7 @@ if (class is "od") { alias mars.system = systemNumber; } if (class is "me") { alias mars.system = systemNumber; } if (class is "en") { alias mars.system = systemNumber; } if (class is "c3") { alias mars.system = systemNumber; } +if (class is "ci") { alias mars.system = systemNumber; } # See ECC-624 if (centre == 80 && subCentre == 98 && class is "c3") { diff --git a/definitions/param_limits.def b/definitions/param_limits.def index 1bbcd18d6..215cbfec0 100644 --- a/definitions/param_limits.def +++ b/definitions/param_limits.def @@ -18,6 +18,7 @@ concept param_value_min(default_min_val) { -60000 = { paramId=228001; } 0 = { paramId=151163; } -3.5 = { paramId=151131; } + -3.5 = { paramId=262140; } -10 = { paramId=260259; } -13000 = { paramId=129; } -1300 = { paramId=156; } @@ -103,6 +104,7 @@ concept param_value_max(default_max_val) { 1000 = { paramId=228001; } 1500 = { paramId=151163; } 3.5 = { paramId=151131; } + 3.5 = { paramId=262140; } 5 = { paramId=260259; } 3500000 = { paramId=129; } 35000 = { paramId=156; } diff --git a/.travis.yml b/deprecated/.travis.yml similarity index 100% rename from .travis.yml rename to deprecated/.travis.yml diff --git a/examples/C/grib_clone.c b/examples/C/grib_clone.c index d54ab4440..c2964b54a 100644 --- a/examples/C/grib_clone.c +++ b/examples/C/grib_clone.c @@ -68,7 +68,7 @@ int main(int argc, char* argv[]) CODES_CHECK(codes_get_message(clone_handle, &buffer, &size), 0); /* write the buffer to a file */ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(argv[2]); return 1; } codes_handle_delete(clone_handle); diff --git a/examples/C/grib_multi.c b/examples/C/grib_multi.c index 24479075d..617c30a71 100644 --- a/examples/C/grib_multi.c +++ b/examples/C/grib_multi.c @@ -30,12 +30,12 @@ int main(int argc, char** argv) codes_handle* h = NULL; int mcount = 0; + /* turn off support for GRIB2 multi-field messages */ + codes_grib_multi_support_off(NULL); + /* turn on support for GRIB2 multi-field messages */ codes_grib_multi_support_on(NULL); - /* turn off support for GRIB2 multi-field messages */ - /* codes_multi_support_off(NULL); */ - in = fopen(filename, "rb"); if (!in) { fprintf(stderr, "Error: unable to open file %s\n", filename); diff --git a/examples/C/grib_multi_write.c b/examples/C/grib_multi_write.c index b68df1517..d0f275c58 100644 --- a/examples/C/grib_multi_write.c +++ b/examples/C/grib_multi_write.c @@ -72,7 +72,7 @@ int main(int argc, char** argv) } /* open output file */ - of = fopen(ofilename, "w"); + of = fopen(ofilename, "wb"); if (!of) { fprintf(stderr, "ERROR: unable to open output file %s\n", ofilename); exit(1); diff --git a/examples/C/grib_multi_write.sh b/examples/C/grib_multi_write.sh index a6a621a59..73942c663 100755 --- a/examples/C/grib_multi_write.sh +++ b/examples/C/grib_multi_write.sh @@ -9,20 +9,20 @@ . ./include.ctest.sh -#if [ ! -f "${data_dir}/sample.grib2" ] -#then -# echo SKIP: $0 -# exit -#fi +label="grib_multi_write_c" +tempGrib=temp.$label.grib +tempText=temp.$label.txt -${examples_dir}/c_grib_multi_write ${data_dir}/sample.grib2 ${data_dir}/multi_sample.grib2 > /dev/null +${examples_dir}/c_grib_multi_write ${data_dir}/sample.grib2 $tempGrib > /dev/null -${tools_dir}/grib_get -p step ${data_dir}/multi_sample.grib2 > ${data_dir}/multi_step.test +${tools_dir}/grib_get -p step $tempGrib > $tempText -diff ${data_dir}/multi_step.test ${data_dir}/multi_step.txt - -step=`${tools_dir}/grib_get -M -p step ${data_dir}/multi_sample.grib2` +reference=${data_dir}/multi_step.txt +diff $reference $tempText +# -M = Turn multi-field support off +step=`${tools_dir}/grib_get -M -p step $tempGrib` [ $step -eq 12 ] -rm -f ${data_dir}/multi_sample.grib2 ${data_dir}/multi_step.test +# Clean up +rm -f $tempGrib $tempText diff --git a/examples/C/grib_precision.c b/examples/C/grib_precision.c index ae39318b2..4f3657610 100644 --- a/examples/C/grib_precision.c +++ b/examples/C/grib_precision.c @@ -116,7 +116,7 @@ int main(int argc, char** argv) /* write the buffer in a file*/ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(outfile); exit(1); } diff --git a/examples/C/grib_pthreads.c b/examples/C/grib_pthreads.c index 2dce9a4cd..eab0a5e74 100644 --- a/examples/C/grib_pthreads.c +++ b/examples/C/grib_pthreads.c @@ -9,11 +9,22 @@ */ #include -#include "grib_api_internal.h" +#include +#include +/*#include "grib_api_internal.h"*/ #include "eccodes.h" #define NUM_THREADS 4 +void Assert(int condition) +{ + if (!condition) { + printf("Assertion failed\n"); + exit(1); + } +} + + /* Return 0 if numbers considered equal, otherwise 1 */ static int compare_doubles(double a, double b, double tolerance) { @@ -40,7 +51,7 @@ static void* process_grib(void* threadID) ProductKind prod_kind = 0; codes_handle* h = codes_grib_handle_new_from_samples(0, "regular_ll_pl_grib2"); - Assert(h); + Assert(h != NULL); CODES_CHECK(codes_get_product_kind(h, &prod_kind), 0); Assert(prod_kind == PRODUCT_GRIB); printf("Thread %ld running\n", tid); diff --git a/examples/C/grib_set_keys.c b/examples/C/grib_set_keys.c index feea6731a..50aeff372 100644 --- a/examples/C/grib_set_keys.c +++ b/examples/C/grib_set_keys.c @@ -78,7 +78,7 @@ int main(int argc, char** argv) /* write the buffer in a file*/ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(outfile); exit(1); } diff --git a/examples/C/grib_set_missing.c b/examples/C/grib_set_missing.c index 82f698975..98395c120 100644 --- a/examples/C/grib_set_missing.c +++ b/examples/C/grib_set_missing.c @@ -77,7 +77,7 @@ int main(int argc, char** argv) /* write the buffer in a file*/ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(outfile); exit(1); } diff --git a/examples/C/grib_set_pv.c b/examples/C/grib_set_pv.c index 7ca4c32fe..e279aec8b 100644 --- a/examples/C/grib_set_pv.c +++ b/examples/C/grib_set_pv.c @@ -78,7 +78,7 @@ int main(int argc, char** argv) /* write the buffer in a file*/ if (fwrite(buffer, 1, size, out) != size) { - perror(argv[1]); + perror(outfile); exit(1); } diff --git a/examples/C/large_grib1.c b/examples/C/large_grib1.c index a01761ced..3131ead64 100644 --- a/examples/C/large_grib1.c +++ b/examples/C/large_grib1.c @@ -14,7 +14,7 @@ #include "eccodes.h" /* See JIRA issue GRIB-361 */ -int main() +int main(void) { const int ni = 2880; const int nj = 2880; diff --git a/examples/C/new_sample.c b/examples/C/new_sample.c index 9560e3924..82524b022 100644 --- a/examples/C/new_sample.c +++ b/examples/C/new_sample.c @@ -25,8 +25,7 @@ int main(int argc, char** argv) exit(1); } - /* h = codes_grib_handle_new_from_samples(NULL, "GRIB2"); */ - h = codes_handle_new_from_samples(NULL, "just a test"); + h = codes_handle_new_from_samples(NULL, "nonexistentsample"); if (h) return 1; h = codes_handle_new_from_samples(NULL, "GRIB2"); @@ -148,12 +147,6 @@ int main(int argc, char** argv) CODES_CHECK(codes_set_long(h, "jScansPositively", 0), 0); CODES_CHECK(codes_set_long(h, "jPointsAreConsecutive", 0), 0); CODES_CHECK(codes_set_long(h, "alternativeRowScanning", 0), 0); - CODES_CHECK(codes_set_long(h, "iScansPositively", 1), 0); - - /* ITERATOR */ - - - /* NEAREST */ CODES_CHECK(codes_set_long(h, "timeRangeIndicator", 0), 0); CODES_CHECK(codes_set_long(h, "NV", 0), 0); @@ -165,15 +158,12 @@ int main(int argc, char** argv) /* Parameter information */ - /* 0 = Temperature (grib2/tables/4/4.1.0.table) */ CODES_CHECK(codes_set_long(h, "parameterCategory", 0), 0); - /* 0 = Temperature (K) (grib2/tables/4/4.2.0.0.table) */ CODES_CHECK(codes_set_long(h, "parameterNumber", 0), 0); - /* 0 = Analysis (grib2/tables/4/4.3.table) */ CODES_CHECK(codes_set_long(h, "typeOfGeneratingProcess", 0), 0); @@ -185,7 +175,6 @@ int main(int argc, char** argv) /* 1 = Hour (grib2/tables/4/4.4.table) */ CODES_CHECK(codes_set_long(h, "indicatorOfUnitOfTimeRange", 1), 0); - /* 1 = Hour (stepUnits.table) */ CODES_CHECK(codes_set_long(h, "stepUnits", 1), 0); @@ -226,7 +215,6 @@ int main(int argc, char** argv) /* grib 2 Section 6 BIT-MAP SECTION */ - /* 255 = A bit map does not apply to this product (grib2/tables/4/6.0.table) */ CODES_CHECK(codes_set_long(h, "bitMapIndicator", 255), 0); diff --git a/examples/F90/bufr_ecc-1019.f90 b/examples/F90/bufr_ecc-1019.f90 index 5974132e6..8bbceb900 100644 --- a/examples/F90/bufr_ecc-1019.f90 +++ b/examples/F90/bufr_ecc-1019.f90 @@ -18,7 +18,6 @@ program operator_3_test call codes_bufr_new_from_samples(ibufr,'BUFR4',iret) if (iret /= CODES_SUCCESS) then - print *,'ERROR creating BUFR from BUFR4' stop 1 endif diff --git a/examples/F90/bufr_ecc-1284.f90 b/examples/F90/bufr_ecc-1284.f90 index 69600a1c7..53b18b7c5 100644 --- a/examples/F90/bufr_ecc-1284.f90 +++ b/examples/F90/bufr_ecc-1284.f90 @@ -22,7 +22,6 @@ program bufr_encode call codes_bufr_new_from_samples(ibufr,'BUFR4',iret) if (iret/=CODES_SUCCESS) then - print *,'ERROR creating BUFR from BUFR4' stop 1 endif call codes_set(ibufr,'masterTableNumber',0) diff --git a/examples/F90/codes_dump.f90 b/examples/F90/codes_dump.f90 index b68c68e51..ab547ec04 100644 --- a/examples/F90/codes_dump.f90 +++ b/examples/F90/codes_dump.f90 @@ -12,7 +12,7 @@ program codes_dump_test implicit none integer :: ifile, iret, msgid integer :: product_kind - character(len=10) :: product_string + character(len=512) :: product_string character(len=512) :: infile_name call getarg(1, product_string) diff --git a/examples/F90/grib_count_messages_multi.f90 b/examples/F90/grib_count_messages_multi.f90 index 5e4fe92d9..67178fa6f 100644 --- a/examples/F90/grib_count_messages_multi.f90 +++ b/examples/F90/grib_count_messages_multi.f90 @@ -13,10 +13,10 @@ program grib_count_messages_multi use eccodes implicit none - integer :: ifile - character(len=100) :: grib_file - integer :: n, stat - character(len=1) :: multi_flag + integer :: ifile + character(len=100) :: multi_flag + character(len=100) :: grib_file + integer :: n, stat call getarg(1, multi_flag) call getarg(2, grib_file) diff --git a/examples/F90/grib_read_bytes.f90 b/examples/F90/grib_read_bytes.f90 index 950eb2924..c118bdab4 100644 --- a/examples/F90/grib_read_bytes.f90 +++ b/examples/F90/grib_read_bytes.f90 @@ -7,7 +7,7 @@ ! virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. ! ! -program grib_read_bytes +program read_bytes use eccodes implicit none integer :: ifile diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index 979ad0652..66b6e598f 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -42,7 +42,7 @@ if( HAVE_FORTRAN ) # Note: $ will be present only while building (for the whole bundle), # whereas $ is only present once you install the package / bundle ecbuild_add_library( TARGET eccodes_f90 - SOURCES grib_fortran.c grib_f90.f90 eccodes_f90.f90 grib_kinds.h + SOURCES grib_fortran.cc grib_f90.f90 eccodes_f90.f90 grib_kinds.h GENERATED grib_f90.f90 eccodes_f90.f90 PUBLIC_INCLUDES $ $ diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.cc similarity index 97% rename from fortran/grib_fortran.c rename to fortran/grib_fortran.cc index e1835ae47..972118384 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.cc @@ -9,6 +9,7 @@ */ #include "grib_api_internal.h" +#include "grib_fortran_prototypes.h" #if HAVE_SYS_TYPES_H # include @@ -41,7 +42,7 @@ static pthread_mutex_t multi_handle_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t iterator_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t keys_iterator_mutex = PTHREAD_MUTEX_INITIALIZER; -static void init() { +static void init(void) { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); @@ -986,7 +987,7 @@ void grib_f_write_on_fail(int* gid) { file_count++; GRIB_MUTEX_UNLOCK(&handle_mutex) - sprintf(filename,"%ld_%d_error.grib",(long)pid,file_count); + snprintf(filename, sizeof(filename), "%ld_%d_error.grib",(long)pid,file_count); h=get_handle(*gid); if (h) grib_write_message(h,filename,"w"); @@ -996,13 +997,13 @@ void grib_f_write_on_fail_(int* gid) { grib_f_write_on_fail(gid); } /*****************************************************************************/ -int grib_f_multi_support_on_() +int grib_f_multi_support_on_(void) { grib_multi_support_on(0); return GRIB_SUCCESS; } -int grib_f_multi_support_off_() +int grib_f_multi_support_off_(void) { grib_multi_support_off(0); return GRIB_SUCCESS; @@ -1181,13 +1182,13 @@ int grib_f_keys_iterator_delete_(int* iterid) } /*****************************************************************************/ -int grib_f_gribex_mode_on_() +int grib_f_gribex_mode_on_(void) { grib_gribex_mode_on(0); return GRIB_SUCCESS; } -int grib_f_gribex_mode_off_() +int grib_f_gribex_mode_off_(void) { grib_gribex_mode_off(0); return GRIB_SUCCESS; @@ -1249,7 +1250,7 @@ int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) fort_char_clean(name, len); - sprintf(buf,"%s",grib_keys_iterator_get_name(kiter)); + snprintf(buf, sizeof(buf), "%s",grib_keys_iterator_get_name(kiter)); lsize = strlen(buf); if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; @@ -1321,7 +1322,7 @@ int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len) fort_char_clean(name, len); - sprintf(buf, "%s", codes_bufr_keys_iterator_get_name(kiter)); + snprintf(buf, sizeof(buf), "%s", codes_bufr_keys_iterator_get_name(kiter)); lsize = strlen(buf); if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; @@ -1604,9 +1605,8 @@ int any_f_new_from_loaded_(int* msgid, int* gid) /*****************************************************************************/ int codes_f_clear_loaded_from_file_(void) { - grib_context* c = grib_context_get_default(); /* grib_oarray_delete_content(c,binary_messages); */ - grib_oarray_delete(c, binary_messages); + grib_oarray_delete(grib_context_get_default(), binary_messages); return GRIB_SUCCESS; } @@ -1711,10 +1711,10 @@ int grib_f_headers_only_new_from_file_(int* fid, int* gid) } /*****************************************************************************/ -int grib_f_new_from_index_(int* iid, int* gid) +int grib_f_new_from_index_(int* index_id, int* gid) { int err = 0; - grib_index* i = get_index(*iid); + grib_index* i = get_index(*index_id); grib_handle *h = NULL; if (i) { @@ -1757,16 +1757,15 @@ int grib_f_index_new_from_file_(char* file, char* keys, int* gid, int lfile, int } /*****************************************************************************/ -int grib_f_index_add_file_(int* iid, char* file, int lfile) +int grib_f_index_add_file_(int* index_id, char* file, int lfile) { - grib_index *i = get_index(*iid); - int err = GRIB_SUCCESS; + grib_index *i = get_index(*index_id); char buf[1024]; if (!i) { return GRIB_INVALID_INDEX; } else { - err = grib_index_add_file(i,cast_char(buf,file,lfile)); + int err = grib_index_add_file(i,cast_char(buf,file,lfile)); return err; } } @@ -1928,9 +1927,9 @@ int grib_f_get_size_long_(int* gid, char* key, long* val, int len) } /*****************************************************************************/ -int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len) +int grib_f_index_get_size_int_(int* index_id, char* key, int* val, int len) { - grib_index *h = get_index(*gid); + grib_index *h = get_index(*index_id); int err = GRIB_SUCCESS; char buf[1024]; size_t tsize = 0; @@ -1944,19 +1943,18 @@ int grib_f_index_get_size_int_(int* gid, char* key, int* val, int len) } } -int grib_f_index_get_size_long_(int* gid, char* key, long* val, int len) +int grib_f_index_get_size_long_(int* index_id, char* key, long* val, int len) { - grib_index *h = get_index(*gid); - int err = GRIB_SUCCESS; + grib_index *h = get_index(*index_id); char buf[1024]; size_t tsize = 0; - if(!h){ + if (!h){ return GRIB_INVALID_GRIB; - }else{ - err = grib_index_get_size(h, cast_char(buf,key,len), &tsize); + } else{ + int err = grib_index_get_size(h, cast_char(buf,key,len), &tsize); *val = tsize; - return err; + return err; } } @@ -2063,9 +2061,9 @@ int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, i } /*****************************************************************************/ -int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int* size, int len) +int grib_f_index_get_string_(int* index_id, char* key, char* val, int *eachsize,int* size, int len) { - grib_index *h = get_index(*gid); + grib_index *h = get_index(*index_id); int err = GRIB_SUCCESS; int i; char buf[1024]; @@ -2104,23 +2102,23 @@ int grib_f_index_get_string_(int* gid, char* key, char* val, int *eachsize,int* } /*****************************************************************************/ -int grib_f_index_get_long_(int* gid, char* key, long *val, int* size, int len) +int grib_f_index_get_long_(int* index_id, char* key, long *val, int* size, int len) { - grib_index *h = get_index(*gid); - int err = GRIB_SUCCESS; + int err = 0; + grib_index* h = get_index(*index_id); char buf[1024]; size_t lsize = *size; - if(!h) return GRIB_INVALID_GRIB; + if (!h) return GRIB_INVALID_GRIB; err = grib_index_get_long(h, cast_char(buf,key,len), val, &lsize); *size = lsize; - return err; + return err; } /*****************************************************************************/ -int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len) +int grib_f_index_get_int_(int* index_id, char* key, int *val, int* size, int len) { - grib_index *h = get_index(*gid); + grib_index *h = get_index(*index_id); int err = GRIB_SUCCESS; char buf[1024]; size_t lsize = *size, i = 0; @@ -2140,17 +2138,17 @@ int grib_f_index_get_int_(int* gid, char* key, int *val, int* size, int len) } /*****************************************************************************/ -int grib_f_index_get_real8_(int* gid, char* key, double *val, int* size, int len) +int grib_f_index_get_real8_(int* index_id, char* key, double *val, int* size, int len) { - grib_index *h = get_index(*gid); - int err = GRIB_SUCCESS; + int err = 0; + grib_index* h = get_index(*index_id); char buf[1024]; size_t lsize = *size; - if(!h) return GRIB_INVALID_GRIB; + if (!h) return GRIB_INVALID_GRIB; err = grib_index_get_double(h, cast_char(buf,key,len), val, &lsize); *size = lsize; - return err; + return err; } /*****************************************************************************/ @@ -2438,9 +2436,9 @@ int grib_f_set_real4_array_(int* gid, char* key, float* val, int* size, int len) } /*****************************************************************************/ -int grib_f_index_select_real8_(int* gid, char* key, double* val, int len) +int grib_f_index_select_real8_(int* index_id, char* key, double* val, int len) { - grib_index *h = get_index(*gid); + grib_index *h = get_index(*index_id); char buf[1024]; if(!h) return GRIB_INVALID_GRIB; @@ -2448,9 +2446,9 @@ int grib_f_index_select_real8_(int* gid, char* key, double* val, int len) } /*****************************************************************************/ -int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int vallen) +int grib_f_index_select_string_(int* index_id, char* key, char* val, int len, int vallen) { - grib_index *h = get_index(*gid); + grib_index *h = get_index(*index_id); char buf[1024]; char bufval[1024]; @@ -2465,9 +2463,9 @@ int grib_f_index_select_string_(int* gid, char* key, char* val, int len, int val } /*****************************************************************************/ -int grib_f_index_select_int_(int* gid, char* key, int* val, int len) +int grib_f_index_select_int_(int* index_id, char* key, int* val, int len) { - grib_index *h = get_index(*gid); + grib_index *h = get_index(*index_id); long lval = *val; char buf[1024] = {0,}; @@ -2476,9 +2474,9 @@ int grib_f_index_select_int_(int* gid, char* key, int* val, int len) } /*****************************************************************************/ -int grib_f_index_select_long_(int* gid, char* key, long* val, int len) +int grib_f_index_select_long_(int* index_id, char* key, long* val, int len) { - grib_index *h = get_index(*gid); + grib_index *h = get_index(*index_id); char buf[1024] = {0,}; if (!h) return GRIB_INVALID_GRIB; @@ -2880,13 +2878,13 @@ int grib_f_multi_append_(int* ingid, int* sec,int* mgid) } /*****************************************************************************/ -int codes_f_bufr_multi_element_constant_arrays_on_() +int codes_f_bufr_multi_element_constant_arrays_on_(void) { codes_bufr_multi_element_constant_arrays_on(NULL); return GRIB_SUCCESS; } -int codes_f_bufr_multi_element_constant_arrays_off_() +int codes_f_bufr_multi_element_constant_arrays_off_(void) { codes_bufr_multi_element_constant_arrays_off(NULL); return GRIB_SUCCESS; diff --git a/fortran/grib_fortran_prototypes.h b/fortran/grib_fortran_prototypes.h new file mode 100644 index 000000000..4eb0a313d --- /dev/null +++ b/fortran/grib_fortran_prototypes.h @@ -0,0 +1,332 @@ +/* + * Copyright 2005-2018 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. + */ + +/* grib_fortran.c */ +#ifdef __cplusplus +extern "C" { +#endif + +int grib_f_read_any_headers_only_from_file_(int *fid, char *buffer, size_t *nbytes); +int grib_f_write_file_(int* fid, void* buffer, size_t* nbytes); +int any_f_new_from_loaded_(int* msgid, int* gid); +int codes_f_bufr_copy_data_(int* gid1,int* gid2); +int grib_f_get_string_array_(int* gid, char* key, char* val,int* nvals,int* slen, int len); +int codes_f_bufr_keys_iterator_rewind_(int* kiter); +int any_f_scan_file_(int* fid, int* n); +int grib_f_new_from_message_int_(int* gid, int* buffer , size_t* bufsize); +int grib_f_copy_key_(int* gidsrc, char* key, int* giddest, int len); +int grib_f_set_samples_path_(char* path, int len); + +int grib_f_read_file(int *fid, char *buffer, size_t *nbytes); +int grib_f_open_file_(int *fid, char *name, char *op, int lname, int lop); +int grib_f_open_file__(int *fid, char *name, char *op, int lname, int lop); +int grib_f_open_file(int *fid, char *name, char *op, int lname, int lop); +int grib_f_close_file_(int *fid); +int grib_f_close_file__(int *fid); +int grib_f_close_file(int *fid); +void grib_f_write_on_fail(int *gid); +void grib_f_write_on_fail_(int* gid); +void grib_f_write_on_fail__(int* gid); +int grib_f_multi_support_on_(void); +int grib_f_multi_support_on__(void); +int grib_f_multi_support_on(void); +int grib_f_multi_support_off_(void); +int grib_f_multi_support_off__(void); +int grib_f_multi_support_off(void); +int grib_f_iterator_new_(int *gid, int *iterid, int *mode); +int grib_f_iterator_new__(int *gid, int *iterid, int *mode); +int grib_f_iterator_new(int *gid, int *iterid, int *mode); +int grib_f_iterator_next_(int *iterid, double *lat, double *lon, double *value); +int grib_f_iterator_next__(int *iterid, double *lat, double *lon, double *value); +int grib_f_iterator_next(int *iterid, double *lat, double *lon, double *value); +int grib_f_iterator_delete_(int *iterid); +int grib_f_iterator_delete__(int *iterid); +int grib_f_iterator_delete(int *iterid); +int grib_f_keys_iterator_new_(int *gid, int *iterid, char *name_space, int len); +int grib_f_keys_iterator_new__(int *gid, int *iterid, char *name_space, int len); +int grib_f_keys_iterator_new(int *gid, int *iterid, char *name_space, int len); +int grib_f_keys_iterator_next_(int *iterid); +int grib_f_keys_iterator_next__(int *iterid); +int grib_f_keys_iterator_next(int *iterid); +int grib_f_keys_iterator_delete_(int *iterid); +int grib_f_keys_iterator_delete__(int *iterid); +int grib_f_keys_iterator_delete(int *iterid); +int grib_f_gribex_mode_on_(void); +int grib_f_gribex_mode_on__(void); +int grib_f_gribex_mode_on(void); +int grib_f_gribex_mode_off_(void); +int grib_f_gribex_mode_off__(void); +int grib_f_gribex_mode_off(void); +int grib_f_skip_computed_(int *iterid); +int grib_f_skip_computed__(int *iterid); +int grib_f_skip_computed(int *iterid); +int grib_f_skip_coded_(int *iterid); +int grib_f_skip_coded__(int *iterid); +int grib_f_skip_coded(int *iterid); +int grib_f_skip_edition_specific_(int *iterid); +int grib_f_skip_edition_specific__(int *iterid); +int grib_f_skip_edition_specific(int *iterid); +int grib_f_skip_duplicates_(int *iterid); +int grib_f_skip_duplicates__(int *iterid); +int grib_f_skip_duplicates(int *iterid); +int grib_f_skip_read_only_(int *iterid); +int grib_f_skip_read_only__(int *iterid); +int grib_f_skip_read_only(int *iterid); +int grib_f_skip_function_(int *iterid); +int grib_f_skip_function__(int *iterid); +int grib_f_skip_function(int *iterid); +int grib_f_keys_iterator_get_name_(int *iterid, char *name, int len); +int grib_f_keys_iterator_get_name__(int *kiter, char *name, int len); +int grib_f_keys_iterator_get_name(int *kiter, char *name, int len); +int grib_f_keys_iterator_rewind_(int *kiter); +int grib_f_keys_iterator_rewind__(int *kiter); +int grib_f_keys_iterator_rewind(int *kiter); +int grib_f_new_from_message_(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message__(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message_copy_(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message_copy__(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_message_copy(int *gid, void *buffer, size_t *bufsize); +int grib_f_new_from_samples_(int *gid, char *name, int lname); +int grib_f_new_from_samples__(int *gid, char *name, int lname); +int grib_f_new_from_samples(int *gid, char *name, int lname); +int grib_f_new_from_template_(int *gid, char *name, int lname); +int grib_f_new_from_template__(int *gid, char *name, int lname); +int grib_f_new_from_template(int *gid, char *name, int lname); +int grib_f_clone_(int *gidsrc, int *giddest); +int grib_f_clone__(int *gidsrc, int *giddest); +int grib_f_clone(int *gidsrc, int *giddest); +int grib_f_util_sections_copy_(int *gidfrom, int *gidto, int *what, int *gidout); +int grib_f_util_sections_copy__(int *gidfrom, int *gidto, int *what, int *gidout); +int grib_f_util_sections_copy(int *gidfrom, int *gidto, int *what, int *gidout); +int grib_f_copy_namespace_(int *gidsrc, char *name, int *giddest, int len); +int grib_f_copy_namespace__(int *gidsrc, char *name, int *giddest, int len); +int grib_f_copy_namespace(int *gidsrc, char *name, int *giddest, int len); +int grib_f_count_in_file(int *fid, int *n); +int grib_f_count_in_file_(int *fid, int *n); +int grib_f_count_in_file__(int *fid, int *n); +int grib_f_new_from_file_(int *fid, int *gid); +int grib_f_new_from_file__(int *fid, int *gid); +int grib_f_new_from_file(int *fid, int *gid); +int grib_f_headers_only_new_from_file_(int *fid, int *gid); +int grib_f_headers_only_new_from_file__(int *fid, int *gid); +int grib_f_headers_only_new_from_file(int *fid, int *gid); +int grib_f_new_from_index_(int *iid, int *gid); +int grib_f_new_from_index__(int *iid, int *gid); +int grib_f_new_from_index(int *iid, int *gid); +int grib_f_index_new_from_file_(char *file, char *keys, int *gid, int lfile, int lkeys); +int grib_f_index_new_from_file__(char *file, char *keys, int *gid, int lfile, int lkeys); +int grib_f_index_new_from_file(char *file, char *keys, int *gid, int lfile, int lkeys); +int grib_f_index_add_file_(int* iid, char* file, int lfile); +int grib_f_index_add_file__(int* iid, char* file, int lfile); +int grib_f_index_add_file(int* iid, char* file, int lfile); +int grib_f_index_read_(char *file, int *gid, int lfile); +int grib_f_index_read__(char *file, int *gid, int lfile); +int grib_f_index_read(char *file, int *gid, int lfile); +int grib_f_index_write_(int *gid, char *file, int lfile); +int grib_f_index_write__(int *gid, char *file, int lfile); +int grib_f_index_write(int *gid, char *file, int lfile); +int grib_f_index_release_(int *hid); +int grib_f_index_release__(int *hid); +int grib_f_index_release(int *hid); +int grib_f_multi_handle_release_(int *hid); +int grib_f_multi_handle_release__(int *hid); +int grib_f_multi_handle_release(int *hid); +int grib_f_release_(int *hid); +int grib_f_release__(int *hid); +int grib_f_release(int *hid); +int grib_f_dump_(int *gid); +int grib_f_dump__(int *gid); +int grib_f_dump(int *gid); +int grib_f_print_(int *gid, char *key, int len); +int grib_f_print__(int *gid, char *key, int len); +int grib_f_print(int *gid, char *key, int len); +int grib_f_get_error_string_(int *err, char *buf, int len); +int grib_f_get_error_string__(int *err, char *buf, int len); +int grib_f_get_error_string(int *err, char *buf, int len); +int grib_f_get_size_int_(int *gid, char *key, int *val, int len); +int grib_f_get_size_int__(int *gid, char *key, int *val, int len); +int grib_f_get_size_int(int *gid, char *key, int *val, int len); +int grib_f_get_size_long_(int *gid, char *key, long *val, int len); +int grib_f_get_size_long__(int *gid, char *key, long *val, int len); +int grib_f_get_size_long(int *gid, char *key, long *val, int len); +int grib_f_index_get_size_int_(int *gid, char *key, int *val, int len); +int grib_f_index_get_size_int__(int *gid, char *key, int *val, int len); +int grib_f_index_get_size_int(int *gid, char *key, int *val, int len); +int grib_f_index_get_size_long_(int *gid, char *key, long *val, int len); +int grib_f_index_get_size_long__(int *gid, char *key, long *val, int len); +int grib_f_index_get_size_long(int *gid, char *key, long *val, int len); +int grib_f_get_int_(int *gid, char *key, int *val, int len); +int grib_f_get_int__(int *gid, char *key, int *val, int len); +int grib_f_get_int(int *gid, char *key, int *val, int len); +int grib_f_get_long_(int *gid, char *key, long *val, int len); +int grib_f_get_long__(int *gid, char *key, long *val, int len); +int grib_f_get_long(int *gid, char *key, long *val, int len); +int grib_f_get_int_array_(int *gid, char *key, int *val, int *size, int len); +int grib_f_get_int_array__(int *gid, char *key, int *val, int *size, int len); +int grib_f_get_int_array(int *gid, char *key, int *val, int *size, int len); +int grib_f_get_long_array_(int *gid, char *key, long *val, int *size, int len); +int grib_f_get_long_array__(int *gid, char *key, long *val, int *size, int len); +int grib_f_get_long_array(int *gid, char *key, long *val, int *size, int len); +int grib_f_get_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_get_byte_array__(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_get_byte_array(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_index_get_string_(int *gid, char *key, char *val, int *eachsize, int *size, int len); +int grib_f_index_get_string__(int *gid, char *key, char *val, int *eachsize, int *size, int len); +int grib_f_index_get_string(int *gid, char *key, char *val, int *eachsize, int *size, int len); +int grib_f_index_get_long_(int *gid, char *key, long *val, int *size, int len); +int grib_f_index_get_long__(int *gid, char *key, long *val, int *size, int len); +int grib_f_index_get_long(int *gid, char *key, long *val, int *size, int len); +int grib_f_index_get_int_(int *gid, char *key, int *val, int *size, int len); +int grib_f_index_get_int__(int *gid, char *key, int *val, int *size, int len); +int grib_f_index_get_int(int *gid, char *key, int *val, int *size, int len); +int grib_f_index_get_real8_(int *gid, char *key, double *val, int *size, int len); +int grib_f_index_get_real8__(int *gid, char *key, double *val, int *size, int len); +int grib_f_index_get_real8(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_int_array_(int *gid, char *key, int *val, int *size, int len); +int grib_f_set_int_array__(int *gid, char *key, int *val, int *size, int len); +int grib_f_set_int_array(int *gid, char *key, int *val, int *size, int len); +int grib_f_set_long_array_(int *gid, char *key, long *val, int *size, int len); +int grib_f_set_long_array__(int *gid, char *key, long *val, int *size, int len); +int grib_f_set_long_array(int *gid, char *key, long *val, int *size, int len); +int grib_f_set_byte_array_(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_set_byte_array__(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_set_byte_array(int* gid, char* key, unsigned char *val, int* size, int len, int lenv); +int grib_f_set_int_(int *gid, char *key, int *val, int len); +int grib_f_set_int__(int *gid, char *key, int *val, int len); +int grib_f_set_int(int *gid, char *key, int *val, int len); +int grib_f_set_long_(int *gid, char *key, long *val, int len); +int grib_f_set_long__(int *gid, char *key, long *val, int len); +int grib_f_set_long(int *gid, char *key, long *val, int len); +int grib_f_set_missing_(int *gid, char *key, int len); +int grib_f_set_missing__(int *gid, char *key, int len); +int grib_f_set_missing(int *gid, char *key, int len); +int grib_f_is_missing_(int *gid, char *key, int *isMissing, int len); +int grib_f_is_defined_(int *gid, char *key, int *isDefined, int len); +int grib_f_is_missing__(int *gid, char *key, int *isMissing, int len); +int grib_f_is_missing(int *gid, char *key, int *isMissing, int len); +int grib_f_set_real4_(int *gid, char *key, float *val, int len); +int grib_f_set_real4__(int *gid, char *key, float *val, int len); +int grib_f_set_real4(int *gid, char *key, float *val, int len); +int grib_f_get_real4_element_(int *gid, char *key, int *index, float *val, int len); +int grib_f_get_real4_element__(int *gid, char *key, int *index, float *val, int len); +int grib_f_get_real4_element(int *gid, char *key, int *index, float *val, int len); +int grib_f_get_real4_elements_(int *gid, char *key, int *index, float *val, int *size, int len); +int grib_f_get_real4_elements__(int *gid, char *key, int *index, float *val, int *len, int size); +int grib_f_get_real4_elements(int *gid, char *key, int *index, float *val, int *len, int size); +int grib_f_get_real4_(int *gid, char *key, float *val, int len); +int grib_f_get_real4__(int *gid, char *key, float *val, int len); +int grib_f_get_real4(int *gid, char *key, float *val, int len); +int grib_f_get_real4_array_(int *gid, char *key, float *val, int *size, int len); +int grib_f_get_real4_array__(int *gid, char *key, float *val, int *size, int len); +int grib_f_get_real4_array(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_real4_array_(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_real4_array__(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_real4_array(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_force_real4_array_(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_force_real4_array__(int *gid, char *key, float *val, int *size, int len); +int grib_f_set_force_real4_array(int *gid, char *key, float *val, int *size, int len); +int grib_f_index_select_real8_(int *gid, char *key, double *val, int len); +int grib_f_index_select_real8__(int *gid, char *key, double *val, int len); +int grib_f_index_select_real8(int *gid, char *key, double *val, int len); +int grib_f_index_select_string_(int *gid, char *key, char *val, int len, int vallen); +int grib_f_index_select_string__(int *gid, char *key, char *val, int len, int vallen); +int grib_f_index_select_string(int *gid, char *key, char *val, int len, int vallen); +int grib_f_index_select_int_(int *gid, char *key, int *val, int len); +int grib_f_index_select_int__(int *gid, char *key, int *val, int len); +int grib_f_index_select_int(int *gid, char *key, int *val, int len); +int grib_f_index_select_long_(int *gid, char *key, long *val, int len); +int grib_f_index_select_long__(int *gid, char *key, long *val, int len); +int grib_f_index_select_long(int *gid, char *key, long *val, int len); +int grib_f_set_real8_(int *gid, char *key, double *val, int len); +int grib_f_set_real8__(int *gid, char *key, double *val, int len); +int grib_f_set_real8(int *gid, char *key, double *val, int len); +int grib_f_get_real8_(int *gid, char *key, double *val, int len); +int grib_f_get_real8__(int *gid, char *key, double *val, int len); +int grib_f_get_real8(int *gid, char *key, double *val, int len); +int grib_f_get_real8_element_(int *gid, char *key, int *index, double *val, int len); +int grib_f_get_real8_element__(int *gid, char *key, int *index, double *val, int len); +int grib_f_get_real8_element(int *gid, char *key, int *index, double *val, int len); +int grib_f_get_real8_elements_(int *gid, char *key, int *index, double *val, int *size, int len); +int grib_f_get_real8_elements__(int *gid, char *key, int *index, double *val, int *len, int size); +int grib_f_get_real8_elements(int *gid, char *key, int *index, double *val, int *len, int size); +int grib_f_find_nearest_four_single_(int *gid, int *is_lsm, double *inlat, double *inlon, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_four_single__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_four_single(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_single_(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_single__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_single(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes); +int grib_f_find_nearest_multiple_(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints); +int grib_f_find_nearest_multiple__(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints); +int grib_f_find_nearest_multiple(int *gid, int *is_lsm, double *inlats, double *inlons, double *outlats, double *outlons, double *values, double *distances, int *indexes, int *npoints); +int grib_f_get_real8_array_(int *gid, char *key, double *val, int *size, int len); +int grib_f_get_real8_array__(int *gid, char *key, double *val, int *size, int len); +int grib_f_get_real8_array(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_real8_array_(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_real8_array__(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_real8_array(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_force_real8_array_(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_force_real8_array__(int *gid, char *key, double *val, int *size, int len); +int grib_f_set_force_real8_array(int *gid, char *key, double *val, int *size, int len); +int grib_f_get_string_(int *gid, char *key, char *val, int len, int len2); +int grib_f_get_string__(int *gid, char *key, char *val, int len, int len2); +int grib_f_get_string(int *gid, char *key, char *val, int len, int len2); +int grib_f_set_string_(int *gid, char *key, char *val, int len, int len2); +int grib_f_set_string__(int *gid, char *key, char *val, int len, int len2); +int grib_f_set_string(int *gid, char *key, char *val, int len, int len2); +int grib_f_get_data_real4_(int *gid, float *lats, float *lons, float *values, size_t *size); +int grib_f_get_data_real4__(int *gid, float *lats, float *lons, float *values, size_t *size); +int grib_f_get_data_real4(int *gid, float *lats, float *lons, float *values, size_t *size); +int grib_f_get_data_real8_(int *gid, double *lats, double *lons, double *values, size_t *size); +int grib_f_get_data_real8__(int *gid, double *lats, double *lons, double *values, size_t *size); +int grib_f_get_data_real8(int *gid, double *lats, double *lons, double *values, size_t *size); +int grib_f_get_message_size_(int *gid, size_t *len); +int grib_f_get_message_size__(int *gid, size_t *len); +int grib_f_get_message_size(int *gid, size_t *len); +int grib_f_copy_message_(int *gid, void *mess, size_t *len); +int grib_f_copy_message__(int *gid, void *mess, size_t *len); +int grib_f_copy_message(int *gid, void *mess, size_t *len); +void grib_f_check_(int *err, char *call, char *str, int lencall, int lenstr); +void grib_f_check__(int *err, char *call, char *key, int lencall, int lenkey); +void grib_f_check(int *err, char *call, char *key, int lencall, int lenkey); +int grib_f_write_(int *gid, int *fid); +int grib_f_write__(int *gid, int *fid); +int grib_f_write(int *gid, int *fid); +int grib_f_multi_write_(int *gid, int *fid); +int grib_f_multi_write__(int *gid, int *fid); +int grib_f_multi_write(int *gid, int *fid); +int grib_f_multi_append_(int *ingid, int *sec, int *mgid); +int grib_f_multi_append(int *ingid, int *sec, int *mgid); +int grib_f_multi_append__(int *ingid, int *sec, int *mgid); + +int codes_f_bufr_keys_iterator_new_(int* gid,int* iterid); +int grib_f_read_file_(int* fid, void* buffer, size_t* nbytes); +int codes_f_bufr_keys_iterator_delete_(int* iterid); +int grib_f_set_definitions_path_(char* path, int len); +int grib_f_read_any_from_file_(int* fid, void* buffer, size_t* nbytes); +int any_f_new_from_file_(int* fid, int* gid); +int grib_f_get_native_type_(int* gid, char* key, int* val, int len); +int grib_f_get_api_version_(int* apiVersion,int len); +int codes_bufr_f_new_from_samples_(int* gid, char* name, int lname); +int any_f_load_all_from_file_(int* fid, int* n); +int codes_f_bufr_multi_element_constant_arrays_on_(); +int bufr_f_new_from_file_(int* fid, int* gid); +int grib_f_julian_to_datetime_(double* jd,long* year,long* month,long* day,long *hour,long *minute,long *second); +int any_f_new_from_scanned_file_(int* fid, int* msgid, int* gid); +int codes_f_bufr_keys_iterator_next_(int* iterid); +int grib_f_datetime_to_julian_(long* year,long* month,long* day, long* hour,long* minute,long* second,double* jd); +int grib_f_set_string_array_(int* gid, char* key, char* val,int* nvals,int* slen, int len); +int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len); +int codes_f_bufr_multi_element_constant_arrays_off_(); + + +#ifdef __cplusplus +} +#endif diff --git a/samples/GRIB2.tmpl b/samples/GRIB2.tmpl index 5c7b111ce..e2f890a57 100644 Binary files a/samples/GRIB2.tmpl and b/samples/GRIB2.tmpl differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97cd81dfc..fce6d88d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,10 @@ # nor does it submit to any jurisdiction. # list( APPEND eccodes_src_files + accessor/grib_accessor.cc + accessor/grib_accessors_list.cc + grib_accessor_class.cc + shared_functions.cc step_unit.cc step.cc step_utilities.cc @@ -20,9 +24,9 @@ list( APPEND eccodes_src_files action_class_gen.cc action_class_if.cc action_class_switch.cc - grib_accessor_class_g1fcperiod.cc - grib_accessor_class_g1end_of_interval_monthly.cc - grib_accessor_class_mars_param.cc + accessor/grib_accessor_class_g1fcperiod.cc + accessor/grib_accessor_class_g1end_of_interval_monthly.cc + accessor/grib_accessor_class_mars_param.cc action_class_section.cc action_class_list.cc action_class_while.cc @@ -47,7 +51,6 @@ list( APPEND eccodes_src_files action_class_modify.cc action_class_transient_darray.cc eccodes.cc - grib_accessor.cc grib_concept.cc grib_hash_array.cc grib_bufr_descriptor.cc @@ -60,208 +63,207 @@ list( APPEND eccodes_src_files grib_iarray.cc grib_viarray.cc codes_memfs.cc - grib_accessor_class_ascii.cc - grib_accessor_class_bit.cc - grib_accessor_class_bitmap.cc - grib_accessor_class_bits.cc - grib_accessor_class_bits_per_value.cc - grib_accessor_class_bufr_elements_table.cc - grib_accessor_class_bufr_data_array.cc - grib_accessor_class_bufr_data_element.cc - grib_accessor_class_bufr_group.cc - grib_accessor_class_bufr_string_values.cc - grib_accessor_class_pack_bufr_values.cc - grib_accessor_class_unpack_bufr_values.cc - grib_accessor_class_group.cc - grib_accessor_class_non_alpha.cc - grib_accessor_class_g1bitmap.cc - grib_accessor_class_g2bitmap.cc - grib_accessor_class_concept.cc - grib_accessor_class_hash_array.cc - grib_accessor_class_decimal_precision.cc - grib_accessor_class_divdouble.cc - grib_accessor_class_multdouble.cc - grib_accessor_class_budgdate.cc - grib_accessor_class_validity_date.cc - grib_accessor_class_validity_time.cc - grib_accessor_class_bytes.cc - grib_accessor_class.cc - grib_accessor_class_change_alternative_row_scanning.cc - grib_accessor_class_change_scanning_direction.cc - grib_accessor_class_check_internal_version.cc - grib_accessor_class_codeflag.cc - grib_accessor_class_smart_table.cc - grib_accessor_class_smart_table_column.cc - grib_accessor_class_codetable.cc - grib_accessor_class_codetable_units.cc - grib_accessor_class_codetable_title.cc - grib_accessor_class_step_human_readable.cc - grib_accessor_class_count_file.cc - grib_accessor_class_count_total.cc - grib_accessor_class_double.cc - grib_accessor_class_element.cc - grib_accessor_class_evaluate.cc - grib_accessor_class_g1date.cc - grib_accessor_class_g1monthlydate.cc - grib_accessor_class_library_version.cc - grib_accessor_class_when.cc - grib_accessor_class_g1verificationdate.cc - grib_accessor_class_g1day_of_the_year_date.cc - grib_accessor_class_g1_half_byte_codeflag.cc - grib_accessor_class_g1forecastmonth.cc - grib_accessor_class_g1step_range.cc - grib_accessor_class_g2step_range.cc - grib_accessor_class_data_g22order_packing.cc - grib_accessor_class_mars_step.cc - grib_accessor_class_message_copy.cc - grib_accessor_class_dictionary.cc - grib_accessor_class_latlon_increment.cc - grib_accessor_class_g2date.cc - grib_accessor_class_g2level.cc - grib_accessor_class_g2end_step.cc - grib_accessor_class_g2latlon.cc - grib_accessor_class_g2lon.cc - grib_accessor_class_global_gaussian.cc - grib_accessor_class_gaussian_grid_name.cc - grib_accessor_class_gen.cc - grib_accessor_class_getenv.cc - grib_accessor_class_gts_header.cc - grib_accessor_class_ifs_param.cc - grib_accessor_class_julian_day.cc - grib_accessor_class_julian_date.cc - grib_accessor_class_closest_date.cc - grib_accessor_class_latlonvalues.cc - grib_accessor_class_latitudes.cc - grib_accessor_class_longitudes.cc - grib_accessor_class_offset_file.cc - grib_accessor_class_scale.cc - grib_accessor_class_from_scale_factor_scaled_value.cc - grib_accessor_class_g2bitmap_present.cc - grib_accessor_class_ibmfloat.cc - grib_accessor_class_ieeefloat.cc - grib_accessor_class_constant.cc - grib_accessor_class_iterator.cc - grib_accessor_class_message.cc - grib_accessor_class_nearest.cc - grib_accessor_class_ksec1expver.cc - grib_accessor_class_label.cc - grib_accessor_class_long.cc - grib_accessor_class_lookup.cc - grib_accessor_class_octahedral_gaussian.cc - grib_accessor_class_octet_number.cc - grib_accessor_class_headers_only.cc - grib_accessor_class_padding.cc - grib_accessor_class_pad.cc - grib_accessor_class_padto.cc - grib_accessor_class_padtoeven.cc - grib_accessor_class_padtomultiple.cc - grib_accessor_class_section_padding.cc - grib_accessor_class_packing_type.cc - grib_accessor_class_section_pointer.cc - grib_accessor_class_position.cc - grib_accessor_class_signed.cc - grib_accessor_class_signed_bits.cc - grib_accessor_class_section.cc - grib_accessor_class_step_in_units.cc - grib_accessor_class_optimal_step_units.cc - grib_accessor_class_section_length.cc - grib_accessor_class_g1_message_length.cc - grib_accessor_class_g1_section4_length.cc - grib_accessor_class_size.cc - grib_accessor_class_rdbtime_guess_date.cc - grib_accessor_class_scale_values.cc - grib_accessor_class_offset_values.cc - grib_accessor_class_sprintf.cc - grib_accessor_class_round.cc - grib_accessor_class_spectral_truncation.cc - grib_accessor_class_time.cc - grib_accessor_class_transient.cc - grib_accessor_class_trim.cc - grib_accessor_class_transient_darray.cc - grib_accessor_class_values.cc - grib_accessor_class_simple_packing_error.cc - grib_accessor_class_data_simple_packing.cc - grib_accessor_class_count_missing.cc - grib_accessor_class_data_sh_packed.cc - grib_accessor_class_data_sh_unpacked.cc - grib_accessor_class_number_of_values_data_raw_packing.cc - grib_accessor_class_data_g1simple_packing.cc - grib_accessor_class_data_g1shsimple_packing.cc - grib_accessor_class_data_shsimple_packing.cc - grib_accessor_class_data_dummy_field.cc - grib_accessor_class_variable.cc - grib_accessor_class_second_order_bits_per_value.cc - grib_accessor_class_data_g2simple_packing.cc - grib_accessor_class_data_g2simple_packing_with_preprocessing.cc - grib_accessor_class_data_g2shsimple_packing.cc - grib_accessor_class_data_g2complex_packing.cc - grib_accessor_class_data_g1second_order_row_by_row_packing.cc - grib_accessor_class_data_g1second_order_constant_width_packing.cc - grib_accessor_class_data_g1second_order_general_packing.cc - grib_accessor_class_data_g1second_order_general_extended_packing.cc - grib_accessor_class_g2grid.cc - grib_accessor_class_unexpanded_descriptors.cc - grib_accessor_class_expanded_descriptors.cc - grib_accessor_class_bufrdc_expanded_descriptors.cc - grib_accessor_class_data_apply_bitmap.cc - grib_accessor_class_data_apply_boustrophedonic.cc - grib_accessor_class_data_apply_boustrophedonic_bitmap.cc - grib_accessor_class_data_secondary_bitmap.cc - grib_accessor_class_data_g1secondary_bitmap.cc - grib_accessor_class_data_g2secondary_bitmap.cc - grib_accessor_class_data_jpeg2000_packing.cc - grib_accessor_class_data_png_packing.cc - grib_accessor_class_data_ccsds_packing.cc - grib_accessor_class_data_raw_packing.cc - grib_accessor_class_data_complex_packing.cc - grib_accessor_class_data_g1complex_packing.cc - grib_accessor_class_gds_not_present_bitmap.cc - grib_accessor_class_gds_is_present.cc - grib_accessor_class_select_step_template.cc - grib_accessor_class_local_definition.cc - grib_accessor_class_g2_eps.cc - grib_accessor_class_g2_aerosol.cc - grib_accessor_class_g2_chemical.cc - grib_accessor_class_g2_mars_labeling.cc - grib_accessor_class_md5.cc - grib_accessor_class_proj_string.cc + accessor/grib_accessor_class_gen.cc + accessor/grib_accessor_class_ascii.cc + accessor/grib_accessor_class_bit.cc + accessor/grib_accessor_class_bitmap.cc + accessor/grib_accessor_class_bits.cc + accessor/grib_accessor_class_bits_per_value.cc + accessor/grib_accessor_class_bufr_elements_table.cc + accessor/grib_accessor_class_bufr_data_array.cc + accessor/grib_accessor_class_bufr_data_element.cc + accessor/grib_accessor_class_bufr_group.cc + accessor/grib_accessor_class_bufr_string_values.cc + accessor/grib_accessor_class_pack_bufr_values.cc + accessor/grib_accessor_class_unpack_bufr_values.cc + accessor/grib_accessor_class_group.cc + accessor/grib_accessor_class_non_alpha.cc + accessor/grib_accessor_class_g1bitmap.cc + accessor/grib_accessor_class_g2bitmap.cc + accessor/grib_accessor_class_concept.cc + accessor/grib_accessor_class_hash_array.cc + accessor/grib_accessor_class_decimal_precision.cc + accessor/grib_accessor_class_divdouble.cc + accessor/grib_accessor_class_multdouble.cc + accessor/grib_accessor_class_budgdate.cc + accessor/grib_accessor_class_validity_date.cc + accessor/grib_accessor_class_validity_time.cc + accessor/grib_accessor_class_bytes.cc + accessor/grib_accessor_class_change_alternative_row_scanning.cc + accessor/grib_accessor_class_change_scanning_direction.cc + accessor/grib_accessor_class_check_internal_version.cc + accessor/grib_accessor_class_codeflag.cc + accessor/grib_accessor_class_smart_table.cc + accessor/grib_accessor_class_smart_table_column.cc + accessor/grib_accessor_class_codetable.cc + accessor/grib_accessor_class_codetable_units.cc + accessor/grib_accessor_class_codetable_title.cc + accessor/grib_accessor_class_step_human_readable.cc + accessor/grib_accessor_class_count_file.cc + accessor/grib_accessor_class_count_total.cc + accessor/grib_accessor_class_double.cc + accessor/grib_accessor_class_element.cc + accessor/grib_accessor_class_evaluate.cc + accessor/grib_accessor_class_g1date.cc + accessor/grib_accessor_class_g1monthlydate.cc + accessor/grib_accessor_class_library_version.cc + accessor/grib_accessor_class_when.cc + accessor/grib_accessor_class_g1verificationdate.cc + accessor/grib_accessor_class_g1day_of_the_year_date.cc + accessor/grib_accessor_class_g1_half_byte_codeflag.cc + accessor/grib_accessor_class_g1forecastmonth.cc + accessor/grib_accessor_class_g1step_range.cc + accessor/grib_accessor_class_g2step_range.cc + accessor/grib_accessor_class_data_g22order_packing.cc + accessor/grib_accessor_class_mars_step.cc + accessor/grib_accessor_class_message_copy.cc + accessor/grib_accessor_class_dictionary.cc + accessor/grib_accessor_class_latlon_increment.cc + accessor/grib_accessor_class_g2date.cc + accessor/grib_accessor_class_g2level.cc + accessor/grib_accessor_class_g2end_step.cc + accessor/grib_accessor_class_g2latlon.cc + accessor/grib_accessor_class_g2lon.cc + accessor/grib_accessor_class_global_gaussian.cc + accessor/grib_accessor_class_gaussian_grid_name.cc + accessor/grib_accessor_class_getenv.cc + accessor/grib_accessor_class_gts_header.cc + accessor/grib_accessor_class_ifs_param.cc + accessor/grib_accessor_class_julian_day.cc + accessor/grib_accessor_class_julian_date.cc + accessor/grib_accessor_class_closest_date.cc + accessor/grib_accessor_class_latlonvalues.cc + accessor/grib_accessor_class_latitudes.cc + accessor/grib_accessor_class_longitudes.cc + accessor/grib_accessor_class_offset_file.cc + accessor/grib_accessor_class_scale.cc + accessor/grib_accessor_class_from_scale_factor_scaled_value.cc + accessor/grib_accessor_class_g2bitmap_present.cc + accessor/grib_accessor_class_ibmfloat.cc + accessor/grib_accessor_class_ieeefloat.cc + accessor/grib_accessor_class_constant.cc + accessor/grib_accessor_class_iterator.cc + accessor/grib_accessor_class_message.cc + accessor/grib_accessor_class_nearest.cc + accessor/grib_accessor_class_ksec1expver.cc + accessor/grib_accessor_class_label.cc + accessor/grib_accessor_class_long.cc + accessor/grib_accessor_class_lookup.cc + accessor/grib_accessor_class_octahedral_gaussian.cc + accessor/grib_accessor_class_octet_number.cc + accessor/grib_accessor_class_headers_only.cc + accessor/grib_accessor_class_padding.cc + accessor/grib_accessor_class_pad.cc + accessor/grib_accessor_class_padto.cc + accessor/grib_accessor_class_padtoeven.cc + accessor/grib_accessor_class_padtomultiple.cc + accessor/grib_accessor_class_section_padding.cc + accessor/grib_accessor_class_packing_type.cc + accessor/grib_accessor_class_section_pointer.cc + accessor/grib_accessor_class_position.cc + accessor/grib_accessor_class_signed.cc + accessor/grib_accessor_class_signed_bits.cc + accessor/grib_accessor_class_section.cc + accessor/grib_accessor_class_step_in_units.cc + accessor/grib_accessor_class_optimal_step_units.cc + accessor/grib_accessor_class_section_length.cc + accessor/grib_accessor_class_g1_message_length.cc + accessor/grib_accessor_class_g1_section4_length.cc + accessor/grib_accessor_class_size.cc + accessor/grib_accessor_class_rdbtime_guess_date.cc + accessor/grib_accessor_class_scale_values.cc + accessor/grib_accessor_class_offset_values.cc + accessor/grib_accessor_class_sprintf.cc + accessor/grib_accessor_class_round.cc + accessor/grib_accessor_class_spectral_truncation.cc + accessor/grib_accessor_class_time.cc + accessor/grib_accessor_class_transient.cc + accessor/grib_accessor_class_trim.cc + accessor/grib_accessor_class_transient_darray.cc + accessor/grib_accessor_class_values.cc + accessor/grib_accessor_class_simple_packing_error.cc + accessor/grib_accessor_class_data_simple_packing.cc + accessor/grib_accessor_class_count_missing.cc + accessor/grib_accessor_class_data_sh_packed.cc + accessor/grib_accessor_class_data_sh_unpacked.cc + accessor/grib_accessor_class_number_of_values_data_raw_packing.cc + accessor/grib_accessor_class_data_g1simple_packing.cc + accessor/grib_accessor_class_data_g1shsimple_packing.cc + accessor/grib_accessor_class_data_shsimple_packing.cc + accessor/grib_accessor_class_data_dummy_field.cc + accessor/grib_accessor_class_variable.cc + accessor/grib_accessor_class_second_order_bits_per_value.cc + accessor/grib_accessor_class_data_g2simple_packing.cc + accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc + accessor/grib_accessor_class_data_g2shsimple_packing.cc + accessor/grib_accessor_class_data_g2complex_packing.cc + accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc + accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc + accessor/grib_accessor_class_data_g1second_order_general_packing.cc + accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc + accessor/grib_accessor_class_g2grid.cc + accessor/grib_accessor_class_unexpanded_descriptors.cc + accessor/grib_accessor_class_expanded_descriptors.cc + accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc + accessor/grib_accessor_class_data_apply_bitmap.cc + accessor/grib_accessor_class_data_apply_boustrophedonic.cc + accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc + accessor/grib_accessor_class_data_secondary_bitmap.cc + accessor/grib_accessor_class_data_g1secondary_bitmap.cc + accessor/grib_accessor_class_data_g2secondary_bitmap.cc + accessor/grib_accessor_class_data_jpeg2000_packing.cc + accessor/grib_accessor_class_data_png_packing.cc + accessor/grib_accessor_class_data_ccsds_packing.cc + accessor/grib_accessor_class_data_raw_packing.cc + accessor/grib_accessor_class_data_complex_packing.cc + accessor/grib_accessor_class_data_g1complex_packing.cc + accessor/grib_accessor_class_gds_not_present_bitmap.cc + accessor/grib_accessor_class_gds_is_present.cc + accessor/grib_accessor_class_select_step_template.cc + accessor/grib_accessor_class_local_definition.cc + accessor/grib_accessor_class_g2_eps.cc + accessor/grib_accessor_class_g2_aerosol.cc + accessor/grib_accessor_class_g2_chemical.cc + accessor/grib_accessor_class_g2_mars_labeling.cc + accessor/grib_accessor_class_md5.cc + accessor/grib_accessor_class_proj_string.cc grib_jasper_encoding.cc grib_openjpeg_encoding.cc action_class_set_missing.cc - grib_accessor_class_number_of_points.cc - grib_accessor_class_suppressed.cc + accessor/grib_accessor_class_number_of_points.cc + accessor/grib_accessor_class_suppressed.cc grib_index.cc - grib_accessor_class_number_of_points_gaussian.cc - grib_accessor_class_number_of_values.cc - grib_accessor_class_number_of_coded_values.cc - grib_accessor_class_g1number_of_coded_values_sh_complex.cc - grib_accessor_class_g1number_of_coded_values_sh_simple.cc - grib_accessor_class_dirty.cc - grib_accessor_class_statistics.cc - grib_accessor_class_statistics_spectral.cc - grib_accessor_class_unsigned.cc - grib_accessor_class_unsigned_bits.cc - grib_accessor_class_raw.cc - grib_accessor_class_bufr_simple_thinning.cc - grib_accessor_class_bufr_extract_subsets.cc - grib_accessor_class_bufr_extract_area_subsets.cc - grib_accessor_class_bufr_extract_datetime_subsets.cc - grib_accessor_class_spd.cc - grib_accessor_class_sum.cc - grib_accessor_class_to_integer.cc - grib_accessor_class_to_double.cc - grib_accessor_class_to_string.cc - grib_accessor_class_sexagesimal2decimal.cc - grib_accessor_class_vector.cc - grib_accessor_class_long_vector.cc + accessor/grib_accessor_class_number_of_points_gaussian.cc + accessor/grib_accessor_class_number_of_values.cc + accessor/grib_accessor_class_number_of_coded_values.cc + accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc + accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc + accessor/grib_accessor_class_dirty.cc + accessor/grib_accessor_class_statistics.cc + accessor/grib_accessor_class_statistics_spectral.cc + accessor/grib_accessor_class_unsigned.cc + accessor/grib_accessor_class_unsigned_bits.cc + accessor/grib_accessor_class_raw.cc + accessor/grib_accessor_class_bufr_simple_thinning.cc + accessor/grib_accessor_class_bufr_extract_subsets.cc + accessor/grib_accessor_class_bufr_extract_area_subsets.cc + accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc + accessor/grib_accessor_class_spd.cc + accessor/grib_accessor_class_sum.cc + accessor/grib_accessor_class_to_integer.cc + accessor/grib_accessor_class_to_double.cc + accessor/grib_accessor_class_to_string.cc + accessor/grib_accessor_class_sexagesimal2decimal.cc + accessor/grib_accessor_class_vector.cc + accessor/grib_accessor_class_long_vector.cc grib_gaussian_reduced.cc - grib_accessor_class_abstract_vector.cc - grib_accessor_class_abstract_long_vector.cc + accessor/grib_accessor_class_abstract_vector.cc + accessor/grib_accessor_class_abstract_long_vector.cc grib_loader_from_handle.cc grib_bits.cc grib_ibmfloat.cc grib_ieeefloat.cc - grib_accessor_class_reference_value_error.cc + accessor/grib_accessor_class_reference_value_error.cc grib_memory.cc grib_buffer.cc grib_dumper.cc @@ -364,16 +366,16 @@ list( APPEND eccodes_src_files grib_yacc.h md5.h md5.cc - grib_accessor_class_uint16.cc - grib_accessor_class_uint32.cc - grib_accessor_class_uint32_little_endian.cc - grib_accessor_class_uint64.cc - grib_accessor_class_uint64_little_endian.cc - grib_accessor_class_uint8.cc - grib_accessor_class_blob.cc + accessor/grib_accessor_class_uint16.cc + accessor/grib_accessor_class_uint32.cc + accessor/grib_accessor_class_uint32_little_endian.cc + accessor/grib_accessor_class_uint64.cc + accessor/grib_accessor_class_uint64_little_endian.cc + accessor/grib_accessor_class_uint8.cc + accessor/grib_accessor_class_blob.cc grib_optimize_decimal_factor.cc - grib_accessor_class_data_g2bifourier_packing.cc - grib_accessor_class_data_run_length_packing.cc + accessor/grib_accessor_class_data_g2bifourier_packing.cc + accessor/grib_accessor_class_data_run_length_packing.cc eccodes_windef.h # We ship our own generated lex/yacc C files grib_yacc.cc grib_lex.cc ) diff --git a/src/accessor/grib_accessor.cc b/src/accessor/grib_accessor.cc new file mode 100644 index 000000000..23c52c888 --- /dev/null +++ b/src/accessor/grib_accessor.cc @@ -0,0 +1,135 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +/*************************************************************************** + * Jean Baptiste Filippi - 01.11.2005 + ***************************************************************************/ + +#include "grib_accessor.h" +#include + +// Note: A fast cut-down version of strcmp which does NOT return -1 +// 0 means input strings are equal and 1 means not equal +GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) +{ + if (*a != *b) + return 1; + while ((*a != 0 && *b != 0) && *(a) == *(b)) { + a++; + b++; + } + return (*a == 0 && *b == 0) ? 0 : 1; +} + +int grib_accessor::compare_accessors(grib_accessor* a2, int compare_flags) +{ + int ret = 0; + long type1 = 0; + long type2 = 0; + int type_mismatch = 0; + grib_accessor_class* c1 = NULL; + grib_accessor* a1 = this; + + if ((compare_flags & GRIB_COMPARE_NAMES) && grib_inline_strcmp(a1->name, a2->name)) + return GRIB_NAME_MISMATCH; + + if (compare_flags & GRIB_COMPARE_TYPES) { + type1 = a1->get_native_type(); + type2 = a2->get_native_type(); + + type_mismatch = type1 != type2 ? 1 : 0; + } + + // ret = GRIB_UNABLE_TO_COMPARE_ACCESSORS; + c1 = a1->cclass; + ret = c1->compare(a1, a2); + + if (ret == GRIB_VALUE_MISMATCH && type_mismatch) + ret = GRIB_TYPE_AND_VALUE_MISMATCH; + + return ret; +} + +int grib_accessor::add_attribute(grib_accessor* attr, int nest_if_clash) +{ + int id = 0; + int idx = 0; + grib_accessor* pSame = NULL; + grib_accessor* pAloc = this; + + if (this->has_attributes()) { + pSame = this->get_attribute_index(attr->name, &id); + } + + if (pSame) { + if (nest_if_clash == 0) + return GRIB_ATTRIBUTE_CLASH; + pAloc = pSame; + } + + for (id = 0; id < MAX_ACCESSOR_ATTRIBUTES; id++) { + if (pAloc->attributes[id] == NULL) { + // attr->parent=a->parent; + pAloc->attributes[id] = attr; + attr->parent_as_attribute = pAloc; + if (pAloc->same) + attr->same = pAloc->same->get_attribute_index(attr->name, &idx); + + grib_context_log(this->context, GRIB_LOG_DEBUG, "added attribute %s->%s", this->name, attr->name); + return GRIB_SUCCESS; + } + } + return GRIB_TOO_MANY_ATTRIBUTES; +} + +grib_accessor* grib_accessor::get_attribute_index(const char* name, int* index) +{ + int i = 0; + while (i < MAX_ACCESSOR_ATTRIBUTES && this->attributes[i]) { + if (!grib_inline_strcmp(this->attributes[i]->name, name)) { + *index = i; + return this->attributes[i]; + } + i++; + } + return NULL; +} + +int grib_accessor::has_attributes() +{ + return this->attributes[0] ? 1 : 0; +} + +grib_accessor* grib_accessor::get_attribute(const char* name) +{ + int index = 0; + const char* p = 0; + char* basename = NULL; + const char* attribute_name = NULL; + grib_accessor* acc = NULL; + p = name; + while (*(p + 1) != '\0' && (*p != '-' || *(p + 1) != '>')) + p++; + if (*(p + 1) == '\0') { + return this->get_attribute_index(name, &index); + } + else { + size_t size = p - name; + attribute_name = p + 2; + basename = (char*)grib_context_malloc_clear(this->context, size + 1); + basename = (char*)memcpy(basename, name, size); + acc = this->get_attribute_index(basename, &index); + grib_context_free(this->context, basename); + if (acc) + return acc->get_attribute(attribute_name); + else + return NULL; + } +} diff --git a/src/accessor/grib_accessor.h b/src/accessor/grib_accessor.h new file mode 100644 index 000000000..7fe8aad19 --- /dev/null +++ b/src/accessor/grib_accessor.h @@ -0,0 +1,147 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_api_internal.h" +#include "grib_value.h" + +class grib_accessor +{ +public: + grib_accessor() : + name(nullptr), name_space(nullptr), context(nullptr), h(nullptr), creator(nullptr), + length(0), offset(0), parent(nullptr), next_(nullptr), previous_(nullptr), cclass(nullptr), + flags(0), sub_section(nullptr), dirty(0), same(nullptr), loop(0), vvalue(nullptr), + set(nullptr), parent_as_attribute(nullptr) {} + virtual ~grib_accessor() {} + + virtual void init_accessor(const long, grib_arguments*) = 0; + virtual void dump(grib_dumper* f) = 0; + virtual int pack_missing() = 0; + //virtual int grib_pack_zero(grib_accessor* a) = 0; + virtual int is_missing_internal() = 0; + virtual int pack_double(const double* v, size_t* len) = 0; + virtual int pack_float(const float* v, size_t* len) = 0; + virtual int pack_expression(grib_expression* e) = 0; + virtual int pack_string(const char* v, size_t* len) = 0; + virtual int pack_string_array(const char** v, size_t* len) = 0; + virtual int pack_long(const long* v, size_t* len) = 0; + virtual int pack_bytes(const unsigned char* v, size_t* len) = 0; + virtual int unpack_bytes(unsigned char* v, size_t* len) = 0; + virtual int unpack_double_subarray(double* v, size_t start, size_t len) = 0; + virtual int unpack_double(double* v, size_t* len) = 0; + virtual int unpack_float(float* v, size_t* len) = 0; + virtual int unpack_double_element(size_t i, double* v) = 0; + virtual int unpack_float_element(size_t i, float* v) = 0; + virtual int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) = 0; + virtual int unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) = 0; + virtual int unpack_string(char* v, size_t* len) = 0; + virtual int unpack_string_array(char** v, size_t* len) = 0; + virtual int unpack_long(long* v, size_t* len) = 0; + virtual long get_native_type() = 0; + virtual long get_next_position_offset() = 0; + virtual long string_length() = 0; + virtual long byte_offset() = 0; + virtual long byte_count() = 0; + virtual int value_count(long* count) = 0; + virtual int notify_change(grib_accessor* changed) = 0; + virtual grib_accessor* clone(grib_section* s, int* err) = 0; + virtual void update_size(size_t len) = 0; + virtual int nearest_smaller_value(double val, double* nearest) = 0; + virtual size_t preferred_size(int from_handle) = 0; + virtual grib_accessor* next_accessor() = 0; + virtual void resize(size_t new_size) = 0; + virtual void destroy(grib_context* ct) = 0; + + virtual int compare_accessors(grib_accessor* a2, int compare_flags); + virtual int add_attribute(grib_accessor* attr, int nest_if_clash); + virtual grib_accessor* get_attribute_index(const char* name, int* index); + virtual int has_attributes(); + virtual grib_accessor* get_attribute(const char* name); + + + const char* name; /** < name of the accessor */ + const char* name_space; /** < namespace to which the accessor belongs */ + grib_context* context; + grib_handle* h; + grib_action* creator; /** < action that created the accessor */ + long length; /** < byte length of the accessor */ + long offset; /** < offset of the data in the buffer */ + grib_section* parent; /** < section to which the accessor is attached */ + grib_accessor* next_; /** < next accessor in list */ + grib_accessor* previous_; /** < next accessor in list */ + grib_accessor_class* cclass; /** < behaviour of the accessor */ + unsigned long flags; /** < Various flags */ + grib_section* sub_section; + + const char* all_names[MAX_ACCESSOR_NAMES]= {0,}; /** < name of the accessor */ + const char* all_name_spaces[MAX_ACCESSOR_NAMES] = {0,}; /** < namespace to which the accessor belongs */ + int dirty; + + grib_accessor* same; /** < accessors with the same name */ + long loop; /** < used in lists */ + grib_virtual_value* vvalue; /** < virtual value used when transient flag on **/ + const char* set; + grib_accessor* attributes[MAX_ACCESSOR_ATTRIBUTES] = {0,}; /** < attributes are accessors */ + grib_accessor* parent_as_attribute; +}; + + +class grib_accessor_class +{ +public: + const char* name; + + grib_accessor_class(const char* name) : name(name){} + virtual ~grib_accessor_class(){} + + virtual grib_accessor* create_empty_accessor() = 0; + virtual grib_section* sub_section(grib_accessor* a) = 0; + virtual int get_native_type(grib_accessor*) = 0; + virtual int pack_missing(grib_accessor*) = 0; + virtual int is_missing(grib_accessor*) = 0; + virtual int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) = 0; + virtual int pack_double(grib_accessor*, const double* val, size_t* len) = 0; + virtual int pack_float(grib_accessor*, const float* val, size_t* len) = 0; + virtual int pack_long(grib_accessor*, const long* val, size_t* len) = 0; + virtual int pack_string(grib_accessor*, const char*, size_t* len) = 0; + virtual int pack_string_array(grib_accessor*, const char**, size_t* len) = 0; + virtual int pack_expression(grib_accessor*, grib_expression*) = 0; + virtual int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) = 0; + virtual int unpack_double(grib_accessor*, double* val, size_t* len) = 0; + virtual int unpack_float(grib_accessor*, float* val, size_t* len) = 0; + virtual int unpack_long(grib_accessor*, long* val, size_t* len) = 0; + virtual int unpack_string(grib_accessor*, char*, size_t* len) = 0; + virtual int unpack_string_array(grib_accessor*, char**, size_t* len) = 0; + virtual size_t string_length(grib_accessor*) = 0; + virtual long byte_count(grib_accessor*) = 0; + virtual long byte_offset(grib_accessor*) = 0; + virtual long next_offset(grib_accessor*) = 0; + virtual int value_count(grib_accessor*, long*) = 0; + virtual void destroy(grib_context*, grib_accessor*) = 0; + virtual void dump(grib_accessor*, grib_dumper*) = 0; + virtual void init(grib_accessor*, const long, grib_arguments*) = 0; + virtual void post_init(grib_accessor*) = 0; + virtual int notify_change(grib_accessor*, grib_accessor*) = 0; + virtual void update_size(grib_accessor*, size_t) = 0; + virtual size_t preferred_size(grib_accessor*, int) = 0; + virtual void resize(grib_accessor*,size_t) = 0; + virtual int nearest_smaller_value (grib_accessor*, double, double*) = 0; + virtual grib_accessor* next(grib_accessor*, int) = 0; + virtual int compare(grib_accessor*, grib_accessor*) = 0; + virtual int unpack_double_element(grib_accessor*, size_t i, double* val) = 0; + virtual int unpack_float_element(grib_accessor*, size_t i, float* val) = 0; + virtual int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) = 0; + virtual int unpack_float_element_set(grib_accessor*, const size_t* index_array, size_t len, float* val_array) = 0; + virtual int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) = 0; + virtual int clear(grib_accessor*) = 0; + virtual grib_accessor* make_clone(grib_accessor*, grib_section*, int*) = 0; +}; diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.cc b/src/accessor/grib_accessor_class_abstract_long_vector.cc new file mode 100644 index 000000000..0f4514aa1 --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_long_vector.cc @@ -0,0 +1,15 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_abstract_long_vector.h" + +grib_accessor_class_abstract_long_vector_t _grib_accessor_class_abstract_long_vector{"abstract_long_vector"}; +grib_accessor_class* grib_accessor_class_abstract_long_vector = &_grib_accessor_class_abstract_long_vector; diff --git a/src/accessor/grib_accessor_class_abstract_long_vector.h b/src/accessor/grib_accessor_class_abstract_long_vector.h new file mode 100644 index 000000000..94ed9d636 --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_long_vector.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_abstract_long_vector_t : public grib_accessor_gen_t +{ +public: + /* Members defined in abstract_long_vector */ + long* v; + long pack_index; + int number_of_elements; +}; + +class grib_accessor_class_abstract_long_vector_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_abstract_long_vector_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_long_vector_t{}; } +}; diff --git a/src/grib_accessor.h b/src/accessor/grib_accessor_class_abstract_vector.cc similarity index 62% rename from src/grib_accessor.h rename to src/accessor/grib_accessor_class_abstract_vector.cc index 10fa228f7..2ee141e8f 100644 --- a/src/grib_accessor.h +++ b/src/accessor/grib_accessor_class_abstract_vector.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,8 +9,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#pragma once +#include "grib_accessor_class_abstract_vector.h" -#include "grib_api_internal.h" - -template int grib_unpack(grib_accessor* a, T* v, size_t* len); +grib_accessor_class_abstract_vector_t _grib_accessor_class_abstract_vector{"abstract_vector"}; +grib_accessor_class* grib_accessor_class_abstract_vector = &_grib_accessor_class_abstract_vector; diff --git a/src/accessor/grib_accessor_class_abstract_vector.h b/src/accessor/grib_accessor_class_abstract_vector.h new file mode 100644 index 000000000..b721a3adb --- /dev/null +++ b/src/accessor/grib_accessor_class_abstract_vector.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_abstract_vector_t : public grib_accessor_double_t +{ +public: + /* Members defined in abstract_vector */ + double* v; + int number_of_elements; +}; + +class grib_accessor_class_abstract_vector_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_abstract_vector_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_vector_t{}; } +}; diff --git a/src/accessor/grib_accessor_class_ascii.cc b/src/accessor/grib_accessor_class_ascii.cc new file mode 100644 index 000000000..b3e9f6a8a --- /dev/null +++ b/src/accessor/grib_accessor_class_ascii.cc @@ -0,0 +1,179 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_ascii.h" + +grib_accessor_class_ascii_t _grib_accessor_class_ascii{ "ascii" }; +grib_accessor_class* grib_accessor_class_ascii = &_grib_accessor_class_ascii; + + +void grib_accessor_class_ascii_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_gen_t::init(a, len, arg); + a->length = len; + Assert(a->length >= 0); +} + +int grib_accessor_class_ascii_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +size_t grib_accessor_class_ascii_t::string_length(grib_accessor* a) +{ + return a->length; +} + +void grib_accessor_class_ascii_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_ascii_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_ascii_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + grib_handle* hand = grib_handle_of_accessor(a); + const size_t alen = a->length; + + if (*len < (alen + 1)) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, alen + 1, *len); + *len = alen + 1; + return GRIB_BUFFER_TOO_SMALL; + } + + size_t i = 0; + for (i = 0; i < alen; i++) + val[i] = hand->buffer->data[a->offset + i]; + val[i] = 0; + *len = i; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ascii_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ + grib_handle* hand = grib_handle_of_accessor(a); + const size_t alen = a->length; + if (len[0] > (alen + 1)) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "pack_string: Wrong size (%zu) for %s, it contains %ld values", + len[0], a->name, a->length + 1); + len[0] = 0; + return GRIB_BUFFER_TOO_SMALL; + } + + for (size_t i = 0; i < alen; i++) { + if (i < len[0]) + hand->buffer->data[a->offset + i] = val[i]; + else + hand->buffer->data[a->offset + i] = 0; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_ascii_t::pack_long(grib_accessor* a, const long* v, size_t* len) +{ + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as long (It's a string)", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_ascii_t::pack_double(grib_accessor* a, const double* v, size_t* len) +{ + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as double (It's a string)", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_ascii_t::unpack_long(grib_accessor* a, long* v, size_t* len) +{ + char val[1024] = {0,}; + size_t l = sizeof(val); + size_t i = 0; + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + i = 0; + while (i < l - 1 && val[i] == ' ') + i++; + + if (val[i] == 0) { + *v = 0; + return 0; + } + if (val[i + 1] == ' ' && i < l - 2) + val[i + 1] = 0; + + *v = strtol(val, &last, 10); + + grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); + return GRIB_SUCCESS; +} + +int grib_accessor_class_ascii_t::unpack_double(grib_accessor* a, double* v, size_t* len) +{ + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + + int err = a->unpack_string(val, &l); + if (err) return err; + + *v = strtod(val, &last); + + if (*last == 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); + return GRIB_SUCCESS; + } + + grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot unpack %s as double. Hint: Try unpacking as string", a->name); + + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_ascii_t::compare(grib_accessor* a, grib_accessor* b) +{ + int retval = 0; + char* aval = 0; + char* bval = 0; + int err = 0; + + size_t alen = a->length + 1; + size_t blen = b->length + 1; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); + bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); + + err = a->unpack_string(aval, &alen); + if (err) return err; + err = b->unpack_string(bval, &blen); + if (err) return err; + + retval = GRIB_SUCCESS; + if (!STR_EQUAL(aval, bval)) + retval = GRIB_STRING_VALUE_MISMATCH; + + grib_context_free(a->context, aval); + grib_context_free(b->context, bval); + + return retval; +} diff --git a/src/accessor/grib_accessor_class_ascii.h b/src/accessor/grib_accessor_class_ascii.h new file mode 100644 index 000000000..8bef5eaac --- /dev/null +++ b/src/accessor/grib_accessor_class_ascii.h @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_ascii_t : public grib_accessor_gen_t +{ +public: + /* Members defined in ascii */ +}; + +class grib_accessor_class_ascii_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_ascii_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ascii_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_bit.cc b/src/accessor/grib_accessor_class_bit.cc new file mode 100644 index 000000000..c1efac202 --- /dev/null +++ b/src/accessor/grib_accessor_class_bit.cc @@ -0,0 +1,82 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bit.h" + +grib_accessor_class_bit_t _grib_accessor_class_bit{ "bit" }; +grib_accessor_class* grib_accessor_class_bit = &_grib_accessor_class_bit; + + +void grib_accessor_class_bit_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_long_t::init(a, len, arg); + grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; + a->length = 0; + self->owner = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); + self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); +} + +int grib_accessor_class_bit_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; + int ret = 0; + long data = 0; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit_t: unpack_long: Wrong size for %s, it contains %d values ", a->name, 1); + *len = 1; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->owner, &data)) != GRIB_SUCCESS) { + *len = 0; + return ret; + } + + if (data & (1 << self->bit_index)) + *val = 1; + else + *val = 0; + + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_bit_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_bit_t* self = (grib_accessor_bit_t*)a; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit_t: pack_long: At least one value to pack for %s", a->name); + *len = 1; + return GRIB_ARRAY_TOO_SMALL; + } + + grib_accessor* owner = grib_find_accessor(grib_handle_of_accessor(a), self->owner); + if (!owner) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit_t: Cannot get the owner %s for computing the bit value of %s", + self->owner, a->name); + *len = 0; + return GRIB_NOT_FOUND; + } + + unsigned char* mdata = grib_handle_of_accessor(a)->buffer->data; + mdata += owner->byte_offset(); + /* Note: In the definitions, flagbit numbers go from 7 to 0 (the bit_index), while WMO convention is from 1 to 8 */ + if (a->context->debug) { + /* Print bit positions from 1 (MSB) */ + fprintf(stderr, "ECCODES DEBUG Setting bit %d in %s to %d\n", 8 - self->bit_index, owner->name, (*val > 0)); + } + grib_set_bit(mdata, 7 - self->bit_index, *val > 0); + + *len = 1; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_bit.h b/src/accessor/grib_accessor_class_bit.h new file mode 100644 index 000000000..188d5e370 --- /dev/null +++ b/src/accessor/grib_accessor_class_bit.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_bit_t : public grib_accessor_long_t +{ +public: + /* Members defined in bit */ + const char* owner; + int bit_index; +}; + +class grib_accessor_class_bit_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bit_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bit_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc new file mode 100644 index 000000000..05d9db3bf --- /dev/null +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -0,0 +1,189 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bitmap.h" + +grib_accessor_class_bitmap_t _grib_accessor_class_bitmap{ "bitmap" }; +grib_accessor_class* grib_accessor_class_bitmap = &_grib_accessor_class_bitmap; + +static void compute_size(grib_accessor* a) +{ + long slen = 0; + long off = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_accessor_bitmap_t* self = (grib_accessor_bitmap_t*)a; + grib_get_long_internal(hand, self->offsetbsec, &off); + grib_get_long_internal(hand, self->sLength, &slen); + + if (slen == 0) { + grib_accessor* seclen; + size_t size; + /* Assume reparsing */ + Assert(hand->loader != 0); + if (hand->loader != 0) { + seclen = grib_find_accessor(hand, self->sLength); + Assert(seclen); + grib_get_block_length(seclen->parent, &size); + slen = size; + } + } + + // printf("compute_size off=%ld slen=%ld a->offset=%ld\n", (long)off,(long)slen,(long)a->offset); + + a->length = off + (slen - a->offset); + + if (a->length < 0) { + /* Assume reparsing */ + /*Assert(hand->loader != 0);*/ + a->length = 0; + } + + Assert(a->length >= 0); +} + +void grib_accessor_class_bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_bytes_t::init(a, len, arg); + grib_accessor_bitmap_t* self = (grib_accessor_bitmap_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->tableReference = grib_arguments_get_name(hand, arg, n++); + self->missing_value = grib_arguments_get_name(hand, arg, n++); + self->offsetbsec = grib_arguments_get_name(hand, arg, n++); + self->sLength = grib_arguments_get_name(hand, arg, n++); + + compute_size(a); +} + +long grib_accessor_class_bitmap_t::next_offset(grib_accessor* a) +{ + return a->byte_offset() + a->byte_count(); +} + +void grib_accessor_class_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + long len = 0; + char label[1024]; + + a->value_count(&len); + snprintf(label, sizeof(label), "Bitmap of %ld values", len); + grib_dump_bytes(dumper, a, label); +} + +int grib_accessor_class_bitmap_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + long pos = a->offset * 8; + long tlen = 0; + const grib_handle* hand = grib_handle_of_accessor(a); + + int err = a->value_count(&tlen); + if (err) + return err; + + if (*len < tlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); + *len = tlen; + return GRIB_ARRAY_TOO_SMALL; + } + + for (long i = 0; i < tlen; i++) { + val[i] = (long)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); + } + *len = tlen; + return GRIB_SUCCESS; +} + +template +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating points numbers"); + long pos = a->offset * 8; + long tlen; + grib_handle* hand = grib_handle_of_accessor(a); + + int err = a->value_count(&tlen); + if (err) + return err; + + if (*len < tlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); + *len = tlen; + return GRIB_ARRAY_TOO_SMALL; + } + + for (long i = 0; i < tlen; i++) { + val[i] = (T)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); + } + *len = tlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + return unpack(a, val, len); +} + +int grib_accessor_class_bitmap_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ + return unpack(a, val, len); +} + +int grib_accessor_class_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ + long pos = a->offset * 8; + + pos += idx; + *val = (double)grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, 1); + + return GRIB_SUCCESS; +} +int grib_accessor_class_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ + for (size_t i = 0; i < len; ++i) { + unpack_double_element(a, index_array[i], val_array + i); + } + return GRIB_SUCCESS; +} + +void grib_accessor_class_bitmap_t::update_size(grib_accessor* a, size_t s) +{ + a->length = s; +} + +size_t grib_accessor_class_bitmap_t::string_length(grib_accessor* a) +{ + return a->length; +} + +int grib_accessor_class_bitmap_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + grib_handle* hand = grib_handle_of_accessor(a); + const size_t l = a->length; + + if (*len < l) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + for (long i = 0; i < a->length; i++) { + val[i] = hand->buffer->data[a->offset + i]; + } + + *len = a->length; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_bitmap.h b/src/accessor/grib_accessor_class_bitmap.h new file mode 100644 index 000000000..4f07f3a6c --- /dev/null +++ b/src/accessor/grib_accessor_class_bitmap.h @@ -0,0 +1,42 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_bytes.h" + +class grib_accessor_bitmap_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in bitmap */ + const char* tableReference; + const char* missing_value; + const char* offsetbsec; + const char* sLength; +}; + +class grib_accessor_class_bitmap_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_bitmap_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bitmap_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/grib_accessor_class_bits.cc b/src/accessor/grib_accessor_class_bits.cc similarity index 50% rename from src/grib_accessor_class_bits.cc rename to src/accessor/grib_accessor_class_bits.cc index 5e86e2fef..e0a9e7d8d 100644 --- a/src/grib_accessor_class_bits.cc +++ b/src/accessor/grib_accessor_class_bits.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,127 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" - - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = unpack_bytes; byte_count - IMPLEMENTS = unpack_double; pack_double - IMPLEMENTS = unpack_string - IMPLEMENTS = init - MEMBERS=const char* argument - MEMBERS=long start - MEMBERS=long len - MEMBERS=double referenceValue - MEMBERS=double referenceValuePresent - MEMBERS=double scale - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static long byte_count(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bits -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bits */ - const char* argument; - long start; - long len; - double referenceValue; - double referenceValuePresent; - double scale; -} grib_accessor_bits; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bits = { - &grib_accessor_class_gen, /* super */ - "bits", /* name */ - sizeof(grib_accessor_bits), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_bits.h" +grib_accessor_class_bits_t _grib_accessor_class_bits{"bits"}; grib_accessor_class* grib_accessor_class_bits = &_grib_accessor_class_bits; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +void grib_accessor_class_bits_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_handle* hand = grib_handle_of_accessor(a); grib_expression* e = NULL; int n = 0; @@ -154,9 +43,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +int grib_accessor_class_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_accessor* x = NULL; unsigned char* p = NULL; grib_handle* h = grib_handle_of_accessor(a); @@ -173,17 +61,15 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) if (!x) return GRIB_NOT_FOUND; - p = h->buffer->data + grib_byte_offset(x); - *val = grib_decode_unsigned_long(p, &start, length); + p = h->buffer->data + x->byte_offset(); *val = grib_decode_unsigned_long(p, &start, length); *len = 1; return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +int grib_accessor_class_bits_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_accessor* x = NULL; unsigned char* p = NULL; grib_handle* h = grib_handle_of_accessor(a); @@ -200,8 +86,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) if (!x) return GRIB_NOT_FOUND; - p = h->buffer->data + grib_byte_offset(x); - *val = grib_decode_unsigned_long(p, &start, length); + p = h->buffer->data + x->byte_offset(); *val = grib_decode_unsigned_long(p, &start, length); *val = ((long)*val + self->referenceValue) / self->scale; @@ -210,9 +95,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +int grib_accessor_class_bits_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_accessor* x = NULL; grib_handle* h = grib_handle_of_accessor(a); unsigned char* p = NULL; @@ -228,15 +112,13 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if (!x) return GRIB_NOT_FOUND; - p = h->buffer->data + grib_byte_offset(x); - + p = h->buffer->data + x->byte_offset(); lval = round(*val * self->scale) - self->referenceValue; return grib_encode_unsigned_longb(p, lval, &start, length); } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_bits* self = (grib_accessor_bits*)a; +int grib_accessor_class_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; grib_accessor* x = NULL; grib_handle* h = grib_handle_of_accessor(a); unsigned char* p = NULL; @@ -285,14 +167,12 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_ENCODING_ERROR; } - p = h->buffer->data + grib_byte_offset(x); - return grib_encode_unsigned_longb(p, *val, &start, length); + p = h->buffer->data + x->byte_offset(); return grib_encode_unsigned_longb(p, *val, &start, length); } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_bits_t::get_native_type(grib_accessor* a){ int type = GRIB_TYPE_BYTES; - grib_accessor_bits* self = (grib_accessor_bits*)a; + grib_accessor_bits_t* self = (grib_accessor_bits_t*)a; if (a->flags & GRIB_ACCESSOR_FLAG_STRING_TYPE) type = GRIB_TYPE_STRING; @@ -306,13 +186,11 @@ static int get_native_type(grib_accessor* a) return type; } -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ +int grib_accessor_class_bits_t::unpack_string(grib_accessor* a, char* v, size_t* len){ int ret = 0; double dval = 0; long lval = 0; size_t llen = 1; - grib_accessor_class* super = NULL; switch (get_native_type(a)) { case GRIB_TYPE_LONG: @@ -328,20 +206,17 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len) break; default: - super = *(a->cclass->super); - ret = super->unpack_string(a, v, len); + ret = grib_accessor_class_gen_t::unpack_string(a, v, len); } return ret; } -static long byte_count(grib_accessor* a) -{ +long grib_accessor_class_bits_t::byte_count(grib_accessor* a){ grib_context_log(a->context, GRIB_LOG_DEBUG, "byte_count of %s = %ld", a->name, a->length); return a->length; } -static int unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len) -{ +int grib_accessor_class_bits_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len){ if (*len < a->length) { *len = a->length; return GRIB_ARRAY_TOO_SMALL; diff --git a/src/accessor/grib_accessor_class_bits.h b/src/accessor/grib_accessor_class_bits.h new file mode 100644 index 000000000..19ec26b35 --- /dev/null +++ b/src/accessor/grib_accessor_class_bits.h @@ -0,0 +1,42 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bits_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bits */ + const char* argument; + long start; + long len; + double referenceValue; + double referenceValuePresent; + double scale; +}; + +class grib_accessor_class_bits_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bits_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bits_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_bits_per_value.cc b/src/accessor/grib_accessor_class_bits_per_value.cc new file mode 100644 index 000000000..dbdef54cb --- /dev/null +++ b/src/accessor/grib_accessor_class_bits_per_value.cc @@ -0,0 +1,78 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bits_per_value.h" + +grib_accessor_class_bits_per_value_t _grib_accessor_class_bits_per_value{ "bits_per_value" }; +grib_accessor_class* grib_accessor_class_bits_per_value = &_grib_accessor_class_bits_per_value; + + +void grib_accessor_class_bits_per_value_t::init(grib_accessor* a, const long l, grib_arguments* args) +{ + grib_accessor_class_long_t::init(a, l, args); + int n = 0; + grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_bits_per_value_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; + + int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(h, self->bits_per_value, val)) != GRIB_SUCCESS) + return ret; + + *len = 1; + return ret; +} + +int grib_accessor_class_bits_per_value_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_bits_per_value_t* self = (grib_accessor_bits_per_value_t*)a; + + double* values = NULL; + size_t size = 0; + int ret = 0; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->bits_per_value, *val)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_bits_per_value.h b/src/accessor/grib_accessor_class_bits_per_value.h new file mode 100644 index 000000000..741ecd0e5 --- /dev/null +++ b/src/accessor/grib_accessor_class_bits_per_value.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_bits_per_value_t : public grib_accessor_long_t +{ +public: + /* Members defined in bits_per_value */ + const char* values; + const char* bits_per_value; +}; + +class grib_accessor_class_bits_per_value_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bits_per_value_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bits_per_value_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_blob.cc b/src/accessor/grib_accessor_class_blob.cc new file mode 100644 index 000000000..4629de93a --- /dev/null +++ b/src/accessor/grib_accessor_class_blob.cc @@ -0,0 +1,47 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_blob.h" + +grib_accessor_class_blob_t _grib_accessor_class_blob{ "blob" }; +grib_accessor_class* grib_accessor_class_blob = &_grib_accessor_class_blob; + + +void grib_accessor_class_blob_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_gen_t::init(a, len, 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); +} + +int grib_accessor_class_blob_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_BYTES; +} + +int grib_accessor_class_blob_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len) +{ + if (*len < (size_t)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); + + return GRIB_SUCCESS; +} + +void grib_accessor_class_blob_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + grib_dump_bytes(dumper, a, NULL); +} diff --git a/src/accessor/grib_accessor_class_blob.h b/src/accessor/grib_accessor_class_blob.h new file mode 100644 index 000000000..10dad4b7b --- /dev/null +++ b/src/accessor/grib_accessor_class_blob.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_blob_t : public grib_accessor_gen_t +{ +public: + /* Members defined in blob */ +}; + +class grib_accessor_class_blob_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_blob_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_blob_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_budgdate.cc b/src/accessor/grib_accessor_class_budgdate.cc new file mode 100644 index 000000000..4c58c20f2 --- /dev/null +++ b/src/accessor/grib_accessor_class_budgdate.cc @@ -0,0 +1,82 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_budgdate.h" + +grib_accessor_class_budgdate_t _grib_accessor_class_budgdate{"budgdate"}; +grib_accessor_class* grib_accessor_class_budgdate = &_grib_accessor_class_budgdate; + + +void grib_accessor_class_budgdate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_budgdate_t* self = (grib_accessor_budgdate_t*)a; + int n = 0; + + self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_budgdate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + grib_accessor_budgdate_t* self = (grib_accessor_budgdate_t*)a; + + long year = 0; + long month = 0; + long day = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->day, &day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->month, &month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->year, &year)) != GRIB_SUCCESS) + return ret; + + if (*len < 1) + return GRIB_WRONG_ARRAY_SIZE; + + val[0] = (1900 + year) * 10000 + month * 100 + day; + + return ret; +} + +/* TODO: Check for a valid date */ +int grib_accessor_class_budgdate_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int ret = 0; + long v = val[0]; + grib_accessor_budgdate_t* self = (grib_accessor_budgdate_t*)a; + + long year = 0; + long month = 0; + long day = 0; + + if (*len != 1) + return GRIB_WRONG_ARRAY_SIZE; + + year = v / 10000; + v %= 10000; + month = v / 100; + v %= 100; + day = v; + + year -= 1900; + + Assert(year < 255); + + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->year, year)) != GRIB_SUCCESS) + return ret; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_budgdate.h b/src/accessor/grib_accessor_class_budgdate.h new file mode 100644 index 000000000..ee18250e2 --- /dev/null +++ b/src/accessor/grib_accessor_class_budgdate.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_budgdate_t : public grib_accessor_long_t +{ +public: + /* Members defined in budgdate */ + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_budgdate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_budgdate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_budgdate_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc similarity index 89% rename from src/grib_accessor_class_bufr_data_array.cc rename to src/accessor/grib_accessor_class_bufr_data_array.cc index c1bff6ea6..e0c998950 100644 --- a/src/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -9,203 +10,11 @@ */ #include "grib_scaling.h" -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = dump;destroy - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count; value_count - IMPLEMENTS = byte_offset; unpack_double - IMPLEMENTS = get_native_type - IMPLEMENTS = pack_long; unpack_double; pack_double - MEMBERS = const char* bufrDataEncodedName - MEMBERS = const char* numberOfSubsetsName - MEMBERS = const char* expandedDescriptorsName - MEMBERS = const char* flagsName - MEMBERS = const char* unitsName - MEMBERS = const char* elementsDescriptorsIndexName - MEMBERS = const char* compressedDataName - MEMBERS = bufr_descriptors_array* expanded - MEMBERS = grib_accessor* expandedAccessor - MEMBERS = int* canBeMissing - MEMBERS = long numberOfSubsets - MEMBERS = long compressedData - MEMBERS = grib_vdarray* numericValues - MEMBERS = grib_vsarray* stringValues - MEMBERS = grib_viarray* elementsDescriptorsIndex - MEMBERS = int do_decode - MEMBERS = int bitmapStartElementsDescriptorsIndex - MEMBERS = int bitmapCurrentElementsDescriptorsIndex - MEMBERS = int bitmapSize - MEMBERS = int bitmapStart - MEMBERS = int bitmapCurrent - MEMBERS = grib_accessors_list* dataAccessors - MEMBERS = int unpackMode - MEMBERS = int bitsToEndData - MEMBERS = grib_section* dataKeys - MEMBERS = double* inputBitmap - MEMBERS = int nInputBitmap - MEMBERS = int iInputBitmap - MEMBERS = long* inputReplications - MEMBERS = int nInputReplications - MEMBERS = int iInputReplications - MEMBERS = long* inputExtendedReplications - MEMBERS = int nInputExtendedReplications - MEMBERS = int iInputExtendedReplications - MEMBERS = long* inputShortReplications - MEMBERS = int nInputShortReplications - MEMBERS = int iInputShortReplications - MEMBERS = grib_iarray* iss_list - MEMBERS = grib_trie_with_rank* dataAccessorsTrie - MEMBERS = grib_sarray* tempStrings - MEMBERS = grib_vdarray* tempDoubleValues - MEMBERS = int change_ref_value_operand - MEMBERS = size_t refValListSize - MEMBERS = long* refValList - MEMBERS = long refValIndex - MEMBERS = bufr_tableb_override* tableb_override - MEMBERS = int set_to_missing_if_out_of_range - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_data_array -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_data_array */ - const char* bufrDataEncodedName; - const char* numberOfSubsetsName; - const char* expandedDescriptorsName; - const char* flagsName; - const char* unitsName; - const char* elementsDescriptorsIndexName; - const char* compressedDataName; - bufr_descriptors_array* expanded; - grib_accessor* expandedAccessor; - int* canBeMissing; - long numberOfSubsets; - long compressedData; - grib_vdarray* numericValues; - grib_vsarray* stringValues; - grib_viarray* elementsDescriptorsIndex; - int do_decode; - int bitmapStartElementsDescriptorsIndex; - int bitmapCurrentElementsDescriptorsIndex; - int bitmapSize; - int bitmapStart; - int bitmapCurrent; - grib_accessors_list* dataAccessors; - int unpackMode; - int bitsToEndData; - grib_section* dataKeys; - double* inputBitmap; - int nInputBitmap; - int iInputBitmap; - long* inputReplications; - int nInputReplications; - int iInputReplications; - long* inputExtendedReplications; - int nInputExtendedReplications; - int iInputExtendedReplications; - long* inputShortReplications; - int nInputShortReplications; - int iInputShortReplications; - grib_iarray* iss_list; - grib_trie_with_rank* dataAccessorsTrie; - grib_sarray* tempStrings; - grib_vdarray* tempDoubleValues; - int change_ref_value_operand; - size_t refValListSize; - long* refValList; - long refValIndex; - bufr_tableb_override* tableb_override; - int set_to_missing_if_out_of_range; -} grib_accessor_bufr_data_array; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_data_array = { - &grib_accessor_class_gen, /* super */ - "bufr_data_array", /* name */ - sizeof(grib_accessor_bufr_data_array), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_bufr_data_array.h" +grib_accessor_class_bufr_data_array_t _grib_accessor_class_bufr_data_array{"bufr_data_array"}; grib_accessor_class* grib_accessor_class_bufr_data_array = &_grib_accessor_class_bufr_data_array; -/* END_CLASS_IMP */ #define MAX_NESTED_REPLICATIONS 8 @@ -226,33 +35,31 @@ grib_accessor_class* grib_accessor_class_bufr_data_array = &_grib_accessor_class } static int process_elements(grib_accessor* a, int flag, long onlySubset, long startSubset, long endSubset); +typedef int (*codec_element_proc)(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval); +typedef int (*codec_replication_proc)(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions); +static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset); -typedef int (*codec_element_proc)(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval); -typedef int (*codec_replication_proc)(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions); - -static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset); - -static void restart_bitmap(grib_accessor_bufr_data_array* self) +static void restart_bitmap(grib_accessor_bufr_data_array_t* self) { self->bitmapCurrent = -1; self->bitmapCurrentElementsDescriptorsIndex = self->bitmapStartElementsDescriptorsIndex - 1; } -static void cancel_bitmap(grib_accessor_bufr_data_array* self) +static void cancel_bitmap(grib_accessor_bufr_data_array_t* self) { self->bitmapCurrent = -1; self->bitmapStart = -1; } -static int is_bitmap_start_defined(grib_accessor_bufr_data_array* self) +static int is_bitmap_start_defined(grib_accessor_bufr_data_array_t* self) { return self->bitmapStart == -1 ? 0 : 1; } -static size_t get_length(grib_accessor* a) +size_t get_length(grib_accessor* a) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; - size_t len = 0; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; + size_t len = 0; const grib_handle* h = grib_handle_of_accessor(a); @@ -262,7 +69,7 @@ static size_t get_length(grib_accessor* a) } /* Operator 203YYY: Store the TableB code and changed reference value in linked list */ -static void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_data_array* self, int code, long new_ref_val) +static void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_data_array_t* self, int code, long new_ref_val) { bufr_tableb_override* tb = (bufr_tableb_override*)grib_context_malloc_clear(c, sizeof(bufr_tableb_override)); tb->code = code; @@ -280,7 +87,7 @@ static void tableB_override_store_ref_val(grib_context* c, grib_accessor_bufr_da } /* Operator 203YYY: Retrieve changed reference value from linked list */ -static int tableB_override_get_ref_val(grib_accessor_bufr_data_array* self, int code, long* out_ref_val) +static int tableB_override_get_ref_val(grib_accessor_bufr_data_array_t* self, int code, long* out_ref_val) { bufr_tableb_override* p = self->tableb_override; while (p) { @@ -294,7 +101,7 @@ static int tableB_override_get_ref_val(grib_accessor_bufr_data_array* self, int } /* Operator 203YYY: Clear and free linked list */ -static void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array* self) +void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array_t* self) { bufr_tableb_override* tb = self->tableb_override; while (tb) { @@ -306,7 +113,7 @@ static void tableB_override_clear(grib_context* c, grib_accessor_bufr_data_array } /* Operator 203YYY: Copy contents of linked list to the transient array key */ -static int tableB_override_set_key(grib_handle* h, grib_accessor_bufr_data_array* self) +int tableB_override_set_key(grib_handle* h, grib_accessor_bufr_data_array_t* self) { int err = GRIB_SUCCESS; size_t size = 0; @@ -343,7 +150,7 @@ static int check_overridden_reference_values(const grib_context* c, long* refVal return GRIB_SUCCESS; } -// static void tableB_override_dump(grib_accessor_bufr_data_array *self) +// void tableB_override_dump(grib_accessor_bufr_data_array_t *self) // { // bufr_tableb_override* p = self->tableb_override; // int i = 1; @@ -357,9 +164,9 @@ static int check_overridden_reference_values(const grib_context* c, long* refVal #define DYN_ARRAY_SIZE_INIT 1000 /* Initial size for grib_iarray_new and grib_darray_new */ #define DYN_ARRAY_SIZE_INCR 1000 /* Increment size for grib_iarray_new and grib_darray_new */ -static void init(grib_accessor* a, const long v, grib_arguments* params) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +void grib_accessor_class_bufr_data_array_t::init(grib_accessor* a, const long v, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, v, params); + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int n = 0; const char* dataKeysName = NULL; grib_accessor* dataKeysAcc = NULL; @@ -397,7 +204,7 @@ static void init(grib_accessor* a, const long v, grib_arguments* params) /* Assert(a->length>=0); */ } -// static void clean_string(char* s,int len) +// void clean_string(char* s,int len) // { // int i=len-1; // while (i) { @@ -407,7 +214,7 @@ static void init(grib_accessor* a, const long v, grib_arguments* params) // } // } -static int check_end_data(grib_context* c, bufr_descriptor* bd, grib_accessor_bufr_data_array* self, int size) +static int check_end_data(grib_context* c, bufr_descriptor* bd, grib_accessor_bufr_data_array_t* self, int size) { const int saved_bitsToEndData = self->bitsToEndData; if (c->debug == 1) @@ -422,8 +229,7 @@ static int check_end_data(grib_context* c, bufr_descriptor* bd, grib_accessor_bu return 0; } -static void self_clear(grib_context* c, grib_accessor_bufr_data_array* self) -{ +void self_clear(grib_context* c, grib_accessor_bufr_data_array_t* self){ grib_context_free(c, self->canBeMissing); grib_vdarray_delete_content(c, self->numericValues); grib_vdarray_delete(c, self->numericValues); @@ -452,69 +258,63 @@ static void self_clear(grib_context* c, grib_accessor_bufr_data_array* self) if (self->inputBitmap) grib_context_free(c, self->inputBitmap); } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_bufr_data_array_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_DOUBLE; } -static long byte_count(grib_accessor* a) -{ +long grib_accessor_class_bufr_data_array_t::byte_count(grib_accessor* a){ return 0; } -static long byte_offset(grib_accessor* a) -{ +long grib_accessor_class_bufr_data_array_t::byte_offset(grib_accessor* a){ return a->offset; } -static long next_offset(grib_accessor* a) -{ +long grib_accessor_class_bufr_data_array_t::next_offset(grib_accessor* a){ return a->offset; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +int grib_accessor_class_bufr_data_array_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; self->do_decode = 1; return GRIB_NOT_IMPLEMENTED; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +int grib_accessor_class_bufr_data_array_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; self->do_decode = 1; return process_elements(a, PROCESS_ENCODE, 0, 0, 0); } grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; process_elements(a, PROCESS_DECODE, 0, 0, 0); return self->stringValues; } grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; return self->dataAccessors; } grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; return self->dataAccessorsTrie; } void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; self->unpackMode = unpackMode; } static int get_descriptors(grib_accessor* a) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int ret = 0, i, numberOfDescriptors; grib_handle* h = grib_handle_of_accessor(a); grib_context* c = a->context; @@ -540,7 +340,7 @@ static int get_descriptors(grib_accessor* a) } static int decode_string_array(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self) + grib_accessor_bufr_data_array_t* self) { int ret = 0; int* err = &ret; @@ -597,9 +397,9 @@ static int decode_string_array(grib_context* c, unsigned char* data, long* pos, return ret; } -static grib_darray* decode_double_array(grib_context* c, unsigned char* data, long* pos, +grib_darray* decode_double_array(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, int canBeMissing, - grib_accessor_bufr_data_array* self, int* err) + grib_accessor_bufr_data_array_t* self, int* err) { grib_darray* ret = NULL; int j; @@ -681,7 +481,7 @@ static grib_darray* decode_double_array(grib_context* c, unsigned char* data, lo } static int encode_string_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, grib_sarray* stringValues) + grib_accessor_bufr_data_array_t* self, grib_sarray* stringValues) { int err = 0, n, ival; int k, j, modifiedWidth, width; @@ -737,8 +537,7 @@ static int encode_string_array(grib_context* c, grib_buffer* buff, long* pos, bu return err; } -static void set_missing_long_to_double(grib_darray* dvalues) -{ +void set_missing_long_to_double(grib_darray* dvalues){ size_t i, n = grib_darray_used_size(dvalues); for (i = 0; i < n; i++) { if (dvalues->v[i] == GRIB_MISSING_LONG) @@ -764,7 +563,7 @@ static int descriptor_get_min_max(bufr_descriptor* bd, long width, long referenc } static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, grib_darray* dvalues) + grib_accessor_bufr_data_array_t* self, grib_darray* dvalues) { int err = 0; int j, i; @@ -982,7 +781,7 @@ static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bu } static int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, double value) + grib_accessor_bufr_data_array_t* self, double value) { size_t lval; double maxAllowed, minAllowed; @@ -1029,7 +828,7 @@ static int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bu } static int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, char* sval) + grib_accessor_bufr_data_array_t* self, char* sval) { int err = 0; int len; @@ -1045,7 +844,7 @@ static int encode_string_value(grib_context* c, grib_buffer* buff, long* pos, bu } static char* decode_string_value(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, - grib_accessor_bufr_data_array* self, int* err) + grib_accessor_bufr_data_array_t* self, int* err) { char* sval = 0; int len; @@ -1069,7 +868,7 @@ static char* decode_string_value(grib_context* c, unsigned char* data, long* pos static double decode_double_value(grib_context* c, unsigned char* data, long* pos, bufr_descriptor* bd, int canBeMissing, - grib_accessor_bufr_data_array* self, int* err) + grib_accessor_bufr_data_array_t* self, int* err) { size_t lval; int modifiedWidth, modifiedReference; @@ -1098,7 +897,7 @@ static double decode_double_value(grib_context* c, unsigned char* data, long* po return dval; } -static int decode_element(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +static int decode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* b, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -1180,7 +979,7 @@ static int decode_element(grib_context* c, grib_accessor_bufr_data_array* self, return err; } -static int decode_replication(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +static int decode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { int ret = 0; @@ -1245,7 +1044,7 @@ static int decode_replication(grib_context* c, grib_accessor_bufr_data_array* se return ret; } -static int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int idx, grib_accessor_bufr_data_array* self) +static int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int idx, grib_accessor_bufr_data_array_t* self) { grib_darray* doubleValues = NULL; int err = 0; @@ -1268,7 +1067,7 @@ static int encode_new_bitmap(grib_context* c, grib_buffer* buff, long* pos, int } /* Operator 203YYY: Change Reference Values: Encoding definition phase */ -static int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr_data_array* self, +static int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr_data_array_t* self, grib_buffer* buff, long* pos, bufr_descriptor* bd) { int err = 0; @@ -1307,7 +1106,7 @@ static int encode_overridden_reference_value(grib_context* c, grib_accessor_bufr return err; } -static int encode_new_element(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +static int encode_new_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -1367,7 +1166,7 @@ static int encode_new_element(grib_context* c, grib_accessor_bufr_data_array* se return err; } -static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { int err = 0; @@ -1430,7 +1229,7 @@ static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array return err; } -static int encode_element(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +static int encode_element(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, bufr_descriptor* descriptor, long elementIndex, grib_darray* dval, grib_sarray* sval) { @@ -1501,7 +1300,7 @@ static int encode_element(grib_context* c, grib_accessor_bufr_data_array* self, return err; } -static int encode_replication(grib_context* c, grib_accessor_bufr_data_array* self, int subsetIndex, +static int encode_replication(grib_context* c, grib_accessor_bufr_data_array_t* self, int subsetIndex, grib_buffer* buff, unsigned char* data, long* pos, int i, long elementIndex, grib_darray* dval, long* numberOfRepetitions) { @@ -1517,16 +1316,16 @@ static int encode_replication(grib_context* c, grib_accessor_bufr_data_array* se return encode_element(c, self, subsetIndex, buff, data, pos, i, 0, elementIndex, dval, 0); } -static int build_bitmap(grib_accessor_bufr_data_array* self, unsigned char* data, long* pos, +static int build_bitmap(grib_accessor_bufr_data_array_t* self, unsigned char* data, long* pos, int iel, grib_iarray* elementsDescriptorsIndex, int iBitmapOperator) { int bitmapSize = 0, iDelayedReplication = 0; int i, localReference, width, bitmapEndElementsDescriptorsIndex; long ppos, n; - grib_accessor* a = (grib_accessor*)self; - grib_context* c = a->context; + grib_accessor* a = (grib_accessor*)self; + const grib_context* c = a->context; bufr_descriptor** descriptors = self->expanded->v; - long* edi = elementsDescriptorsIndex->v; + const long* edi = elementsDescriptorsIndex->v; /* int iel=grib_iarray_used_size(elementsDescriptorsIndex)-1; */ int err = 0; @@ -1615,7 +1414,7 @@ static int build_bitmap(grib_accessor_bufr_data_array* self, unsigned char* data return GRIB_SUCCESS; } -static int consume_bitmap(grib_accessor_bufr_data_array* self, int iBitmapOperator) +static int consume_bitmap(grib_accessor_bufr_data_array_t* self, int iBitmapOperator) { int bitmapSize = 0, iDelayedReplication; int i; @@ -1646,16 +1445,16 @@ static int consume_bitmap(grib_accessor_bufr_data_array* self, int iBitmapOperat return GRIB_SUCCESS; } -static int build_bitmap_new_data(grib_accessor_bufr_data_array* self, unsigned char* data, long* pos, +static int build_bitmap_new_data(grib_accessor_bufr_data_array_t* self, unsigned char* data, long* pos, int iel, grib_iarray* elementsDescriptorsIndex, int iBitmapOperator) { int bitmapSize = 0, iDelayedReplication = 0; int i, bitmapEndElementsDescriptorsIndex; long n; - grib_accessor* a = (grib_accessor*)self; - grib_context* c = a->context; + grib_accessor* a = (grib_accessor*)self; + const grib_context* c = a->context; bufr_descriptor** descriptors = self->expanded->v; - long* edi = elementsDescriptorsIndex->v; + const long* edi = elementsDescriptorsIndex->v; switch (descriptors[iBitmapOperator]->code) { case 222000: @@ -1733,7 +1532,7 @@ static int build_bitmap_new_data(grib_accessor_bufr_data_array* self, unsigned c } /* ECC-1304: Will return an index if successful. In case of an error, a negative number is returned e.g. GRIB_WRONG_BITMAP_SIZE */ -static int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_array* self, grib_iarray* elementsDescriptorsIndex, int compressedData) +static int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_array_t* self, grib_iarray* elementsDescriptorsIndex, int compressedData) { int i; bufr_descriptor** descriptors = self->expanded->v; @@ -1771,7 +1570,7 @@ static int get_next_bitmap_descriptor_index_new_bitmap(grib_accessor_bufr_data_a } /* ECC-1304: Will return an index if successful. In case of an error, a negative number is returned e.g. GRIB_WRONG_BITMAP_SIZE */ -static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array* self, grib_iarray* elementsDescriptorsIndex, grib_darray* numericValues) +static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array_t* self, grib_iarray* elementsDescriptorsIndex, grib_darray* numericValues) { int i; bufr_descriptor** descriptors = self->expanded->v; @@ -1813,7 +1612,7 @@ static int get_next_bitmap_descriptor_index(grib_accessor_bufr_data_array* self, return elementsDescriptorsIndex->v[self->bitmapCurrentElementsDescriptorsIndex]; } -static void push_zero_element(grib_accessor_bufr_data_array* self, grib_darray* dval) +static void push_zero_element(grib_accessor_bufr_data_array_t* self, grib_darray* dval) { grib_darray* d = 0; grib_accessor* a = (grib_accessor*)self; @@ -1846,19 +1645,16 @@ static grib_accessor* create_attribute_variable(const char* name, grib_section* len = 1; switch (type) { case GRIB_TYPE_LONG: - grib_pack_long(a, &lval, &len); - break; + a->pack_long(&lval, &len); break; case GRIB_TYPE_DOUBLE: - grib_pack_double(a, &dval, &len); - break; + a->pack_double(&dval, &len); break; case GRIB_TYPE_STRING: if (!sval) return NULL; /* Performance: No need for len=strlen(sval). It's not used. */ /* See grib_accessor_class_variable.c, pack_string() */ len = 0; - grib_pack_string(a, sval, &len); - break; + a->pack_string(sval, &len); break; } return a; @@ -1951,7 +1747,7 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr long ide, long subset, int add_dump_flag, int add_coord_flag, int count, int add_extra_attributes) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; char code[10] = {0,}; char* temp_str = NULL; int idx = 0; @@ -2014,13 +1810,13 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr if (attribute->attributes[i]) attribute->attributes[i]->parent=elementAccessor->parent; } */ - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } attribute = create_attribute_variable("index", section, GRIB_TYPE_LONG, 0, 0, count, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code); temp_str = grib_context_strdup(a->context, code); @@ -2028,28 +1824,28 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr if (!attribute) return NULL; grib_sarray_push(a->context, self->tempStrings, temp_str); /* ECC-325: store alloc'd string (due to strdup) for clean up later */ - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); if (add_extra_attributes) { attribute = create_attribute_variable("units", section, GRIB_TYPE_STRING, self->expanded->v[idx]->units, 0, 0, GRIB_ACCESSOR_FLAG_DUMP | flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("scale", section, GRIB_TYPE_LONG, 0, 0, self->expanded->v[idx]->scale, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("reference", section, GRIB_TYPE_DOUBLE, 0, self->expanded->v[idx]->reference, 0, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("width", section, GRIB_TYPE_LONG, 0, 0, self->expanded->v[idx]->width, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } break; case 2: @@ -2071,7 +1867,7 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr attribute = create_attribute_variable("index", section, GRIB_TYPE_LONG, 0, 0, count, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } else { elementAccessor = grib_accessor_factory(section, &operatorCreator, 0, NULL); @@ -2080,13 +1876,13 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr attribute = create_attribute_variable("index", section, GRIB_TYPE_LONG, 0, 0, count, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code); attribute = create_attribute_variable("code", section, GRIB_TYPE_STRING, code, 0, 0, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } self->expanded->v[idx]->a = elementAccessor; break; @@ -2106,34 +1902,34 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr attribute = create_attribute_variable("index", section, GRIB_TYPE_LONG, 0, 0, count, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code); attribute = create_attribute_variable("code", section, GRIB_TYPE_STRING, code, 0, 0, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); if (add_extra_attributes) { attribute = create_attribute_variable("units", section, GRIB_TYPE_STRING, self->expanded->v[idx]->units, 0, 0, GRIB_ACCESSOR_FLAG_DUMP); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("scale", section, GRIB_TYPE_LONG, 0, 0, self->expanded->v[idx]->scale, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("reference", section, GRIB_TYPE_DOUBLE, 0, self->expanded->v[idx]->reference, 0, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); attribute = create_attribute_variable("width", section, GRIB_TYPE_LONG, 0, 0, self->expanded->v[idx]->width, flags); if (!attribute) return NULL; - grib_accessor_add_attribute(elementAccessor, attribute, 0); + elementAccessor->add_attribute(attribute, 0); } break; } @@ -2179,19 +1975,18 @@ static grib_accessor* get_element_from_bitmap(const grib_accessor* a, bitmap_s* while (bitmapVal) { len = 1; if (bitmap->cursor && bitmap->cursor->accessor) { - ret = grib_unpack_long(bitmap->cursor->accessor, &bitmapVal, &len); - } + ret = bitmap->cursor->accessor->unpack_long(&bitmapVal, &len); } else { return NULL; } if (ret != 0) return NULL; - bitmap->cursor = bitmap->cursor->next; + bitmap->cursor = bitmap->cursor->next_; if (bitmap->referredElement) - bitmap->referredElement = bitmap->referredElement->next; + bitmap->referredElement = bitmap->referredElement->next_; } - return bitmap->referredElement ? bitmap->referredElement->prev->accessor : NULL; + return bitmap->referredElement ? bitmap->referredElement->prev_->accessor : NULL; } // static GRIB_INLINE void reset_qualifiers(grib_accessor* significanceQualifierGroup[]) @@ -2211,7 +2006,7 @@ static void grib_convert_to_attribute(grib_accessor* a) /* subsetList can be NULL in which case subsetListSize will be 0 */ static grib_iarray* set_subset_list( - grib_context* c, grib_accessor_bufr_data_array* self, + grib_context* c, grib_accessor_bufr_data_array_t* self, long onlySubset, long startSubset, long endSubset, const long* subsetList, size_t subsetListSize) { grib_iarray* list = grib_iarray_new(c, self->numberOfSubsets, 10); @@ -2258,11 +2053,10 @@ static int bitmap_ref_skip(grib_accessors_list* al, int* err) if (!al || !al->accessor) return 0; - acode = grib_accessor_get_attribute(al->accessor, "code"); + acode = al->accessor->get_attribute("code"); if (acode) - *err = grib_unpack_long(acode, code, &l); - else + *err = acode->unpack_long(code, &l); else return 1; switch (code[0]) { @@ -2291,9 +2085,9 @@ static int is_bitmap_start_descriptor(grib_accessors_list* al, int* err) if (!al || !al->accessor) return 0; - acode = grib_accessor_get_attribute(al->accessor, "code"); + acode = al->accessor->get_attribute("code"); if (acode) - *err = grib_unpack_long(acode, code, &l); + *err = acode->unpack_long(code, &l); else return 1; @@ -2309,7 +2103,7 @@ static int is_bitmap_start_descriptor(grib_accessors_list* al, int* err) { //long index[1]; //grib_accessor* anindex=grib_accessor_get_attribute(al->accessor,"index"); - //grib_unpack_long(anindex,index,&l); + //anindex->unpack_long(index,&l); return 1; } } @@ -2320,7 +2114,7 @@ static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_acce { int i = 0, ret = 0; fprintf(stderr, "ECCODES DEBUG: bitmap_init: bitmapSize=%d\n", bitmapSize); - bitmap->cursor = bitmapStart->next; + bitmap->cursor = bitmapStart->next_; bitmap->referredElement = bitmapStart; while (bitmap_ref_skip(bitmap->referredElement, &ret)) { @@ -2328,7 +2122,7 @@ static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_acce if (is_bitmap_start_descriptor(bitmap->referredElement, &ret)) { is_bmp = 1; } - bitmap->referredElement = bitmap->referredElement->prev; + bitmap->referredElement = bitmap->referredElement->prev_; if (is_bmp) { break; } @@ -2337,7 +2131,7 @@ static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_acce for (i = 1; i < bitmapSize; i++) { if (bitmap->referredElement) { fprintf(stderr, "ECCODES DEBUG:\t bitmap_init: i=%d |%s|\n", i, bitmap->referredElement->accessor->name); - bitmap->referredElement = bitmap->referredElement->prev; + bitmap->referredElement = bitmap->referredElement->prev_; } } } @@ -2346,13 +2140,13 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap, grib_accessors_list* bitmapStart, int bitmapSize, grib_accessors_list* lastAccessorInList) { int ret = 0, i; - bitmap->cursor = bitmapStart->next; + bitmap->cursor = bitmapStart->next_; if (bitmap->referredElementStart != NULL) { bitmap->referredElement = bitmap->referredElementStart; return ret; } bitmap->referredElement = bitmapStart; - /*while (bitmap_ref_skip(bitmap->referredElement,&ret)) bitmap->referredElement=bitmap->referredElement->prev;*/ + /*while (bitmap_ref_skip(bitmap->referredElement,&ret)) bitmap->referredElement=bitmap->referredElement->prev_;*/ /* See ECC-869 * We have to INCLUDE the replication factors that come after the bitmap operators */ @@ -2361,7 +2155,7 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap, if (is_bitmap_start_descriptor(bitmap->referredElement, &ret)) { is_bmp = 1; } - bitmap->referredElement = bitmap->referredElement->prev; + bitmap->referredElement = bitmap->referredElement->prev_; if (is_bmp) { break; } @@ -2375,7 +2169,7 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap, return GRIB_INTERNAL_ERROR; } /*printf(" bitmap_init: i=%d |%s|\n", i,bitmap->referredElement->accessor->name);*/ - bitmap->referredElement = bitmap->referredElement->prev; + bitmap->referredElement = bitmap->referredElement->prev_; } bitmap->referredElementStart = bitmap->referredElement; return ret; @@ -2383,13 +2177,13 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap, static grib_accessor* accessor_or_attribute_with_same_name(grib_accessor* a, const char* name) { - if (grib_accessor_has_attributes(a) == 0) { + if (a->has_attributes() == 0) { return a; } else { grib_accessor* ok = a; grib_accessor* next; - while ((next = grib_accessor_get_attribute(ok, name)) != NULL) { + while ((next = ok->get_attribute(name)) != NULL) { ok = next; } return ok; @@ -2408,14 +2202,14 @@ static grib_accessor* accessor_or_attribute_with_same_name(grib_accessor* a, con // return *r; // } -static int grib_data_accessors_trie_push(grib_trie_with_rank* accessorsTrie, grib_accessor* a) +int grib_data_accessors_trie_push(grib_trie_with_rank* accessorsTrie, grib_accessor* a) { return grib_trie_with_rank_insert(accessorsTrie, a->name, a); } static int create_keys(const grib_accessor* a, long onlySubset, long startSubset, long endSubset) { - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; int err = 0; int rank; grib_accessor* elementAccessor = 0; @@ -2509,7 +2303,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset /*if (associatedFieldAccessor) grib_accessor_delete(c, associatedFieldAccessor);*/ associatedFieldAccessor = NULL; if (associatedFieldSignificanceAccessor) { - grib_accessor_delete(c, associatedFieldSignificanceAccessor); + associatedFieldSignificanceAccessor->destroy(c); associatedFieldSignificanceAccessor = NULL; } for (ide = 0; ide < elementsInSubset; ide++) { @@ -2577,7 +2371,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset //return err; bitmapIndex--; } - bitmapStart[bitmapIndex] = grib_accessors_list_last(self->dataAccessors); + bitmapStart[bitmapIndex] = self->dataAccessors->last(); bitmapSize[bitmapIndex] = 1; if (self->expanded->v[idx - 1]->code == 31002 || self->expanded->v[idx - 1]->code == 31001) extraElement += 1; @@ -2659,11 +2453,10 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset creatorsn.name = (char*)"subsetNumber"; asn = grib_accessor_factory(section, &creatorsn, 0, NULL); accessor_variable_set_type(asn, GRIB_TYPE_LONG); - grib_pack_long(asn, &subsetNumber, &len); - + asn->pack_long(&subsetNumber, &len); grib_push_accessor(asn, section->block); rank = grib_data_accessors_trie_push(self->dataAccessorsTrie, asn); - grib_accessors_list_push(self->dataAccessors, asn, rank); + self->dataAccessors->push(asn, rank); } count++; elementAccessor = create_accessor_from_descriptor(a, associatedFieldAccessor, section, ide, iss, @@ -2681,16 +2474,17 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset if (elementFromBitmap && self->unpackMode == CODES_BUFR_UNPACK_STRUCTURE) { if (descriptor->code != 33007 && descriptor->code != 223255) { char* aname = grib_context_strdup(c, elementFromBitmap->name); - grib_accessor* newAccessor = grib_accessor_clone(elementAccessor, section, &err); + grib_accessor* newAccessor = elementAccessor->clone(section, &err); newAccessor->parent = groupSection; newAccessor->name = aname; grib_sarray_push(a->context, self->tempStrings, aname); grib_push_accessor(newAccessor, groupSection->block); rank = grib_data_accessors_trie_push(self->dataAccessorsTrie, newAccessor); - grib_accessors_list_push(self->dataAccessors, newAccessor, rank); + self->dataAccessors->push(newAccessor, rank); } - err = grib_accessor_add_attribute(accessor_or_attribute_with_same_name(elementFromBitmap, elementAccessor->name), elementAccessor, 1); + //err = grib_accessor_add_attribute(accessor_or_attribute_with_same_name(elementFromBitmap, elementAccessor->name), elementAccessor, 1); + err = accessor_or_attribute_with_same_name(elementFromBitmap, elementAccessor->name)->add_attribute( elementAccessor, 1); } else if (elementAccessor) { int add_key = 1; @@ -2700,17 +2494,17 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset associatedFieldAccessor = elementAccessor; grib_convert_to_attribute(associatedFieldAccessor); if (associatedFieldSignificanceAccessor) { - grib_accessor* newAccessor = grib_accessor_clone(associatedFieldSignificanceAccessor, section, &err); + grib_accessor* newAccessor = associatedFieldSignificanceAccessor->clone(section, &err); if (err) { grib_context_log(a->context, GRIB_LOG_ERROR,"Unable to clone accessor '%s'\n", associatedFieldSignificanceAccessor->name); return err; } - grib_accessor_add_attribute(associatedFieldAccessor, newAccessor, 1); + associatedFieldAccessor->add_attribute(newAccessor, 1); } break; case 31021: if (associatedFieldSignificanceAccessor) - grib_accessor_delete(c, associatedFieldSignificanceAccessor); + associatedFieldSignificanceAccessor->destroy(c); associatedFieldSignificanceAccessor = elementAccessor; break; /*case 33007:*/ @@ -2728,8 +2522,8 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset if (add_key) { grib_push_accessor(elementAccessor, section->block); rank = grib_data_accessors_trie_push(self->dataAccessorsTrie, elementAccessor); - grib_accessors_list_push(self->dataAccessors, elementAccessor, rank); - lastAccessorInList = grib_accessors_list_last(self->dataAccessors); + self->dataAccessors->push(elementAccessor, rank); + lastAccessorInList = self->dataAccessors->last(); } } } @@ -2739,7 +2533,7 @@ static int create_keys(const grib_accessor* a, long onlySubset, long startSubset return err; } -static void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array* self) +static void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array_t* self) { size_t nInputReplications; size_t nInputExtendedReplications; @@ -2785,7 +2579,7 @@ static void set_input_replications(grib_handle* h, grib_accessor_bufr_data_array } } -static void set_input_bitmap(grib_handle* h, grib_accessor_bufr_data_array* self) +static void set_input_bitmap(grib_handle* h, grib_accessor_bufr_data_array_t* self) { size_t nInputBitmap; self->nInputBitmap = -1; @@ -2846,7 +2640,7 @@ static int process_elements(grib_accessor* a, int flag, long onlySubset, long st grib_darray* dval = NULL; grib_sarray* sval = NULL; - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; grib_handle* h = grib_handle_of_accessor(a); grib_context* c = h->context; @@ -3373,19 +3167,17 @@ static int process_elements(grib_accessor* a, int flag, long onlySubset, long st return err; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - // grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a; +void grib_accessor_class_bufr_data_array_t::dump(grib_accessor* a, grib_dumper* dumper){ + // grib_accessor_bufr_data_array_t *self =(grib_accessor_bufr_data_array_t*)a; // int err=process_elements(a,PROCESS_DECODE); // grib_dump_section(dumper,a,self->dataKeys->block); return; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_bufr_data_array_t::value_count(grib_accessor* a, long* count){ int err = 0, l; long i; - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; err = process_elements(a, PROCESS_DECODE, 0, 0, 0); if (err) @@ -3405,13 +3197,12 @@ static int value_count(grib_accessor* a, long* count) return err; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_bufr_data_array_t::unpack_double(grib_accessor* a, double* val, size_t* len){ int err = 0, i, k, ii; int proc_flag = PROCESS_DECODE; size_t l = 0, elementsInSubset; long numberOfSubsets = 0; - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; if (self->unpackMode == CODES_BUFR_NEW_DATA) proc_flag = PROCESS_NEW_DATA; @@ -3459,9 +3250,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return GRIB_SUCCESS; } -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; +void grib_accessor_class_bufr_data_array_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_bufr_data_array_t* self = (grib_accessor_bufr_data_array_t*)a; self_clear(c, self); if (self->dataAccessors) grib_accessors_list_delete(c, self->dataAccessors); @@ -3481,4 +3271,5 @@ static void destroy(grib_context* c, grib_accessor* a) } grib_iarray_delete(self->iss_list); + grib_accessor_class_gen_t::destroy(c, a); } diff --git a/src/accessor/grib_accessor_class_bufr_data_array.h b/src/accessor/grib_accessor_class_bufr_data_array.h new file mode 100644 index 000000000..75d02b9b4 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_data_array.h @@ -0,0 +1,89 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_data_array_t : public grib_accessor_gen_t +{ +public: + const char* bufrDataEncodedName; + const char* numberOfSubsetsName; + const char* expandedDescriptorsName; + const char* flagsName; + const char* unitsName; + const char* elementsDescriptorsIndexName; + const char* compressedDataName; + bufr_descriptors_array* expanded; + grib_accessor* expandedAccessor; + int* canBeMissing; + long numberOfSubsets; + long compressedData; + grib_vdarray* numericValues; + grib_vsarray* stringValues; + grib_viarray* elementsDescriptorsIndex; + int do_decode; + int bitmapStartElementsDescriptorsIndex; + int bitmapCurrentElementsDescriptorsIndex; + int bitmapSize; + int bitmapStart; + int bitmapCurrent; + grib_accessors_list* dataAccessors; + int unpackMode; + int bitsToEndData; + grib_section* dataKeys; + double* inputBitmap; + int nInputBitmap; + int iInputBitmap; + long* inputReplications; + int nInputReplications; + int iInputReplications; + long* inputExtendedReplications; + int nInputExtendedReplications; + int iInputExtendedReplications; + long* inputShortReplications; + int nInputShortReplications; + int iInputShortReplications; + grib_iarray* iss_list; + grib_trie_with_rank* dataAccessorsTrie; + grib_sarray* tempStrings; + grib_vdarray* tempDoubleValues; + int change_ref_value_operand; + size_t refValListSize; + long* refValList; + long refValIndex; + bufr_tableb_override* tableb_override; + int set_to_missing_if_out_of_range; +}; + +class grib_accessor_class_bufr_data_array_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_data_array_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_data_array_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; + +grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); +grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); +grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); +void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); + diff --git a/src/grib_accessor_class_bufr_data_element.cc b/src/accessor/grib_accessor_class_bufr_data_element.cc similarity index 60% rename from src/grib_accessor_class_bufr_data_element.cc rename to src/accessor/grib_accessor_class_bufr_data_element.cc index 1e98e17d9..8d483b96d 100644 --- a/src/grib_accessor_class_bufr_data_element.cc +++ b/src/accessor/grib_accessor_class_bufr_data_element.cc @@ -8,147 +8,22 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - IMPLEMENTS = unpack_string;unpack_string_array;unpack_long; unpack_double - IMPLEMENTS = unpack_double_element ; is_missing - IMPLEMENTS = pack_long; pack_double ; pack_string_array; pack_string; pack_missing - IMPLEMENTS = value_count; get_native_type; make_clone; destroy - MEMBERS = long index - MEMBERS = int type - MEMBERS = long compressedData - MEMBERS = long subsetNumber - MEMBERS = long numberOfSubsets - MEMBERS = bufr_descriptors_array* descriptors - MEMBERS = grib_vdarray* numericValues - MEMBERS = grib_vsarray* stringValues - MEMBERS = grib_viarray* elementsDescriptorsIndex - MEMBERS = char* cname - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_missing(grib_accessor*); -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_string_array(grib_accessor*, const char**, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static grib_accessor* make_clone(grib_accessor*, grib_section*, int*); - -typedef struct grib_accessor_bufr_data_element -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_data_element */ - long index; - int type; - long compressedData; - long subsetNumber; - long numberOfSubsets; - bufr_descriptors_array* descriptors; - grib_vdarray* numericValues; - grib_vsarray* stringValues; - grib_viarray* elementsDescriptorsIndex; - char* cname; -} grib_accessor_bufr_data_element; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_data_element = { - &grib_accessor_class_gen, /* super */ - "bufr_data_element", /* name */ - sizeof(grib_accessor_bufr_data_element), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - &pack_string_array, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - &make_clone, /* clone accessor */ -}; - +#include "grib_accessor_class_bufr_data_element.h" +grib_accessor_class_bufr_data_element_t _grib_accessor_class_bufr_data_element{ "bufr_data_element" }; grib_accessor_class* grib_accessor_class_bufr_data_element = &_grib_accessor_class_bufr_data_element; -/* END_CLASS_IMP */ - -static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) +grib_accessor* grib_accessor_class_bufr_data_element_t::make_clone(grib_accessor* a, grib_section* s, int* err) { grib_accessor* the_clone = NULL; grib_accessor* attribute = NULL; - grib_accessor_bufr_data_element* elementAccessor; - grib_accessor_bufr_data_element* self; + grib_accessor_bufr_data_element_t* elementAccessor; + grib_accessor_bufr_data_element_t* self; char* copied_name = NULL; int i; - grib_action creator = {0,}; + grib_action creator = { + 0, + }; creator.op = (char*)"bufr_data_element"; creator.name_space = (char*)""; creator.set = 0; @@ -161,8 +36,8 @@ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) the_clone = grib_accessor_factory(s, &creator, 0, NULL); copied_name = grib_context_strdup(a->context, a->name); the_clone->name = copied_name; - elementAccessor = (grib_accessor_bufr_data_element*)the_clone; - self = (grib_accessor_bufr_data_element*)a; + elementAccessor = (grib_accessor_bufr_data_element_t*)the_clone; + self = (grib_accessor_bufr_data_element_t*)a; the_clone->flags = a->flags; the_clone->parent = NULL; the_clone->h = s->h; @@ -179,9 +54,9 @@ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) i = 0; while (a->attributes[i]) { - attribute = grib_accessor_clone(a->attributes[i], s, err); + attribute = a->attributes[i]->clone(s, err); /* attribute->parent=a->parent; */ - grib_accessor_add_attribute(the_clone, attribute, 0); + the_clone->add_attribute(attribute, 0); i++; } @@ -190,68 +65,69 @@ static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) void accessor_bufr_data_element_set_index(grib_accessor* a, long index) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->index = index; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->index = index; } void accessor_bufr_data_element_set_type(grib_accessor* a, int type) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->type = type; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->type = type; } void accessor_bufr_data_element_set_numberOfSubsets(grib_accessor* a, long numberOfSubsets) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->numberOfSubsets = numberOfSubsets; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->numberOfSubsets = numberOfSubsets; } void accessor_bufr_data_element_set_subsetNumber(grib_accessor* a, long subsetNumber) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->subsetNumber = subsetNumber; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->subsetNumber = subsetNumber; } void accessor_bufr_data_element_set_compressedData(grib_accessor* a, int compressedData) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->compressedData = compressedData; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->compressedData = compressedData; } void accessor_bufr_data_element_set_descriptors(grib_accessor* a, bufr_descriptors_array* descriptors) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->descriptors = descriptors; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->descriptors = descriptors; } void accessor_bufr_data_element_set_numericValues(grib_accessor* a, grib_vdarray* numericValues) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->numericValues = numericValues; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->numericValues = numericValues; } void accessor_bufr_data_element_set_stringValues(grib_accessor* a, grib_vsarray* stringValues) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->stringValues = stringValues; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->stringValues = stringValues; } void accessor_bufr_data_element_set_elementsDescriptorsIndex(grib_accessor* a, grib_viarray* elementsDescriptorsIndex) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - self->elementsDescriptorsIndex = elementsDescriptorsIndex; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + self->elementsDescriptorsIndex = elementsDescriptorsIndex; } -static void init(grib_accessor* a, const long len, grib_arguments* params) +void grib_accessor_class_bufr_data_element_t::init(grib_accessor* a, const long len, grib_arguments* params) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - a->length = 0; + grib_accessor_class_gen_t::init(a, len, params); + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_BUFR_DATA; /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ self->cname = NULL; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_bufr_data_element_t::dump(grib_accessor* a, grib_dumper* dumper) { int type = get_native_type(a); @@ -268,12 +144,12 @@ static void dump(grib_accessor* a, grib_dumper* dumper) } } -static int unpack_string_array(grib_accessor* a, char** val, size_t* len) +int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* a, char** val, size_t* len) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = 0, i, idx; - long count = 0; + int ret = 0, idx = 0; + size_t count = 0, i = 0; grib_context* c = a->context; if (self->compressedData) { @@ -297,18 +173,18 @@ static int unpack_string_array(grib_accessor* a, char** val, size_t* len) return ret; } -static int pack_string_array(grib_accessor* a, const char** v, size_t* len) +int grib_accessor_class_bufr_data_element_t::pack_string_array(grib_accessor* a, const char** v, size_t* len) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS, idx = 0; - size_t i = 0; - char* s = NULL; + size_t i = 0; + char* s = NULL; grib_context* c = a->context; if (self->compressedData) { idx = ((int)self->numericValues->v[self->index]->v[0] / 1000 - 1) / self->numberOfSubsets; - if (*len != 1 && *len != self->numberOfSubsets) { + if (*len != 1 && *len != (size_t)self->numberOfSubsets) { grib_context_log(c, GRIB_LOG_ERROR, "Number of values mismatch for '%s': %ld strings provided but expected %ld (=number of subsets)", self->descriptors->v[self->elementsDescriptorsIndex->v[0]->v[idx]]->shortName, *len, self->numberOfSubsets); return GRIB_ARRAY_TOO_SMALL; @@ -322,32 +198,32 @@ static int pack_string_array(grib_accessor* a, const char** v, size_t* len) } } else { - //ECC-1623 - if (*len != self->numberOfSubsets) { + // ECC-1623 + if (*len != (size_t)self->numberOfSubsets) { grib_context_log(c, GRIB_LOG_ERROR, - "Number of values mismatch for '%s': %zu strings provided but expected %ld (=number of subsets)", - a->name, *len, self->numberOfSubsets); + "Number of values mismatch for '%s': %zu strings provided but expected %ld (=number of subsets)", + a->name, *len, self->numberOfSubsets); return GRIB_WRONG_ARRAY_SIZE; } for (i = 0; i < *len; i++) { - //idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; - idx = (int)self->numericValues->v[i]->v[self->index] / 1000 - 1; + // idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; + idx = (int)self->numericValues->v[i]->v[self->index] / 1000 - 1; self->stringValues->v[idx]->v[0] = strdup(v[i]); } - *len=1; + *len = 1; } return ret; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) +int grib_accessor_class_bufr_data_element_t::unpack_string(grib_accessor* a, char* val, size_t* len) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - char* str = NULL; - char* p = 0; - size_t slen = 0; - double dval = 0; - size_t dlen = 1; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + char* str = NULL; + char* p = 0; + size_t slen = 0; + double dval = 0; + size_t dlen = 1; int idx = 0, err = 0; grib_context* c = a->context; @@ -409,11 +285,11 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) +int grib_accessor_class_bufr_data_element_t::pack_string(grib_accessor* a, const char* val, size_t* len) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS, idx = 0; + int ret = GRIB_SUCCESS, idx = 0; char* s = NULL; grib_context* c = a->context; @@ -432,10 +308,10 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_bufr_data_element_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - int ret = GRIB_SUCCESS; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + int ret = GRIB_SUCCESS; long count = 0, i = 0; value_count(a, &count); @@ -461,10 +337,10 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_bufr_data_element_t::unpack_double(grib_accessor* a, double* val, size_t* len) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - int ret = GRIB_SUCCESS; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + int ret = GRIB_SUCCESS; long count = 0, i = 0; value_count(a, &count); @@ -490,16 +366,16 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_bufr_data_element_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - int ret = GRIB_SUCCESS; - long count = 1, i = 0; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + int ret = GRIB_SUCCESS; + size_t count = 1, i = 0; grib_context* c = a->context; if (self->compressedData) { count = *len; - if (count != 1 && count != self->numberOfSubsets) { + if (count != 1 && count != (size_t)self->numberOfSubsets) { grib_context_log(c, GRIB_LOG_ERROR, "Number of values mismatch for '%s': %ld doubles provided but expected %ld (=number of subsets)", self->descriptors->v[self->elementsDescriptorsIndex->v[0]->v[self->index]]->shortName, count, self->numberOfSubsets); return GRIB_ARRAY_TOO_SMALL; @@ -520,17 +396,17 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_bufr_data_element_t::pack_long(grib_accessor* a, const long* val, size_t* len) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - int ret = 0, i; - long count = 1; - grib_context* c = a->context; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + int ret = 0; + size_t count = 1, i = 0; + grib_context* c = a->context; if (self->compressedData) { count = *len; - if (count != 1 && count != self->numberOfSubsets) { - grib_context_log(c, GRIB_LOG_ERROR, "Number of values mismatch for '%s': %ld integers provided but expected %ld (=number of subsets)", + if (count != 1 && count != (size_t)self->numberOfSubsets) { + grib_context_log(c, GRIB_LOG_ERROR, "Number of values mismatch for '%s': %zu integers provided but expected %ld (=number of subsets)", self->descriptors->v[self->elementsDescriptorsIndex->v[0]->v[self->index]]->shortName, count, self->numberOfSubsets); return GRIB_ARRAY_TOO_SMALL; } @@ -550,11 +426,11 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return ret; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_bufr_data_element_t::value_count(grib_accessor* a, long* count) { - int ret = 0, type = 0, idx = 0; - size_t size = 0; - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; + int ret = 0, type = 0, idx = 0; + size_t size = 0; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; if (!self->compressedData) { *count = 1; @@ -577,12 +453,12 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) +int grib_accessor_class_bufr_data_element_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) { /* ECC-415 */ - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - int ret = GRIB_SUCCESS; - long count = 0; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + int ret = GRIB_SUCCESS; + long count = 0; value_count(a, &count); if (idx >= (size_t)count) { @@ -598,10 +474,10 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return ret; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_bufr_data_element_t::get_native_type(grib_accessor* a) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - int ret = GRIB_TYPE_DOUBLE; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + int ret = GRIB_TYPE_DOUBLE; DEBUG_ASSERT(self); switch (self->type) { case BUFR_DESCRIPTOR_TYPE_STRING: @@ -624,24 +500,25 @@ static int get_native_type(grib_accessor* a) return ret; } -static void destroy(grib_context* ct, grib_accessor* a) +void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_accessor* a) { - grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a; - int i = 0; + grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; + int i = 0; if (self->cname) grib_context_free(ct, self->cname); /* ECC-765 */ while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { /*grib_context_log(ct,GRIB_LOG_DEBUG,"deleting attribute %s->%s",a->name,a->attributes[i]->name);*/ /*printf("bufr_data_element destroy %s %p\n", a->attributes[i]->name, (void*)a->attributes[i]);*/ - grib_accessor_delete(ct, a->attributes[i]); + a->attributes[i]->destroy(ct); a->attributes[i] = NULL; i++; } + grib_accessor_class_gen_t::destroy(ct, a); } #define MAX_STRING_SIZE 4096 /* Return 1 if BUFR element(s) is/are missing, 0 otherwise. In case of decoding errors, also return 0 */ -static int is_missing(grib_accessor* a) +int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a) { const int ktype = get_native_type(a); int err = 0, result = 1; /* default: assume all are missing */ @@ -650,17 +527,17 @@ static int is_missing(grib_accessor* a) grib_context* c = a->context; if (ktype == GRIB_TYPE_LONG) { - long* values = NULL; - long value = 0; + long* values = NULL; + long value = 0; value_count(a, &count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(c, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } if (err) return 0; /* TODO: no way of propagating the error up */ Assert(size2 == size); @@ -672,22 +549,23 @@ static int is_missing(grib_accessor* a) } } grib_context_free(c, values); - } else { + } + else { result = grib_is_missing_long(a, value); } } else if (ktype == GRIB_TYPE_DOUBLE) { - double value = 0; - double* values = NULL; + double value = 0; + double* values = NULL; value_count(a, &count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } if (err) return 0; /* TODO: no way of propagating the error up */ Assert(size2 == size); @@ -705,12 +583,12 @@ static int is_missing(grib_accessor* a) } } else if (ktype == GRIB_TYPE_STRING) { - char** values = NULL; + char** values = NULL; value_count(a, &count); size = count; if (size > 1) { values = (char**)grib_context_malloc_clear(a->context, size * sizeof(char*)); - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); if (err) return 0; /* TODO: no way of propagating the error up */ for (i = 0; i < size; i++) { if (!grib_is_missing_string(a, (unsigned char*)values[i], size)) { @@ -718,12 +596,14 @@ static int is_missing(grib_accessor* a) break; } } - for (i = 0; i < size; i++) grib_context_free(c, values[i]); + for (i = 0; i < size; i++) + grib_context_free(c, values[i]); grib_context_free(c, values); - } else { + } + else { char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */ size = MAX_STRING_SIZE; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); if (err) return 0; /* TODO: no way of propagating the error up */ result = grib_is_missing_string(a, (unsigned char*)value, size); } @@ -734,11 +614,11 @@ static int is_missing(grib_accessor* a) return result; } -static int pack_missing(grib_accessor* a) +int grib_accessor_class_bufr_data_element_t::pack_missing(grib_accessor* a) { - int ktype = GRIB_TYPE_UNDEFINED; - int err = 0; - size_t size = 1; + int ktype = GRIB_TYPE_UNDEFINED; + int err = 0; + size_t size = 1; const int can_be_missing = (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING); if (!can_be_missing) return GRIB_VALUE_CANNOT_BE_MISSING; @@ -746,11 +626,11 @@ static int pack_missing(grib_accessor* a) ktype = get_native_type(a); if (ktype == GRIB_TYPE_LONG) { long missing = GRIB_MISSING_LONG; - err = pack_long(a, &missing, &size); + err = pack_long(a, &missing, &size); } else if (ktype == GRIB_TYPE_DOUBLE) { double missing = GRIB_MISSING_DOUBLE; - err = pack_double(a, &missing, &size); + err = pack_double(a, &missing, &size); } else if (ktype == GRIB_TYPE_STRING) { err = pack_string(a, "", &size); diff --git a/src/accessor/grib_accessor_class_bufr_data_element.h b/src/accessor/grib_accessor_class_bufr_data_element.h new file mode 100644 index 000000000..bbed1785b --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_data_element.h @@ -0,0 +1,54 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_data_element_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_data_element */ + long index; + int type; + long compressedData; + long subsetNumber; + long numberOfSubsets; + bufr_descriptors_array* descriptors; + grib_vdarray* numericValues; + grib_vsarray* stringValues; + grib_viarray* elementsDescriptorsIndex; + char* cname; +}; + +class grib_accessor_class_bufr_data_element_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_data_element_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_data_element_t{}; } + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_string_array(grib_accessor*, const char**, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; +}; diff --git a/src/grib_accessor_class_bufr_elements_table.cc b/src/accessor/grib_accessor_class_bufr_elements_table.cc similarity index 62% rename from src/grib_accessor_class_bufr_elements_table.cc rename to src/accessor/grib_accessor_class_bufr_elements_table.cc index cee7049aa..ddd055544 100644 --- a/src/grib_accessor_class_bufr_elements_table.cc +++ b/src/accessor/grib_accessor_class_bufr_elements_table.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,12 +9,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - +#include "grib_accessor_class_bufr_elements_table.h" #include "grib_scaling.h" -#include "grib_api_internal.h" #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; @@ -31,7 +28,7 @@ static void thread_init() static int once = 0; static omp_nest_lock_t mutex1; -static void thread_init() +void thread_init() { GRIB_OMP_CRITICAL(lock_grib_accessor_class_bufr_elements_table_c) { @@ -43,107 +40,16 @@ static void thread_init() } #endif -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string;unpack_long;unpack_double - IMPLEMENTS = value_count; get_native_type; - MEMBERS = const char* dictionary - MEMBERS = const char* masterDir - MEMBERS = const char* localDir - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_elements_table -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_elements_table */ - const char* dictionary; - const char* masterDir; - const char* localDir; -} grib_accessor_bufr_elements_table; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_elements_table = { - &grib_accessor_class_gen, /* super */ - "bufr_elements_table", /* name */ - sizeof(grib_accessor_bufr_elements_table), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_bufr_elements_table_t _grib_accessor_class_bufr_elements_table{ "bufr_elements_table" }; grib_accessor_class* grib_accessor_class_bufr_elements_table = &_grib_accessor_class_bufr_elements_table; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* params) +void grib_accessor_class_bufr_elements_table_t::init(grib_accessor* a, const long len, grib_arguments* params) { - int n = 0; - grib_accessor_bufr_elements_table* self = (grib_accessor_bufr_elements_table*)a; + grib_accessor_class_gen_t::init(a, len, params); + int n = 0; + grib_accessor_bufr_elements_table_t* self = (grib_accessor_bufr_elements_table_t*)a; self->dictionary = grib_arguments_get_string(grib_handle_of_accessor(a), params, n++); self->masterDir = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); @@ -155,7 +61,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) { - grib_accessor_bufr_elements_table* self = (grib_accessor_bufr_elements_table*)a; + grib_accessor_bufr_elements_table_t* self = (grib_accessor_bufr_elements_table_t*)a; char* filename = NULL; char line[1024] = {0,}; @@ -163,7 +69,9 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) char localDir[1024] = {0,}; char dictName[1024] = {0,}; char masterRecomposed[1024] = {0,}; /*e.g. bufr/tables/0/wmo/36/element.table */ - char localRecomposed[1024] = {0,}; /*e.g. bufr/tables/0/local/0/98/0/element.table */ + char localRecomposed[1024] = { + 0, + }; /*e.g. bufr/tables/0/local/0/98/0/element.table */ char* localFilename = 0; char** list = 0; char** cached_list = 0; @@ -208,9 +116,9 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) if (!filename) { grib_context_log(c, GRIB_LOG_ERROR, "Unable to find definition file %s", self->dictionary); - if (strlen(masterRecomposed) > 0) grib_context_log(c, GRIB_LOG_DEBUG,"master path=%s", masterRecomposed); + if (strlen(masterRecomposed) > 0) grib_context_log(c, GRIB_LOG_DEBUG, "master path=%s", masterRecomposed); if (strlen(localRecomposed) > 0) grib_context_log(c, GRIB_LOG_DEBUG, "local path=%s", localRecomposed); - *err = GRIB_FILE_NOT_FOUND; + *err = GRIB_FILE_NOT_FOUND; dictionary = NULL; goto the_end; } @@ -234,7 +142,7 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) dictionary = grib_trie_new(c); while (fgets(line, sizeof(line) - 1, f)) { - DEBUG_ASSERT( strlen(line) > 0 ); + DEBUG_ASSERT(strlen(line) > 0); if (line[0] == '#') continue; /* Ignore first line with column titles */ list = string_split(line, "|"); grib_trie_insert(dictionary, list[0], list); @@ -251,14 +159,15 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err) } while (fgets(line, sizeof(line) - 1, f)) { - DEBUG_ASSERT( strlen(line) > 0 ); - if (line[0] == '#') continue; /* Ignore first line with column titles */ + DEBUG_ASSERT(strlen(line) > 0); + if (line[0] == '#') continue; /* Ignore first line with column titles */ list = string_split(line, "|"); /* Look for the descriptor code in the trie. It might be there from before */ cached_list = (char**)grib_trie_get(dictionary, list[0]); if (cached_list) { /* If found, we are about to overwrite it. So free memory */ int i; - for (i = 0; cached_list[i] != NULL; ++i) free(cached_list[i]); + for (i = 0; cached_list[i] != NULL; ++i) + free(cached_list[i]); free(cached_list); } grib_trie_insert(dictionary, list[0], list); @@ -304,17 +213,18 @@ static int convert_type(const char* stype) return ret; } -static long atol_fast(const char* input) +long atol_fast(const char* input) { if (strcmp(input, "0") == 0) return 0; return atol(input); } -static int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v) + +int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v) { - int ret = 0; - char** list = 0; - char code[7] = { 0 }; + int ret = 0; + char** list = 0; + char code[7] = { 0 }; const size_t codeLen = sizeof(code); grib_trie* table = load_bufr_elements_table(a, &ret); @@ -332,8 +242,8 @@ static int bufr_get_from_table(grib_accessor* a, bufr_descriptor* v) /* ECC-1137: check descriptor key name and unit lengths */ const size_t maxlen_shortName = sizeof(v->shortName); const size_t maxlen_units = sizeof(v->units); - Assert( strlen(list[1]) < maxlen_shortName ); - Assert( strlen(list[4]) < maxlen_units ); + Assert(strlen(list[1]) < maxlen_shortName); + Assert(strlen(list[4]) < maxlen_units); } #endif @@ -379,8 +289,7 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i DEBUG_ASSERT(c); v = (bufr_descriptor*)grib_context_malloc_clear(c, sizeof(bufr_descriptor)); if (!v) { - grib_context_log(c, GRIB_LOG_ERROR, - "accessor_bufr_elements_table_get_descriptor: unable to allocate %ld bytes\n", sizeof(bufr_descriptor)); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptor)); *err = GRIB_OUT_OF_MEMORY; return NULL; } @@ -408,28 +317,28 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i return v; } -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) +int grib_accessor_class_bufr_elements_table_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) { return GRIB_NOT_IMPLEMENTED; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_bufr_elements_table_t::value_count(grib_accessor* a, long* count) { *count = 1; return 0; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_bufr_elements_table_t::get_native_type(grib_accessor* a) { return GRIB_TYPE_STRING; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_bufr_elements_table_t::unpack_long(grib_accessor* a, long* val, size_t* len) { return GRIB_NOT_IMPLEMENTED; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_bufr_elements_table_t::unpack_double(grib_accessor* a, double* val, size_t* len) { return GRIB_NOT_IMPLEMENTED; } diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.h b/src/accessor/grib_accessor_class_bufr_elements_table.h new file mode 100644 index 000000000..4f133c9e4 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_elements_table.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_elements_table_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_elements_table */ + const char* dictionary; + const char* masterDir; + const char* localDir; +}; + +class grib_accessor_class_bufr_elements_table_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_elements_table_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_elements_table_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_bufr_extract_area_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc similarity index 55% rename from src/grib_accessor_class_bufr_extract_area_subsets.cc rename to src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc index 473a5148d..91a34c72c 100644 --- a/src/grib_accessor_class_bufr_extract_area_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,120 +9,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init; get_native_type - IMPLEMENTS = pack_long; - MEMBERS = const char* doExtractSubsets - MEMBERS = const char* numberOfSubsets - MEMBERS = const char* extractSubsetList - MEMBERS = const char* extractAreaWestLongitude - MEMBERS = const char* extractAreaEastLongitude - MEMBERS = const char* extractAreaNorthLatitude - MEMBERS = const char* extractAreaSouthLatitude - MEMBERS = const char* extractAreaLongitudeRank - MEMBERS = const char* extractAreaLatitudeRank - MEMBERS = const char* extractedAreaNumberOfSubsets - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_extract_area_subsets -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_extract_area_subsets */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; - const char* extractAreaWestLongitude; - const char* extractAreaEastLongitude; - const char* extractAreaNorthLatitude; - const char* extractAreaSouthLatitude; - const char* extractAreaLongitudeRank; - const char* extractAreaLatitudeRank; - const char* extractedAreaNumberOfSubsets; -} grib_accessor_bufr_extract_area_subsets; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_extract_area_subsets = { - &grib_accessor_class_gen, /* super */ - "bufr_extract_area_subsets", /* name */ - sizeof(grib_accessor_bufr_extract_area_subsets), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_bufr_extract_area_subsets.h" +grib_accessor_class_bufr_extract_area_subsets_t _grib_accessor_class_bufr_extract_area_subsets{ "bufr_extract_area_subsets" }; grib_accessor_class* grib_accessor_class_bufr_extract_area_subsets = &_grib_accessor_class_bufr_extract_area_subsets; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) +void grib_accessor_class_bufr_extract_area_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg) { - grib_accessor_bufr_extract_area_subsets* self = (grib_accessor_bufr_extract_area_subsets*)a; - grib_handle* h = grib_handle_of_accessor(a); - int n = 0; + grib_accessor_class_gen_t::init(a, len, arg); + grib_accessor_bufr_extract_area_subsets_t* self = (grib_accessor_bufr_extract_area_subsets_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int n = 0; a->length = 0; self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); @@ -138,7 +37,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_bufr_extract_area_subsets_t::get_native_type(grib_accessor* a) { return GRIB_TYPE_LONG; } @@ -153,11 +52,11 @@ static void fill_in(double a[], long length) static int select_area(grib_accessor* a) { - grib_accessor_bufr_extract_area_subsets* self = (grib_accessor_bufr_extract_area_subsets*)a; + grib_accessor_bufr_extract_area_subsets_t* self = (grib_accessor_bufr_extract_area_subsets_t*)a; - int ret = 0; + int ret = 0; long compressed = 0; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); grib_context* c = h->context; double* lat = NULL; @@ -166,8 +65,8 @@ static int select_area(grib_accessor* a) double lonWest, lonEast, latNorth, latSouth; long numberOfSubsets, i, latRank, lonRank; grib_iarray* subsets = NULL; - size_t nsubsets = 0; - char latstr[32] = {0,}; + size_t nsubsets = 0; + char latstr[32] = {0,}; char lonstr[32] = {0,}; ret = grib_get_long(h, "compressedData", &compressed); @@ -265,7 +164,7 @@ static int select_area(grib_accessor* a) if (nsubsets != 0) { long* subsets_ar = grib_iarray_get_array(subsets); - ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); grib_context_free(c, subsets_ar); if (ret) return ret; @@ -281,9 +180,9 @@ static int select_area(grib_accessor* a) return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_bufr_extract_area_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len) { - /*grib_accessor_bufr_extract_area_subsets *self =(grib_accessor_bufr_extract_area_subsets*)a;*/ + /*grib_accessor_bufr_extract_area_subsets_t *self =(grib_accessor_bufr_extract_area_subsets_t*)a;*/ if (*len == 0) return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h new file mode 100644 index 000000000..941f38ac0 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.h @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_area_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_area_subsets */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; + const char* extractAreaWestLongitude; + const char* extractAreaEastLongitude; + const char* extractAreaNorthLatitude; + const char* extractAreaSouthLatitude; + const char* extractAreaLongitudeRank; + const char* extractAreaLatitudeRank; + const char* extractedAreaNumberOfSubsets; +}; + +class grib_accessor_class_bufr_extract_area_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_area_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_area_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_bufr_extract_datetime_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc similarity index 71% rename from src/grib_accessor_class_bufr_extract_datetime_subsets.cc rename to src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc index d5ec98bf6..d47652984 100644 --- a/src/grib_accessor_class_bufr_extract_datetime_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,105 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init; get_native_type - IMPLEMENTS = pack_long; - MEMBERS = const char* doExtractSubsets - MEMBERS = const char* numberOfSubsets - MEMBERS = const char* extractSubsetList - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_extract_datetime_subsets -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_extract_datetime_subsets */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; -} grib_accessor_bufr_extract_datetime_subsets; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_extract_datetime_subsets = { - &grib_accessor_class_gen, /* super */ - "bufr_extract_datetime_subsets", /* name */ - sizeof(grib_accessor_bufr_extract_datetime_subsets), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_bufr_extract_datetime_subsets.h" +grib_accessor_class_bufr_extract_datetime_subsets_t _grib_accessor_class_bufr_extract_datetime_subsets{ "bufr_extract_datetime_subsets" }; grib_accessor_class* grib_accessor_class_bufr_extract_datetime_subsets = &_grib_accessor_class_bufr_extract_datetime_subsets; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) +void grib_accessor_class_bufr_extract_datetime_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg) { - int n = 0; - grib_accessor_bufr_extract_datetime_subsets* self = (grib_accessor_bufr_extract_datetime_subsets*)a; + grib_accessor_class_gen_t::init(a, len, arg); + int n = 0; + grib_accessor_bufr_extract_datetime_subsets_t* self = (grib_accessor_bufr_extract_datetime_subsets_t*)a; a->length = 0; self->doExtractSubsets = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); @@ -116,13 +29,13 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_bufr_extract_datetime_subsets_t::get_native_type(grib_accessor* a) { return GRIB_TYPE_LONG; } /* Convert input date to Julian number. If date is invalid, return -1 */ -static double date_to_julian(long year, long month, long day, long hour, long minute, double second) +double date_to_julian(long year, long month, long day, long hour, long minute, double second) { double result = 0; /* Julian number in units of days */ @@ -175,7 +88,9 @@ static int build_long_array(grib_context* c, grib_handle* h, int compressed, } else { /* uncompressed */ - char keystr[32] = {0,}; + char keystr[32] = { + 0, + }; size_t values_len = 0; for (i = 0; i < numberOfSubsets; ++i) { long lVal = 0; @@ -196,14 +111,22 @@ static int build_long_array(grib_context* c, grib_handle* h, int compressed, static int select_datetime(grib_accessor* a) { - int ret = 0; - long compressed = 0; - grib_accessor_bufr_extract_datetime_subsets* self = (grib_accessor_bufr_extract_datetime_subsets*)a; - grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = h->context; + int ret = 0; + long compressed = 0; + grib_accessor_bufr_extract_datetime_subsets_t* self = (grib_accessor_bufr_extract_datetime_subsets_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = h->context; size_t n; double julianStart = 0, julianEnd = 0, julianDT = 0; - char start_str[80] = {0,}, end_str[80] = {0,}, datetime_str[80] = {0,}; + char start_str[80] = { + 0, + }, + end_str[80] = { + 0, + }, + datetime_str[80] = { + 0, + }; long yearRank, monthRank, dayRank, hourRank, minuteRank, secondRank; long yearStart, monthStart, dayStart, hourStart, minuteStart, secondStart; long yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd; @@ -211,13 +134,13 @@ static int select_datetime(grib_accessor* a) double* second = NULL; long numberOfSubsets, i; grib_iarray* subsets = NULL; - size_t nsubsets = 0; - char yearstr[32] = "year"; - char monthstr[32] = "month"; - char daystr[32] = "day"; - char hourstr[32] = "hour"; - char minutestr[32] = "minute"; - char secondstr[32] = "second"; + size_t nsubsets = 0; + char yearstr[32] = "year"; + char monthstr[32] = "month"; + char daystr[32] = "day"; + char hourstr[32] = "hour"; + char minutestr[32] = "minute"; + char secondstr[32] = "second"; ret = grib_get_long(h, "compressedData", &compressed); if (ret) return ret; @@ -356,7 +279,7 @@ static int select_datetime(grib_accessor* a) if (ret) secondEnd = 0; snprintf(end_str, sizeof(end_str), "%04ld/%02ld/%02ld %02ld:%02ld:%02ld", - yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd); + yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd); if (c->debug) fprintf(stderr, "ECCODES DEBUG bufr_extract_datetime_subsets: end =%s\n", end_str); julianEnd = date_to_julian(yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd); if (julianEnd == -1) { @@ -402,7 +325,7 @@ static int select_datetime(grib_accessor* a) if (nsubsets != 0) { long* subsets_ar = grib_iarray_get_array(subsets); - ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); grib_context_free(c, subsets_ar); if (ret) return ret; @@ -423,9 +346,9 @@ cleanup: return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_bufr_extract_datetime_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len) { - /*grib_accessor_bufr_extract_datetime_subsets *self =(grib_accessor_bufr_extract_datetime_subsets*)a;*/ + /*grib_accessor_bufr_extract_datetime_subsets_t *self =(grib_accessor_bufr_extract_datetime_subsets_t*)a;*/ if (*len == 0) return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h new file mode 100644 index 000000000..765786cd2 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_datetime_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_datetime_subsets */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; +}; + +class grib_accessor_class_bufr_extract_datetime_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_datetime_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_datetime_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc new file mode 100644 index 000000000..7d5a23652 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc @@ -0,0 +1,58 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bufr_extract_subsets.h" + +grib_accessor_class_bufr_extract_subsets_t _grib_accessor_class_bufr_extract_subsets{"bufr_extract_subsets"}; +grib_accessor_class* grib_accessor_class_bufr_extract_subsets = &_grib_accessor_class_bufr_extract_subsets; + + +void get_accessors(grib_accessor* a){ + grib_accessor_bufr_extract_subsets_t* self = (grib_accessor_bufr_extract_subsets_t*)a; + const grib_handle* h = grib_handle_of_accessor(a); + + if (self->packAccessor) + return; + self->numericValuesAccessor = grib_find_accessor(h, self->numericValues); + self->packAccessor = grib_find_accessor(h, self->pack); +} + +void grib_accessor_class_bufr_extract_subsets_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + int n = 0; + grib_accessor_bufr_extract_subsets_t* self = (grib_accessor_bufr_extract_subsets_t*)a; + + a->length = 0; + self->numericValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->pack = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; +} + +int grib_accessor_class_bufr_extract_subsets_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_bufr_extract_subsets_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_bufr_extract_subsets_t* self = (grib_accessor_bufr_extract_subsets_t*)a; + size_t l = 1; + long v[1]; + + get_accessors(a); + + v[0] = 1; + int err = self->packAccessor->pack_long(v, &l); if (err) { + if (err == GRIB_ENCODING_ERROR) + grib_context_log(a->context, GRIB_LOG_ERROR, "Could not extract subset(s).\n\tHint: Did you forget to set unpack=1?"); + return err; + } + + return err; +} diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.h b/src/accessor/grib_accessor_class_bufr_extract_subsets.h new file mode 100644 index 000000000..3015d87ae --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_extract_subsets_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_extract_subsets */ + const char* numericValues; + const char* pack; + grib_accessor* numericValuesAccessor; + grib_accessor* packAccessor; +}; + +class grib_accessor_class_bufr_extract_subsets_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_extract_subsets_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_extract_subsets_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_bufr_group.cc b/src/accessor/grib_accessor_class_bufr_group.cc new file mode 100644 index 000000000..71249f70d --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_group.cc @@ -0,0 +1,38 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bufr_group.h" + +grib_accessor_class_bufr_group_t _grib_accessor_class_bufr_group{"bufr_group"}; +grib_accessor_class* grib_accessor_class_bufr_group = &_grib_accessor_class_bufr_group; + + +void grib_accessor_class_bufr_group_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_section(dumper, a, a->sub_section->block); +} + +grib_accessor* grib_accessor_class_bufr_group_t::next(grib_accessor* a, int explore) +{ + grib_accessor* next = NULL; + if (explore) { + next = a->sub_section->block->first; + if (!next) + next = a->next_; + } + else { + next = a->next_; + } + if (!next) { + if (a->parent->owner) + next = a->parent->owner->cclass->next(a->parent->owner, 0); + } + return next; +} diff --git a/src/accessor/grib_accessor_class_bufr_group.h b/src/accessor/grib_accessor_class_bufr_group.h new file mode 100644 index 000000000..758c5c772 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_group.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_variable.h" + +class grib_accessor_bufr_group_t : public grib_accessor_variable_t +{ +public: + /* Members defined in bufr_group */ +}; + +class grib_accessor_class_bufr_group_t : public grib_accessor_class_variable_t +{ +public: + grib_accessor_class_bufr_group_t(const char* name) : grib_accessor_class_variable_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_group_t{}; } + void dump(grib_accessor*, grib_dumper*) override; + grib_accessor* next(grib_accessor* a, int explore) override; +}; diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc new file mode 100644 index 000000000..a74d7a74c --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc @@ -0,0 +1,118 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bufr_simple_thinning.h" + +grib_accessor_class_bufr_simple_thinning_t _grib_accessor_class_bufr_simple_thinning{ "bufr_simple_thinning" }; +grib_accessor_class* grib_accessor_class_bufr_simple_thinning = &_grib_accessor_class_bufr_simple_thinning; + + +void grib_accessor_class_bufr_simple_thinning_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_gen_t::init(a, len, arg); + grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int n = 0; + + a->length = 0; + self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); + self->numberOfSubsets = grib_arguments_get_name(h, arg, n++); + self->extractSubsetList = grib_arguments_get_name(h, arg, n++); + self->simpleThinningStart = grib_arguments_get_name(h, arg, n++); + self->simpleThinningMissingRadius = grib_arguments_get_name(h, arg, n++); + self->simpleThinningSkip = grib_arguments_get_name(h, arg, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; +} + +int grib_accessor_class_bufr_simple_thinning_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_LONG; +} + +static int apply_thinning(grib_accessor* a) +{ + const grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; + + long skip; + grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = h->context; + long compressed = 0, nsubsets; + grib_iarray* subsets; + long* subsets_ar = 0; + long start = 0, radius = 0; + + int ret = grib_get_long(h, "compressedData", &compressed); + if (ret) + return ret; + if (compressed) { + long numberOfSubsets = 0; + ret = grib_get_long(h, self->numberOfSubsets, &numberOfSubsets); + if (ret) + return ret; + + ret = grib_get_long(h, self->simpleThinningStart, &start); + if (ret) + return ret; + + ret = grib_get_long(h, self->simpleThinningSkip, &skip); + if (ret) + return ret; + if (skip <= 0) + return GRIB_INVALID_KEY_VALUE; + + ret = grib_get_long(h, self->simpleThinningMissingRadius, &radius); + if (ret) + return ret; + + subsets = grib_iarray_new(c, numberOfSubsets / skip + 1, 10); + for (long i = 0; i < numberOfSubsets; i += skip + 1) { + grib_iarray_push(subsets, i + 1); + } + + nsubsets = grib_iarray_used_size(subsets); + + if (nsubsets != 0) { + subsets_ar = grib_iarray_get_array(subsets); + ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); + grib_context_free(c, subsets_ar); + if (ret) + return ret; + + ret = grib_set_long(h, "unpack", 1); + if (ret) + return ret; + + ret = grib_set_long(h, self->doExtractSubsets, 1); + if (ret) + return ret; + } + grib_iarray_delete(subsets); + } + else { + return GRIB_NOT_IMPLEMENTED; + } + + return ret; +} + +int grib_accessor_class_bufr_simple_thinning_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + const grib_accessor_bufr_simple_thinning_t* self = (grib_accessor_bufr_simple_thinning_t*)a; + + if (*len == 0) + return GRIB_SUCCESS; + int err = apply_thinning(a); + if (err) + return err; + + return grib_set_long(a->parent->h, self->doExtractSubsets, 1); +} diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.h b/src/accessor/grib_accessor_class_bufr_simple_thinning.h new file mode 100644 index 000000000..9b7467914 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bufr_simple_thinning_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bufr_simple_thinning */ + const char* doExtractSubsets; + const char* numberOfSubsets; + const char* extractSubsetList; + const char* simpleThinningStart; + const char* simpleThinningMissingRadius; + const char* simpleThinningSkip; +}; + +class grib_accessor_class_bufr_simple_thinning_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bufr_simple_thinning_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_simple_thinning_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_bufr_string_values.cc b/src/accessor/grib_accessor_class_bufr_string_values.cc new file mode 100644 index 000000000..31e616b6f --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_string_values.cc @@ -0,0 +1,92 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bufr_string_values.h" +#include "grib_accessor_class_bufr_data_array.h" + +grib_accessor_class_bufr_string_values_t _grib_accessor_class_bufr_string_values{ "bufr_string_values" }; +grib_accessor_class* grib_accessor_class_bufr_string_values = &_grib_accessor_class_bufr_string_values; + + +void grib_accessor_class_bufr_string_values_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ + grib_accessor_class_ascii_t::init(a, len, args); + grib_accessor_bufr_string_values_t* self = (grib_accessor_bufr_string_values_t*)a; + int n = 0; + self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->dataAccessor = NULL; + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_bufr_string_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + grib_dump_string_array(dumper, a, NULL); +} + +static grib_accessor* get_accessor(grib_accessor* a) +{ + grib_accessor_bufr_string_values_t* self = (grib_accessor_bufr_string_values_t*)a; + if (!self->dataAccessor) { + self->dataAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->dataAccessorName); + } + return self->dataAccessor; +} + +int grib_accessor_class_bufr_string_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +{ + grib_accessor* data = 0; + grib_context* c = a->context; + grib_vsarray* stringValues = NULL; + size_t l = 0, tl; + size_t i, j, n = 0; + char** b = buffer; + + data = get_accessor(a); + if (!data) + return GRIB_NOT_FOUND; + + stringValues = accessor_bufr_data_array_get_stringValues(data); + + n = grib_vsarray_used_size(stringValues); + + tl = 0; + for (j = 0; j < n; j++) { + l = grib_sarray_used_size(stringValues->v[j]); + tl += l; + + if (tl > *len) + return GRIB_ARRAY_TOO_SMALL; + + for (i = 0; i < l; i++) { + *(b++) = grib_context_strdup(c, stringValues->v[j]->v[i]); + } + } + *len = tl; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_bufr_string_values_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_bufr_string_values_t::value_count(grib_accessor* a, long* rlen) +{ + grib_accessor* descriptors = get_accessor(a); + return descriptors->value_count(rlen); +} + +void grib_accessor_class_bufr_string_values_t::destroy(grib_context* c, grib_accessor* a) +{ + grib_accessor_class_ascii_t::destroy(c, a); +} diff --git a/src/accessor/grib_accessor_class_bufr_string_values.h b/src/accessor/grib_accessor_class_bufr_string_values.h new file mode 100644 index 000000000..fe6c2acb7 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufr_string_values.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_bufr_string_values_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in bufr_string_values */ + const char* dataAccessorName; + grib_accessor* dataAccessor; +}; + +class grib_accessor_class_bufr_string_values_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_bufr_string_values_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_string_values_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc new file mode 100644 index 000000000..bd411d510 --- /dev/null +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc @@ -0,0 +1,99 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bufrdc_expanded_descriptors.h" + +grib_accessor_class_bufrdc_expanded_descriptors_t _grib_accessor_class_bufrdc_expanded_descriptors{"bufrdc_expanded_descriptors"}; +grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors = &_grib_accessor_class_bufrdc_expanded_descriptors; + + +void grib_accessor_class_bufrdc_expanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); + grib_accessor_bufrdc_expanded_descriptors_t* self = (grib_accessor_bufrdc_expanded_descriptors_t*)a; + int n = 0; + self->expandedDescriptors = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->expandedDescriptorsAccessor = 0; + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +static grib_accessor* get_accessor(grib_accessor* a) +{ + grib_accessor_bufrdc_expanded_descriptors_t* self = (grib_accessor_bufrdc_expanded_descriptors_t*)a; + if (!self->expandedDescriptorsAccessor) { + self->expandedDescriptorsAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->expandedDescriptors); + } + return self->expandedDescriptorsAccessor; +} + +int grib_accessor_class_bufrdc_expanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor* descriptors = 0; + size_t rlen = 0, l; + long lenall = 0; + size_t i = 0; + long* v = 0; + grib_context* c = a->context; + + descriptors = get_accessor(a); + if (!descriptors) return GRIB_NOT_FOUND; + + a->value_count(&lenall); v = (long*)grib_context_malloc_clear(c, sizeof(long) * lenall); + l = lenall; + descriptors->unpack_long(v, &l); + rlen = 0; + for (i = 0; i < l; i++) { + if ((v[i] < 100000 || v[i] > 221999)) + val[rlen++] = v[i]; + } + *len = rlen; + grib_context_free(c,v); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_bufrdc_expanded_descriptors_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ + int err = 0; + grib_accessor* descriptors = 0; + size_t l = 0; + long lenall = 0; + size_t i = 0; + long* v = 0; + char buf[25] = {0,}; + grib_context* c = a->context; + + descriptors = get_accessor(a); + if (!descriptors) return GRIB_NOT_FOUND; + + err = a->value_count(&lenall); if (err) return err; + l = lenall; + if (l > *len) return GRIB_ARRAY_TOO_SMALL; + + v = (long*)grib_context_malloc_clear(c, sizeof(long) * l); + err = descriptors->unpack_long(v, &l); if (err) return err; + + for (i = 0; i < l; i++) { + snprintf(buf, sizeof(buf), "%06ld", v[i]); + buffer[i] = grib_context_strdup(c, buf); + } + *len = l; + grib_context_free(c,v); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_bufrdc_expanded_descriptors_t::value_count(grib_accessor* a, long* rlen){ + grib_accessor* descriptors = get_accessor(a); + + return descriptors->value_count(rlen);} + +void grib_accessor_class_bufrdc_expanded_descriptors_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_class_long_t::destroy(c, a); +} diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h new file mode 100644 index 000000000..92cf595ad --- /dev/null +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_bufrdc_expanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in bufrdc_expanded_descriptors */ + const char* expandedDescriptors; + grib_accessor* expandedDescriptorsAccessor; +}; + +class grib_accessor_class_bufrdc_expanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_bufrdc_expanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bufrdc_expanded_descriptors_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_bytes.cc b/src/accessor/grib_accessor_class_bytes.cc new file mode 100644 index 000000000..47c8713ae --- /dev/null +++ b/src/accessor/grib_accessor_class_bytes.cc @@ -0,0 +1,99 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_bytes.h" + +grib_accessor_class_bytes_t _grib_accessor_class_bytes{"bytes"}; +grib_accessor_class* grib_accessor_class_bytes = &_grib_accessor_class_bytes; + + +void grib_accessor_class_bytes_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + /*grib_accessor_signed* self = (grib_accessor_signed*)a; */ + a->length = len; + Assert(a->length >= 0); +} + +int grib_accessor_class_bytes_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_BYTES; +} + +int grib_accessor_class_bytes_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = GRIB_SUCCESS; + + size_t alen = (size_t)a->byte_count(); size_t blen = (size_t)b->byte_count(); + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + return retval; +} + +int grib_accessor_class_bytes_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + unsigned char* p = NULL; + char* s = v; + long i = 0; + const long length = a->byte_count(); const long slength = 2 * length; + + if (*len < (size_t)slength) { + *len = slength; + return GRIB_BUFFER_TOO_SMALL; + } + + p = grib_handle_of_accessor(a)->buffer->data + a->byte_offset(); + for (i = 0; i < length; i++) { + snprintf(s, INT_MAX, "%02x", *(p++)); + s += 2; + } + + *len = slength; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_bytes_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + /* The string representation (val) of the byte array will have two chars + * per byte e.g. 4C5B means the 2 bytes 0114 and 0133 in octal + * so has to be twice the length of the byte array + */ + int err = 0; + grib_context* c = a->context; + size_t nbytes = a->length; + const size_t expected_blen = nbytes; + const size_t expected_slen = 2 * expected_blen; + unsigned char* bytearray = NULL; + size_t i = 0, slen = strlen(val); + + if (slen != expected_slen || *len != expected_slen) { + grib_context_log(c, GRIB_LOG_ERROR, + "%s: Key %s is %lu bytes. Expected a string with %lu characters (actual length=%zu)", + __func__, a->name, expected_blen, expected_slen, *len); + return GRIB_WRONG_ARRAY_SIZE; + } + + bytearray = (unsigned char*)grib_context_malloc(c, nbytes * (sizeof(unsigned char))); + if (!bytearray) return GRIB_OUT_OF_MEMORY; + + for (i = 0; i < (slen/2); i++) { + unsigned int byteVal = 0; + if (sscanf(val + 2*i, "%02x", &byteVal) != 1) { + grib_context_log(c, GRIB_LOG_ERROR,"%s: Invalid hex byte specfication '%.2s'", __func__, val + 2*i); + grib_context_free(c, bytearray); + return GRIB_INVALID_KEY_VALUE; + } + Assert(byteVal < 256); + bytearray[i] = (int)byteVal; + } + + /* Forward to base class to pack the byte array */ + err = grib_accessor_class_gen_t::pack_bytes(a, bytearray, &nbytes); + grib_context_free(c, bytearray); + return err; +} diff --git a/src/accessor/grib_accessor_class_bytes.h b/src/accessor/grib_accessor_class_bytes.h new file mode 100644 index 000000000..676cf55c4 --- /dev/null +++ b/src/accessor/grib_accessor_class_bytes.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_bytes_t : public grib_accessor_gen_t +{ +public: + /* Members defined in bytes */ +}; + +class grib_accessor_class_bytes_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_bytes_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_bytes_t{}; } + int get_native_type(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc new file mode 100644 index 000000000..50475b6a6 --- /dev/null +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc @@ -0,0 +1,117 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_change_alternative_row_scanning.h" + +grib_accessor_class_change_alternative_row_scanning_t _grib_accessor_class_change_alternative_row_scanning{"change_alternative_row_scanning"}; +grib_accessor_class* grib_accessor_class_change_alternative_row_scanning = &_grib_accessor_class_change_alternative_row_scanning; + + +void grib_accessor_class_change_alternative_row_scanning_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, len, args); + int n = 0; + grib_accessor_change_alternative_row_scanning_t* self = (grib_accessor_change_alternative_row_scanning_t*)a; + + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->Ni = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->Nj = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->alternativeRowScanning = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_change_alternative_row_scanning_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int err = 0; + grib_accessor_change_alternative_row_scanning_t* self = (grib_accessor_change_alternative_row_scanning_t*)a; + const grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + long i, j, jr, theEnd, Ni, Nj, k, kp, alternativeRowScanning; + size_t size = 0; + double* values = NULL; + double tmp = 0.0; + + if (*val == 0) + return 0; + + /* Make sure Ni / Nj are not missing */ + if (grib_is_missing(h, self->Ni, &err) && !err) { + grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: Key %s cannot be 'missing'!", self->Ni); + return GRIB_WRONG_GRID; + } + if (grib_is_missing(h, self->Nj, &err) && !err) { + grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: Key %s cannot be 'missing'!", self->Nj); + return GRIB_WRONG_GRID; + } + + if ((err = grib_get_long_internal(h, self->Ni, &Ni)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(h, self->Nj, &Nj)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(h, self->alternativeRowScanning, &alternativeRowScanning)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return err; + + if ( size > (size_t)(Ni * Nj) ) { + grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: wrong values size!=Ni*Nj (%zu!=%ld*%ld)", size, Ni, Nj); + return GRIB_WRONG_ARRAY_SIZE; + } + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((err = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + theEnd = Ni / 2; + for (j = 0; j < Nj; j++) { + jr = Ni * j; + for (i = 0; i < theEnd; i++) { + if (j % 2 == 1) { + /* Swap first and last value on every odd row */ + k = jr + i; + kp = jr + Ni - i - 1; + tmp = values[k]; + values[k] = values[kp]; + values[kp] = tmp; + } + } + } + alternativeRowScanning = !alternativeRowScanning; + if ((err = grib_set_long_internal(h, self->alternativeRowScanning, alternativeRowScanning)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + if ((err = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_change_alternative_row_scanning_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_change_alternative_row_scanning_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + /* Decoding this accessor doesn't make sense so we return a dummy value */ + *v = -1; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.h b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h new file mode 100644 index 000000000..f889931a0 --- /dev/null +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_change_alternative_row_scanning_t : public grib_accessor_gen_t +{ +public: + /* Members defined in change_alternative_row_scanning */ + const char* values; + const char* Ni; + const char* Nj; + const char* alternativeRowScanning; +}; + +class grib_accessor_class_change_alternative_row_scanning_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_change_alternative_row_scanning_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_change_alternative_row_scanning_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_change_scanning_direction.cc b/src/accessor/grib_accessor_class_change_scanning_direction.cc similarity index 56% rename from src/grib_accessor_class_change_scanning_direction.cc rename to src/accessor/grib_accessor_class_change_scanning_direction.cc index 88fbc35fb..e3b6144c9 100644 --- a/src/grib_accessor_class_change_scanning_direction.cc +++ b/src/accessor/grib_accessor_class_change_scanning_direction.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,116 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_long; - IMPLEMENTS = unpack_long - IMPLEMENTS = init;get_native_type - MEMBERS = const char* values - MEMBERS = const char* Ni - MEMBERS = const char* Nj - MEMBERS = const char* i_scans_negatively - MEMBERS = const char* j_scans_positively - MEMBERS = const char* first - MEMBERS = const char* last - MEMBERS = const char* axis - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_change_scanning_direction -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in change_scanning_direction */ - const char* values; - const char* Ni; - const char* Nj; - const char* i_scans_negatively; - const char* j_scans_positively; - const char* first; - const char* last; - const char* axis; -} grib_accessor_change_scanning_direction; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_change_scanning_direction = { - &grib_accessor_class_gen, /* super */ - "change_scanning_direction", /* name */ - sizeof(grib_accessor_change_scanning_direction), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_change_scanning_direction.h" +grib_accessor_class_change_scanning_direction_t _grib_accessor_class_change_scanning_direction{"change_scanning_direction"}; grib_accessor_class* grib_accessor_class_change_scanning_direction = &_grib_accessor_class_change_scanning_direction; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_change_scanning_direction* self = (grib_accessor_change_scanning_direction*)a; +void grib_accessor_class_change_scanning_direction_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, len, args); + grib_accessor_change_scanning_direction_t* self = (grib_accessor_change_scanning_direction_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; @@ -134,8 +34,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* args) a->length = 0; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_change_scanning_direction_t::pack_long(grib_accessor* a, const long* val, size_t* len){ int err = 0; long i, j, jr, theEnd, Ni, Nj, k, kp; double tmp; @@ -145,8 +44,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) double last = 0; size_t size = 0; double* values = NULL; - grib_accessor_change_scanning_direction* self = (grib_accessor_change_scanning_direction*)a; - grib_context* c = a->context; + grib_accessor_change_scanning_direction_t* self = (grib_accessor_change_scanning_direction_t*)a; + const grib_context* c = a->context; grib_handle* h = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -248,13 +147,11 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_change_scanning_direction_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_LONG; } -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ +int grib_accessor_class_change_scanning_direction_t::unpack_long(grib_accessor* a, long* v, size_t* len){ /* ECC-976: decoding this accessor doesn't make sense so we return a dummy value */ *v = -1; return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.h b/src/accessor/grib_accessor_class_change_scanning_direction.h new file mode 100644 index 000000000..ead274485 --- /dev/null +++ b/src/accessor/grib_accessor_class_change_scanning_direction.h @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_change_scanning_direction_t : public grib_accessor_gen_t +{ +public: + /* Members defined in change_scanning_direction */ + const char* values; + const char* Ni; + const char* Nj; + const char* i_scans_negatively; + const char* j_scans_positively; + const char* first; + const char* last; + const char* axis; +}; + +class grib_accessor_class_change_scanning_direction_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_change_scanning_direction_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_change_scanning_direction_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_check_internal_version.cc b/src/accessor/grib_accessor_class_check_internal_version.cc new file mode 100644 index 000000000..f8ceb1896 --- /dev/null +++ b/src/accessor/grib_accessor_class_check_internal_version.cc @@ -0,0 +1,51 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_check_internal_version.h" + +grib_accessor_class_check_internal_version_t _grib_accessor_class_check_internal_version{"check_internal_version"}; +grib_accessor_class* grib_accessor_class_check_internal_version = &_grib_accessor_class_check_internal_version; + + +/* This is the internal engine version number */ +/* We check this against the version number found in the definitions boot.def file */ +/* See the key "internalVersion" */ +#define LATEST_ENGINE_VERSION 30 + +void grib_accessor_class_check_internal_version_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_ascii_t::init(a, l, args); + /* Check version of definition files is compatible with the engine */ + int err = 0; + long defs_file_version = 0; + grib_handle* h = grib_handle_of_accessor(a); + const char* s_defn_version = grib_arguments_get_name(h, args, 0); + Assert(s_defn_version); + + err = grib_get_long_internal(h, s_defn_version, &defs_file_version); + if (!err) { + if (defs_file_version > LATEST_ENGINE_VERSION) { + grib_context_log(h->context, GRIB_LOG_FATAL, + "Definition files version (%d) is greater than engine version (%d)!\n" + " " /* indent for 2nd line */ + "These definition files are for a later version of the ecCodes engine.", + defs_file_version, LATEST_ENGINE_VERSION); + } + } +} + +int grib_accessor_class_check_internal_version_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_check_internal_version_t::string_length(grib_accessor* a){ + return 255; +} diff --git a/src/accessor/grib_accessor_class_check_internal_version.h b/src/accessor/grib_accessor_class_check_internal_version.h new file mode 100644 index 000000000..d37b57282 --- /dev/null +++ b/src/accessor/grib_accessor_class_check_internal_version.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_check_internal_version_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in check_internal_version */ +}; + +class grib_accessor_class_check_internal_version_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_check_internal_version_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_check_internal_version_t{}; } + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_closest_date.cc b/src/accessor/grib_accessor_class_closest_date.cc similarity index 56% rename from src/grib_accessor_class_closest_date.cc rename to src/accessor/grib_accessor_class_closest_date.cc index b4729822f..b0b3bb512 100644 --- a/src/grib_accessor_class_closest_date.cc +++ b/src/accessor/grib_accessor_class_closest_date.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,122 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" +#include "grib_accessor_class_closest_date.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = dump - IMPLEMENTS = init - MEMBERS = const char *dateLocal - MEMBERS = const char *timeLocal - MEMBERS = const char *numForecasts - MEMBERS = const char *year - MEMBERS = const char *month - MEMBERS = const char *day - MEMBERS = const char *hour - MEMBERS = const char *minute - MEMBERS = const char *second - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_closest_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in closest_date */ - const char *dateLocal; - const char *timeLocal; - const char *numForecasts; - const char *year; - const char *month; - const char *day; - const char *hour; - const char *minute; - const char *second; -} grib_accessor_closest_date; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_closest_date = { - &grib_accessor_class_double, /* super */ - "closest_date", /* name */ - sizeof(grib_accessor_closest_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_closest_date_t _grib_accessor_class_closest_date{"closest_date"}; grib_accessor_class* grib_accessor_class_closest_date = &_grib_accessor_class_closest_date; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_closest_date* self = (grib_accessor_closest_date*)a; +void grib_accessor_class_closest_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_closest_date_t* self = (grib_accessor_closest_date_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; @@ -140,13 +35,11 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_closest_date_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_string(dumper, a, NULL); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_closest_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ int ret = 0; double v = 0; @@ -157,8 +50,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } /* Sets val to the 'index' of the closes date */ -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_closest_date_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + const grib_accessor_closest_date_t* self = (grib_accessor_closest_date_t*)a; + int err = 0; long num_forecasts = 0; /* numberOfForecastsUsedInLocalTime */ /* These relate to the date and time in Section 1 */ @@ -171,9 +65,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) /* These relate to the forecast dates and times in Section 4 */ long *yearArray, *monthArray, *dayArray, *hourArray, *minuteArray, *secondArray; - grib_accessor_closest_date* self = (grib_accessor_closest_date*)a; grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = a->context; + const grib_context* c = a->context; *val = -1; /* initialise to an invalid index */ if ((err = grib_get_long_internal(h, self->numForecasts, &num_forecasts)) != GRIB_SUCCESS) return err; diff --git a/src/accessor/grib_accessor_class_closest_date.h b/src/accessor/grib_accessor_class_closest_date.h new file mode 100644 index 000000000..ebd3cb6d4 --- /dev/null +++ b/src/accessor/grib_accessor_class_closest_date.h @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_closest_date_t : public grib_accessor_double_t +{ +public: + /* Members defined in closest_date */ + const char *dateLocal; + const char *timeLocal; + const char *numForecasts; + const char *year; + const char *month; + const char *day; + const char *hour; + const char *minute; + const char *second; +}; + +class grib_accessor_class_closest_date_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_closest_date_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_closest_date_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc new file mode 100644 index 000000000..6cfda6942 --- /dev/null +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -0,0 +1,124 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_codeflag.h" + +grib_accessor_class_codeflag_t _grib_accessor_class_codeflag{ "codeflag" }; +grib_accessor_class* grib_accessor_class_codeflag = &_grib_accessor_class_codeflag; + + +void grib_accessor_class_codeflag_t::init(grib_accessor* a, const long len, grib_arguments* param) +{ + grib_accessor_class_unsigned_t::init(a, len, param); + grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; + a->length = len; + self->tablename = grib_arguments_get_string(grib_handle_of_accessor(a), param, 0); + Assert(a->length >= 0); +} + +static int test_bit(long a, long b) +{ + DEBUG_ASSERT(b >= 0); + return a & (1 << b); +} + +static int grib_get_codeflag(grib_accessor* a, long code, char* codename) +{ + const grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; + FILE* f = NULL; + char fname[1024]; + char bval[50]; + char num[50]; + char* filename = 0; + char line[1024]; + size_t i = 0; + int j = 0; + int err = 0; + + err = grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); + if (err) { + strncpy(fname, self->tablename, sizeof(fname) - 1); + fname[sizeof(fname) - 1] = '\0'; + } + + if ((filename = grib_context_full_defs_path(a->context, fname)) == NULL) { + grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot open flag table %s", filename); + strcpy(codename, "Cannot open flag table"); + return GRIB_FILE_NOT_FOUND; + } + + f = codes_fopen(filename, "r"); + if (!f) { + grib_context_log(a->context, (GRIB_LOG_WARNING) | (GRIB_LOG_PERROR), "Cannot open flag table %s", filename); + strcpy(codename, "Cannot open flag table"); + return GRIB_FILE_NOT_FOUND; + } + + // strcpy(codename, self->tablename); + // strcat(codename,": "); + // j = strlen(codename); + + while (fgets(line, sizeof(line) - 1, f)) { + sscanf(line, "%49s %49s", num, bval); + + if (num[0] != '#') { + if ((test_bit(code, a->length * 8 - atol(num)) > 0) == atol(bval)) { + size_t linelen = strlen(line); + codename[j++] = '('; + codename[j++] = num[0]; + codename[j++] = '='; + codename[j++] = bval[0]; + codename[j++] = ')'; + codename[j++] = ' '; + if (j) + codename[j++] = ' '; + + for (i = (strlen(num) + strlen(bval) + 2); i < linelen - 1; i++) + codename[j++] = line[i]; + if (line[i] != '\n') + codename[j++] = line[i]; + codename[j++] = ';'; + } + } + } + + if (j > 1 && codename[j - 1] == ';') + j--; + codename[j] = 0; + + strcat(codename, ":"); + strcat(codename, fname); + + fclose(f); + return GRIB_SUCCESS; +} + +int grib_accessor_class_codeflag_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +void grib_accessor_class_codeflag_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + const grib_accessor_codeflag_t* self = (grib_accessor_codeflag_t*)a; + long v = 0; + char flagname[1024] = {0,}; + char fname[1024] = {0,}; + + size_t llen = 1; + + grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); + a->unpack_long(&v, &llen); + grib_get_codeflag(a, v, flagname); + + grib_dump_bits(dumper, a, flagname); +} diff --git a/src/accessor/grib_accessor_class_codeflag.h b/src/accessor/grib_accessor_class_codeflag.h new file mode 100644 index 000000000..82c8cc77b --- /dev/null +++ b/src/accessor/grib_accessor_class_codeflag.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_codeflag_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in codeflag */ + const char* tablename; +}; + +class grib_accessor_class_codeflag_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_codeflag_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codeflag_t{}; } + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_codetable.cc b/src/accessor/grib_accessor_class_codetable.cc similarity index 80% rename from src/grib_accessor_class_codetable.cc rename to src/accessor/grib_accessor_class_codetable.cc index 0d97efdfb..f21ef0f86 100644 --- a/src/grib_accessor_class_codetable.cc +++ b/src/accessor/grib_accessor_class_codetable.cc @@ -8,18 +8,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - -#include "grib_api_internal.h" +#include "grib_accessor_class_codetable.h" #include + +grib_accessor_class_codetable_t _grib_accessor_class_codetable("codetable"); +grib_accessor_class* grib_accessor_class_codetable = &_grib_accessor_class_codetable; + + #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; -static void thread_init() +void thread_init() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); @@ -31,7 +32,7 @@ static void thread_init() static int once = 0; static omp_nest_lock_t mutex1; -static void thread_init() +void thread_init() { GRIB_OMP_CRITICAL(lock_grib_accessor_class_codetable_c) { @@ -43,123 +44,16 @@ static void thread_init() } #endif -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = init;dump;unpack_string;pack_expression;unpack_long - IMPLEMENTS = value_count;pack_string; destroy; get_native_type;pack_missing - MEMBERS = const char* tablename - MEMBERS = const char* masterDir - MEMBERS = const char* localDir - MEMBERS = grib_codetable* table - MEMBERS = int table_loaded - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_missing(grib_accessor*); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_expression(grib_accessor*, grib_expression*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_codetable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in codetable */ - const char* tablename; - const char* masterDir; - const char* localDir; - grib_codetable* table; - int table_loaded; -} grib_accessor_codetable; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_codetable = { - &grib_accessor_class_unsigned, /* super */ - "codetable", /* name */ - sizeof(grib_accessor_codetable), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - &pack_expression, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_codetable = &_grib_accessor_class_codetable; - -/* END_CLASS_IMP */ - static int grib_load_codetable(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_codetable* t); -static void init(grib_accessor* a, const long len, grib_arguments* params) +void grib_accessor_class_codetable_t::init(grib_accessor* a, const long len, grib_arguments* params) { + grib_accessor_class_unsigned_t::init(a, len, params); + int n = 0; long new_len = len; grib_handle* hand = grib_handle_of_accessor(a); - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; grib_action* act = (grib_action*)(a->creator); DEBUG_ASSERT(len == self->nbytes); @@ -195,7 +89,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) a->length = 0; if (!a->vvalue) a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->context, sizeof(grib_virtual_value)); - a->vvalue->type = grib_accessor_get_native_type(a); + a->vvalue->type = a->get_native_type(); a->vvalue->length = new_len; if (act->default_value != NULL) { const char* p = 0; @@ -209,12 +103,12 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) switch (type) { case GRIB_TYPE_DOUBLE: grib_expression_evaluate_double(hand, expression, &d); - grib_pack_double(a, &d, &s_len); + a->pack_double(&d, &s_len); break; case GRIB_TYPE_LONG: grib_expression_evaluate_long(grib_handle_of_accessor(a), expression, &l); - grib_pack_long(a, &l, &s_len); + a->pack_long(&l, &s_len); break; default: @@ -248,6 +142,7 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) return (*a == 0 && *b == 0) ? 0 : 1; } +// Cater for parameters being NULL static int str_eq(const char* a, const char* b) { if (a && b && (grib_inline_strcmp(a, b) == 0)) @@ -271,7 +166,7 @@ static void dump_codetable(grib_codetable* atable) #endif static grib_codetable* load_table(grib_accessor* a) { - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; size_t size = 0; grib_handle* h = ((grib_accessor*)self)->parent->h; grib_context* c = h->context; @@ -342,7 +237,7 @@ static grib_codetable* load_table(grib_accessor* a) size = a->vvalue->length * 8; } else { - size = grib_byte_count((grib_accessor*)self) * 8; + size = ((grib_accessor*)self)->byte_count() * 8; } size = (1ULL << size); /* 2^size - 64bits */ @@ -538,10 +433,10 @@ int codes_codetable_get_contents_malloc(const grib_handle* h, const char* key, c return GRIB_INVALID_ARGUMENT; // key is not a codetable } - const grib_accessor_codetable* ca = (const grib_accessor_codetable*)aa; // could be dynamic_cast + const grib_accessor_codetable_t* ca = (const grib_accessor_codetable_t*)aa; // could be dynamic_cast // Decode the key itself. This will either fetch it from the cache or place it there - if ((err = grib_unpack_long(aa, &lvalue, &size)) != GRIB_SUCCESS) { + if ((err = aa->unpack_long(&lvalue, &size)) != GRIB_SUCCESS) { return err; } @@ -612,9 +507,9 @@ int codes_codetable_check_abbreviation(const grib_handle* h, const char* key, co return err; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_codetable_t::dump(grib_accessor* a, grib_dumper* dumper) { - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; char comment[2048]; grib_codetable* table; @@ -627,7 +522,7 @@ static void dump(grib_accessor* a, grib_dumper* dumper) } table = self->table; - grib_unpack_long(a, &value, &llen); + a->unpack_long(&value, &llen); if (value == GRIB_MISSING_LONG) { if (a->length < 4) { @@ -670,9 +565,9 @@ static void dump(grib_accessor* a, grib_dumper* dumper) grib_dump_long(dumper, a, comment); } -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) +int grib_accessor_class_codetable_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) { - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; grib_codetable* table = NULL; size_t size = 1; @@ -681,7 +576,7 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) char tmp[1024]; size_t l = 0; - if ((err = grib_unpack_long(a, &value, &size)) != GRIB_SUCCESS) + if ((err = a->unpack_long(&value, &size)) != GRIB_SUCCESS) return err; if (!self->table_loaded) { @@ -714,14 +609,14 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_codetable_t::value_count(grib_accessor* a, long* count) { *count = 1; return 0; } // Return true if the input is an integer (non-negative) -static bool is_number(const char* s) +bool is_number(const char* s) { while (*s) { if (!isdigit(*s)) @@ -731,27 +626,27 @@ static bool is_number(const char* s) return true; } -static bool strings_equal(const char* s1, const char* s2, bool case_sensitive) +bool strings_equal(const char* s1, const char* s2, bool case_sensitive) { if (case_sensitive) return (strcmp(s1, s2) == 0); return (strcmp_nocase(s1, s2) == 0); } -static int pack_string(grib_accessor* a, const char* buffer, size_t* len) +int grib_accessor_class_codetable_t::pack_string(grib_accessor* a, const char* buffer, size_t* len) { long lValue = 0; Assert(buffer); if (is_number(buffer) && string_to_long(buffer, &lValue, 1) == GRIB_SUCCESS) { // ECC-1654: If value is a pure number, just pack as long size_t l = 1; - return grib_pack_long(a, &lValue, &l); + return a->pack_long(&lValue, &l); } if (STR_EQUAL_NOCASE(buffer, "missing")) { return pack_missing(a); } - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; grib_codetable* table = NULL; long i = 0; size_t size = 1; @@ -779,7 +674,7 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len) for (i = 0; i < table->size; i++) { if (table->entries[i].abbreviation) { if (strings_equal(table->entries[i].abbreviation, buffer, case_sensitive)) { - return grib_pack_long(a, &i, &size); + return a->pack_long(&i, &size); } } } @@ -798,12 +693,12 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len) switch (type) { case GRIB_TYPE_DOUBLE: grib_expression_evaluate_double(grib_handle_of_accessor(a), expression, &d); - grib_pack_double(a, &d, &s_len); + a->pack_double(&d, &s_len); break; case GRIB_TYPE_LONG: grib_expression_evaluate_long(grib_handle_of_accessor(a), expression, &l); - grib_pack_long(a, &l, &s_len); + a->pack_long(&l, &s_len); break; default: @@ -837,7 +732,7 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len) return GRIB_ENCODING_ERROR; } -static int pack_expression(grib_accessor* a, grib_expression* e) +int grib_accessor_class_codetable_t::pack_expression(grib_accessor* a, grib_expression* e) { const char* cval = NULL; int ret = 0; @@ -848,7 +743,7 @@ static int pack_expression(grib_accessor* a, grib_expression* e) if (strcmp(e->cclass->name, "long") == 0) { grib_expression_evaluate_long(hand, e, &lval); /* TODO: check return value */ //if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %ld\n", a->name,lval); - ret = grib_pack_long(a, &lval, &len); + ret = a->pack_long(&lval, &len); } else { char tmp[1024]; @@ -863,20 +758,21 @@ static int pack_expression(grib_accessor* a, grib_expression* e) len = strlen(cval) + 1; //if (hand->context->debug) // printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %s\n", a->name, cval); - ret = grib_pack_string(a, cval, &len); + ret = a->pack_string(cval, &len); } return ret; } -static void destroy(grib_context* context, grib_accessor* a) +void grib_accessor_class_codetable_t::destroy(grib_context* context, grib_accessor* a) { if (a->vvalue != NULL) { grib_context_free(context, a->vvalue); a->vvalue = NULL; } + grib_accessor_class_unsigned_t::destroy(context, a); } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_codetable_t::get_native_type(grib_accessor* a) { int type = GRIB_TYPE_LONG; /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", @@ -886,16 +782,16 @@ static int get_native_type(grib_accessor* a) return type; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_codetable_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; long rlen = 0, i = 0; long pos = a->offset * 8; grib_handle* hand = NULL; #ifdef DEBUG { - int err = grib_value_count(a, &rlen); + int err = a->value_count(&rlen); Assert(!err); Assert(rlen == 1); } @@ -934,12 +830,12 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_missing(grib_accessor* a) +int grib_accessor_class_codetable_t::pack_missing(grib_accessor* a) { // Many of the code tables do have a 'Missing' entry (all bits = 1) // So it is more user-friendly to allow setting codetable keys to // missing. For tables that do not have such an entry, an error is issued - grib_accessor_codetable* self = (grib_accessor_codetable*)a; + grib_accessor_codetable_t* self = (grib_accessor_codetable_t*)a; grib_handle* h = grib_handle_of_accessor(a); const long nbytes = a->length; @@ -949,7 +845,7 @@ static int pack_missing(grib_accessor* a) int err = codes_codetable_check_code_figure(h, a->name, maxVal); if (!err) { size_t l = 1; - return grib_pack_long(a, &maxVal, &l); + return a->pack_long(&maxVal, &l); } grib_context_log(a->context, GRIB_LOG_ERROR, "There is no 'missing' entry in Code Table %s (%s)", diff --git a/src/accessor/grib_accessor_class_codetable.h b/src/accessor/grib_accessor_class_codetable.h new file mode 100644 index 000000000..8a16d9113 --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable.h @@ -0,0 +1,41 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" +#include + +class grib_accessor_codetable_t : public grib_accessor_unsigned_t +{ +public: + const char* tablename; + const char* masterDir; + const char* localDir; + grib_codetable* table; + int table_loaded; +}; + +class grib_accessor_class_codetable_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_t{}; } + grib_accessor_class_codetable_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_codetable_title.cc b/src/accessor/grib_accessor_class_codetable_title.cc new file mode 100644 index 000000000..2bcdfd215 --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_title.cc @@ -0,0 +1,72 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_codetable_title.h" +#include "grib_accessor_class_codetable.h" + +grib_accessor_class_codetable_title_t _grib_accessor_class_codetable_title{ "codetable_title" }; +grib_accessor_class* grib_accessor_class_codetable_title = &_grib_accessor_class_codetable_title; + +void grib_accessor_class_codetable_title_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ + grib_accessor_class_gen_t::init(a, len, params); + grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; + int n = 0; + self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_codetable_title_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_codetable_title_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ + grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; + grib_codetable* table = NULL; + + size_t size = 1; + long value; + int err = GRIB_SUCCESS; + char tmp[1024]; + size_t l = 1024; + grib_accessor_codetable_t* ca = (grib_accessor_codetable_t*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); + + if ((err = ((grib_accessor*)ca)->unpack_long(&value, &size)) != GRIB_SUCCESS) + return err; + + table = ca->table; + + if (table && (value >= 0) && (value < table->size) && table->entries[value].title) { + strcpy(tmp, table->entries[value].title); + } + else { + snprintf(tmp, sizeof(tmp), "%d", (int)value); + } + + l = strlen(tmp) + 1; + + if (*len < l) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + strcpy(buffer, tmp); + *len = l; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_codetable_title.h b/src/accessor/grib_accessor_class_codetable_title.h new file mode 100644 index 000000000..f820c585c --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_title.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_codetable_title_t : public grib_accessor_gen_t +{ +public: + /* Members defined in codetable_title */ + const char* codetable; +}; + +class grib_accessor_class_codetable_title_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_codetable_title_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_title_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_codetable_units.cc b/src/accessor/grib_accessor_class_codetable_units.cc new file mode 100644 index 000000000..cc91ae2e2 --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_units.cc @@ -0,0 +1,73 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_codetable_units.h" +#include "grib_accessor_class_codetable.h" + +grib_accessor_class_codetable_units_t _grib_accessor_class_codetable_units{ "codetable_units" }; +grib_accessor_class* grib_accessor_class_codetable_units = &_grib_accessor_class_codetable_units; + +void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ + grib_accessor_class_gen_t::init(a, len, params); + grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; + + int n = 0; + self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_codetable_units_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_codetable_units_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ + grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; + grib_codetable* table = NULL; + + size_t size = 1; + long value; + int err = GRIB_SUCCESS; + char tmp[1024]; + size_t l = sizeof(tmp); + grib_accessor_codetable_t* ca = (grib_accessor_codetable_t*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); + + if ((err = ((grib_accessor*)ca)->unpack_long(&value, &size)) != GRIB_SUCCESS) + return err; + + table = ca->table; + + if (table && (value >= 0) && (value < table->size) && table->entries[value].units) { + strcpy(tmp, table->entries[value].units); + } + else { + snprintf(tmp, sizeof(tmp), "%d", (int)value); + } + + l = strlen(tmp) + 1; + + if (*len < l) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + strcpy(buffer, tmp); + *len = l; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_codetable_units.h b/src/accessor/grib_accessor_class_codetable_units.h new file mode 100644 index 000000000..0a8c9389d --- /dev/null +++ b/src/accessor/grib_accessor_class_codetable_units.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_codetable_units_t : public grib_accessor_gen_t +{ +public: + /* Members defined in codetable_units */ + const char* codetable; +}; + +class grib_accessor_class_codetable_units_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_codetable_units_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_codetable_units_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc similarity index 68% rename from src/grib_accessor_class_concept.cc rename to src/accessor/grib_accessor_class_concept.cc index c409a6f92..98f0fb35c 100644 --- a/src/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,113 +9,11 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_concept.h" -/******************************************************* - * Enrico Fucile - ******************************************************/ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_string;pack_string;string_length - IMPLEMENTS = unpack_long;pack_long;destroy - IMPLEMENTS = init;dump;value_count;get_native_type - IMPLEMENTS = compare - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_concept -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in concept */ -} grib_accessor_concept; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_concept = { - &grib_accessor_class_gen, /* super */ - "concept", /* name */ - sizeof(grib_accessor_concept), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_concept_t _grib_accessor_class_concept{ "concept" }; grib_accessor_class* grib_accessor_class_concept = &_grib_accessor_class_concept; -/* END_CLASS_IMP */ #define MAX_CONCEPT_STRING_LENGTH 255 @@ -134,12 +33,13 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) return (*a == 0 && *b == 0) ? 0 : 1; } -static void init(grib_accessor* a, const long len, grib_arguments* args) +void grib_accessor_class_concept_t::init(grib_accessor* a, const long len, grib_arguments* args) { + grib_accessor_class_gen_t::init(a, len, args); a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_concept_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_string(dumper, a, NULL); } @@ -192,7 +92,7 @@ static int concept_condition_expression_true(grib_handle* h, grib_concept_condit /* Return 1 (=True) or 0 (=False) */ static int concept_condition_iarray_true(grib_handle* h, grib_concept_condition* c) { - long* val = NULL; + long* val = NULL; size_t size = 0, i; int ret; /* Boolean */ int err = 0; @@ -237,6 +137,7 @@ static const char* concept_evaluate(grib_accessor* a) grib_concept_value* c = action_concept_get_concept(a); grib_handle* h = grib_handle_of_accessor(a); + // fprintf(stderr, "DEBUG: concept_evaluate: %s %s\n", a->name, c->name); while (c) { grib_concept_condition* e = c->conditions; int cnt = 0; @@ -262,7 +163,6 @@ static const char* concept_evaluate(grib_accessor* a) } #define MAX_NUM_CONCEPT_VALUES 40 - static int concept_conditions_expression_apply(grib_handle* h, grib_concept_condition* e, grib_values* values, grib_sarray* sa, int* n) { long lres = 0; @@ -290,7 +190,6 @@ static int concept_conditions_expression_apply(grib_handle* h, grib_concept_cond break; default: return GRIB_NOT_IMPLEMENTED; - break; } (*n)++; return err; @@ -318,9 +217,9 @@ static int cmpstringp(const void* p1, const void* p2) return strcmp(*(char* const*)p1, *(char* const*)p2); } -static bool blacklisted(grib_handle* h, long edition, const char* concept_name, const char* concept_value) +bool blacklisted(grib_handle* h, long edition, const char* concept_name, const char* concept_value) { - if ( strcmp(concept_name, "packingType")==0 ) { + if (strcmp(concept_name, "packingType") == 0) { char input_packing_type[100]; size_t len = sizeof(input_packing_type); if (strstr(concept_value, "SPD")) { @@ -336,10 +235,10 @@ static bool blacklisted(grib_handle* h, long edition, const char* concept_name, return true; } grib_get_string(h, "packingType", input_packing_type, &len); - if (strstr(input_packing_type,"grid_") && !strstr(concept_value,"grid_")) { + if (strstr(input_packing_type, "grid_") && !strstr(concept_value, "grid_")) { return true; } - if (strstr(input_packing_type,"spectral_") && !strstr(concept_value,"spectral_")) { + if (strstr(input_packing_type, "spectral_") && !strstr(concept_value, "spectral_")) { return true; } } @@ -372,8 +271,10 @@ static int grib_concept_apply(grib_accessor* a, const char* name) size_t i = 0, concept_count = 0; long dummy = 0, editionNumber = 0; char centre_s[32] = {0,}; - size_t centre_len = sizeof(centre_s); - char* all_concept_vals[MAX_NUM_CONCEPT_VALUES] = {NULL,}; /* sorted array containing concept values */ + size_t centre_len = sizeof(centre_s); + char* all_concept_vals[MAX_NUM_CONCEPT_VALUES] = { + NULL, + }; /* sorted array containing concept values */ grib_concept_value* pCon = concepts; grib_context_log(h->context, GRIB_LOG_ERROR, "concept: no match for %s=%s", act->name, name); @@ -381,15 +282,21 @@ static int grib_concept_apply(grib_accessor* a, const char* name) grib_get_string(h, "centre", centre_s, ¢re_len) == GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_ERROR, "concept: input handle edition=%ld, centre=%s", editionNumber, centre_s); } + char dataset_s[80]; + size_t dataset_len = sizeof(dataset_s); + if (grib_get_string(h, "datasetForLocal", dataset_s, &dataset_len) == GRIB_SUCCESS && !STR_EQUAL(dataset_s, "unknown")) { + grib_context_log(h->context, GRIB_LOG_ERROR, "concept: input handle dataset=%s", dataset_s); + } if (strcmp(act->name, "paramId") == 0) { if (string_to_long(name, &dummy, 1) == GRIB_SUCCESS) { // The paramId value is an integer. Show them the param DB grib_context_log(h->context, GRIB_LOG_ERROR, - "Please check the Parameter Database 'https://codes.ecmwf.int/grib/param-db/?id=%s'", name); - } else { + "Please check the Parameter Database 'https://codes.ecmwf.int/grib/param-db/?id=%s'", name); + } + else { // paramId being set to a non-integer grib_context_log(h->context, GRIB_LOG_ERROR, - "The paramId value should be an integer. Are you trying to set the shortName?"); + "The paramId value should be an integer. Are you trying to set the shortName?"); } } if (strcmp(act->name, "shortName") == 0) { @@ -441,25 +348,42 @@ static int grib_concept_apply(grib_accessor* a, const char* name) return err; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_concept_t::pack_double(grib_accessor* a, const double* val, size_t* len) { return GRIB_NOT_IMPLEMENTED; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_concept_t::pack_long(grib_accessor* a, const long* val, size_t* len) { char buf[80]; size_t s; snprintf(buf, sizeof(buf), "%ld", *val); - //if(*len > 1) - // return GRIB_NOT_IMPLEMENTED; + // if(*len > 1) + // return GRIB_NOT_IMPLEMENTED; + + // ECC-1806: GRIB: Change of paramId in conversion from GRIB1 to GRIB2 + if (STR_EQUAL(a->name, "paramId")) { + grib_handle* h = grib_handle_of_accessor(a); + long edition = 0; + if (grib_get_long(h, "edition", &edition) == GRIB_SUCCESS && edition == 2) { + long newParamId = 0; + if (grib_get_long(h, "paramIdForConversion", &newParamId) == GRIB_SUCCESS && newParamId > 0) { + if (a->context->debug) { + const char* cclass_name = a->cclass->name; + fprintf(stderr, "ECCODES DEBUG %s::%s: Changing %s from %ld to %ld\n", + cclass_name, __func__, a->name, *val, newParamId); + } + snprintf(buf, sizeof(buf), "%ld", newParamId); + } + } + } s = strlen(buf) + 1; return pack_string(a, buf, &s); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_concept_t::unpack_double(grib_accessor* a, double* val, size_t* len) { /* * If we want to have a condition which contains tests for paramId as well @@ -492,7 +416,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_concept_t::unpack_long(grib_accessor* a, long* val, size_t* len) { const char* p = concept_evaluate(a); @@ -512,14 +436,14 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) * Keep this check in DEBUG mode only */ { - char *endptr; + char* endptr; *val = strtol(p, &endptr, 10); if (endptr == p || *endptr != '\0') { /* Failed to convert string into integer */ int type = GRIB_TYPE_UNDEFINED; - grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as long",a->name); + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack %s as long", a->name); if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context,GRIB_LOG_ERROR,"Hint: Try unpacking as %s", grib_get_type_name(type)); + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); } return GRIB_DECODING_ERROR; } @@ -528,7 +452,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_concept_t::get_native_type(grib_accessor* a) { int type = GRIB_TYPE_STRING; if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) @@ -537,13 +461,14 @@ static int get_native_type(grib_accessor* a) return type; } -static void destroy(grib_context* c, grib_accessor* a) +void grib_accessor_class_concept_t::destroy(grib_context* c, grib_accessor* a) { - //grib_accessor_concept *self = (grib_accessor_concept*)a; - //grib_context_free(c,self->cval); + // grib_accessor_concept_t *self = (grib_accessor_concept_t*)a; + // grib_context_free(c,self->cval); + grib_accessor_class_gen_t::destroy(c, a); } -static int unpack_string(grib_accessor* a, char* val, size_t* len) +int grib_accessor_class_concept_t::unpack_string(grib_accessor* a, char* val, size_t* len) { size_t slen; const char* p = concept_evaluate(a); @@ -559,7 +484,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) slen = strlen(p) + 1; if (*len < slen) { grib_context_log(a->context, GRIB_LOG_ERROR, - "Concept unpack_string. Buffer too small for %s, value='%s' which requires %lu bytes (len=%lu)", + "Concept unpack_string. Buffer too small for %s, value='%s' which requires %lu bytes (len=%lu)", a->name, p, slen, *len); *len = slen; return GRIB_BUFFER_TOO_SMALL; @@ -567,33 +492,33 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) strcpy(val, p); /* NOLINT: CWE-119 clang-analyzer-security.insecureAPI.strcpy */ *len = slen; -// if (a->context->debug==1) { -// int err = 0; -// char result[1024] = {0,}; -// err = get_concept_condition_string(grib_handle_of_accessor(a), a->name, val, result); -// if (!err) fprintf(stderr, "ECCODES DEBUG concept name=%s, value=%s, conditions=%s\n", a->name, val, result); -// } + // if (a->context->debug==1) { + // int err = 0; + // char result[1024] = {0,}; + // err = get_concept_condition_string(grib_handle_of_accessor(a), a->name, val, result); + // if (!err) fprintf(stderr, "ECCODES DEBUG concept name=%s, value=%s, conditions=%s\n", a->name, val, result); + // } return GRIB_SUCCESS; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) +int grib_accessor_class_concept_t::pack_string(grib_accessor* a, const char* val, size_t* len) { return grib_concept_apply(a, val); } -static size_t string_length(grib_accessor* a) +size_t grib_accessor_class_concept_t::string_length(grib_accessor* a) { return MAX_CONCEPT_STRING_LENGTH; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_concept_t::value_count(grib_accessor* a, long* count) { *count = 1; return 0; } -static int compare(grib_accessor* a, grib_accessor* b) +int grib_accessor_class_concept_t::compare(grib_accessor* a, grib_accessor* b) { int retval = 0; char* aval = 0; @@ -604,11 +529,11 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); + err = b->value_count(&count); if (err) return err; blen = count; @@ -620,9 +545,9 @@ static int compare(grib_accessor* a, grib_accessor* b) aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); - err = grib_unpack_string(a, aval, &alen); + err = a->unpack_string(aval, &alen); if (err) return err; - err = grib_unpack_string(b, bval, &blen); + err = b->unpack_string(bval, &blen); if (err) return err; retval = GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_concept.h b/src/accessor/grib_accessor_class_concept.h new file mode 100644 index 000000000..7b9ea11d0 --- /dev/null +++ b/src/accessor/grib_accessor_class_concept.h @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_concept_t : public grib_accessor_gen_t +{ +public: + /* Members defined in concept */ +}; + +class grib_accessor_class_concept_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_concept_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_concept_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_constant.cc b/src/accessor/grib_accessor_class_constant.cc new file mode 100644 index 000000000..ed30a6365 --- /dev/null +++ b/src/accessor/grib_accessor_class_constant.cc @@ -0,0 +1,20 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_constant.h" + +grib_accessor_class_constant_t _grib_accessor_class_constant{"constant"}; +grib_accessor_class* grib_accessor_class_constant = &_grib_accessor_class_constant; + +void grib_accessor_class_constant_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_variable_t::init(a, len, arg); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} diff --git a/src/accessor/grib_accessor_class_constant.h b/src/accessor/grib_accessor_class_constant.h new file mode 100644 index 000000000..916df88e9 --- /dev/null +++ b/src/accessor/grib_accessor_class_constant.h @@ -0,0 +1,21 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_variable.h" + +class grib_accessor_constant_t : public grib_accessor_variable_t {}; + +class grib_accessor_class_constant_t : public grib_accessor_class_variable_t +{ +public: + grib_accessor_class_constant_t(const char* name) : grib_accessor_class_variable_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_constant_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_count_file.cc b/src/accessor/grib_accessor_class_count_file.cc new file mode 100644 index 000000000..268ba8051 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_file.cc @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_count_file.h" + +grib_accessor_class_count_file_t _grib_accessor_class_count_file{ "count_file" }; +grib_accessor_class* grib_accessor_class_count_file = &_grib_accessor_class_count_file; + + +void grib_accessor_class_count_file_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_count_file_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + *val = grib_context_get_handle_file_count(a->context); + *len = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_count_file.h b/src/accessor/grib_accessor_class_count_file.h new file mode 100644 index 000000000..25092b0a4 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_file.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_count_file_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_file */ +}; + +class grib_accessor_class_count_file_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_file_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_file_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_count_missing.cc b/src/accessor/grib_accessor_class_count_missing.cc similarity index 50% rename from src/grib_accessor_class_count_missing.cc rename to src/accessor/grib_accessor_class_count_missing.cc index a4ed76841..7a3232175 100644 --- a/src/grib_accessor_class_count_missing.cc +++ b/src/accessor/grib_accessor_class_count_missing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,104 +9,11 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init; - IMPLEMENTS = value_count - MEMBERS = const char* bitmap - MEMBERS = const char* unusedBitsInBitmap - MEMBERS = const char* numberOfDataPoints - MEMBERS = const char* missingValueManagementUsed - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_count_missing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in count_missing */ - const char* bitmap; - const char* unusedBitsInBitmap; - const char* numberOfDataPoints; - const char* missingValueManagementUsed; -} grib_accessor_count_missing; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_count_missing = { - &grib_accessor_class_long, /* super */ - "count_missing", /* name */ - sizeof(grib_accessor_count_missing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_count_missing.h" +grib_accessor_class_count_missing_t _grib_accessor_class_count_missing{ "count_missing" }; grib_accessor_class* grib_accessor_class_count_missing = &_grib_accessor_class_count_missing; -/* END_CLASS_IMP */ static const unsigned char bitsoff[] = { 8, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 4, 7, @@ -126,16 +34,17 @@ static const unsigned char bitsoff[] = { 0 }; -static void init(grib_accessor* a, const long len, grib_arguments* arg) +void grib_accessor_class_count_missing_t::init(grib_accessor* a, const long len, grib_arguments* arg) { - int n = 0; - grib_accessor_count_missing* self = (grib_accessor_count_missing*)a; - grib_handle* h = grib_handle_of_accessor(a); - a->length = 0; + grib_accessor_class_long_t::init(a, len, arg); + int n = 0; + grib_accessor_count_missing_t* self = (grib_accessor_count_missing_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - self->bitmap = grib_arguments_get_name(h, arg, n++); - self->unusedBitsInBitmap = grib_arguments_get_name(h, arg, n++); - self->numberOfDataPoints = grib_arguments_get_name(h, arg, n++); + self->bitmap = grib_arguments_get_name(h, arg, n++); + self->unusedBitsInBitmap = grib_arguments_get_name(h, arg, n++); + self->numberOfDataPoints = grib_arguments_get_name(h, arg, n++); self->missingValueManagementUsed = grib_arguments_get_name(h, arg, n++); /* Can be NULL */ } @@ -165,9 +74,9 @@ static int get_count_of_missing_values(grib_handle* h, long* p_count_of_missing) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_count_missing_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_count_missing* self = (grib_accessor_count_missing*)a; + grib_accessor_count_missing_t* self = (grib_accessor_count_missing_t*)a; unsigned char* p; int i; long size = 0; @@ -182,11 +91,10 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) if (!bitmap) { long mvmu = 0; if (self->missingValueManagementUsed && - grib_get_long(h, self->missingValueManagementUsed, &mvmu) == GRIB_SUCCESS && mvmu != 0) - { + grib_get_long(h, self->missingValueManagementUsed, &mvmu) == GRIB_SUCCESS && mvmu != 0) { /* ECC-523: No bitmap. Missing values are encoded in the Data Section. * So we must decode all the data values and count how many are missing - */ + */ long count_of_missing = 0; if (get_count_of_missing_values(h, &count_of_missing) == GRIB_SUCCESS) { *val = count_of_missing; @@ -195,9 +103,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } - size = grib_byte_count(bitmap); - offset = grib_byte_offset(bitmap); - + size = bitmap->byte_count(); + offset = bitmap->byte_offset(); if (grib_get_long(h, self->unusedBitsInBitmap, &unusedBitsInBitmap) != GRIB_SUCCESS) { if (grib_get_long(h, self->numberOfDataPoints, &numberOfDataPoints) != GRIB_SUCCESS) { grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to count missing values"); @@ -206,7 +113,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) unusedBitsInBitmap = size * 8 - numberOfDataPoints; if (unusedBitsInBitmap < 0) { grib_context_log(a->context, GRIB_LOG_ERROR, "Inconsistent number of bitmap points: Check the bitmap and data sections!"); - grib_context_log(a->context, GRIB_LOG_ERROR, "Bitmap size=%ld, numberOfDataPoints=%ld", size*8, numberOfDataPoints); + grib_context_log(a->context, GRIB_LOG_ERROR, "Bitmap size=%ld, numberOfDataPoints=%ld", size * 8, numberOfDataPoints); return GRIB_DECODING_ERROR; } } @@ -224,7 +131,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_count_missing_t::value_count(grib_accessor* a, long* count) { *count = 1; return 0; diff --git a/src/accessor/grib_accessor_class_count_missing.h b/src/accessor/grib_accessor_class_count_missing.h new file mode 100644 index 000000000..3e2cf7330 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_missing.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_count_missing_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_missing */ + const char* bitmap; + const char* unusedBitsInBitmap; + const char* numberOfDataPoints; + const char* missingValueManagementUsed; +}; + +class grib_accessor_class_count_missing_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_missing_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_missing_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_count_total.cc b/src/accessor/grib_accessor_class_count_total.cc new file mode 100644 index 000000000..dc708b4b6 --- /dev/null +++ b/src/accessor/grib_accessor_class_count_total.cc @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_count_total.h" + +grib_accessor_class_count_total_t _grib_accessor_class_count_total{ "count_total" }; +grib_accessor_class* grib_accessor_class_count_total = &_grib_accessor_class_count_total; + + +void grib_accessor_class_count_total_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_count_total_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + *val = grib_context_get_handle_total_count(a->context); + *len = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_count_total.h b/src/accessor/grib_accessor_class_count_total.h new file mode 100644 index 000000000..6fa89df0e --- /dev/null +++ b/src/accessor/grib_accessor_class_count_total.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_count_total_t : public grib_accessor_long_t +{ +public: + /* Members defined in count_total */ +}; + +class grib_accessor_class_count_total_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_count_total_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_count_total_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_bitmap.cc similarity index 58% rename from src/grib_accessor_class_data_apply_bitmap.cc rename to src/accessor/grib_accessor_class_data_apply_bitmap.cc index 675e7b3de..cf3d5f4a5 100644 --- a/src/grib_accessor_class_data_apply_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,123 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_value.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = unpack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_float - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = dump;get_native_type - IMPLEMENTS = compare - MEMBERS=const char* coded_values - MEMBERS=const char* bitmap - MEMBERS=const char* missing_value - MEMBERS=const char* number_of_data_points - MEMBERS=const char* number_of_values - MEMBERS=const char* binary_scale_factor - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_apply_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_apply_bitmap */ - const char* coded_values; - const char* bitmap; - const char* missing_value; - const char* number_of_data_points; - const char* number_of_values; - const char* binary_scale_factor; -} grib_accessor_data_apply_bitmap; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_data_apply_bitmap = { - &grib_accessor_class_gen, /* super */ - "data_apply_bitmap", /* name */ - sizeof(grib_accessor_data_apply_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_apply_bitmap.h" +grib_accessor_class_data_apply_bitmap_t _grib_accessor_class_data_apply_bitmap{ "data_apply_bitmap" }; grib_accessor_class* grib_accessor_class_data_apply_bitmap = &_grib_accessor_class_data_apply_bitmap; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) +void grib_accessor_class_data_apply_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args) { - int n = 0; - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; + grib_accessor_class_gen_t::init(a, v, args); + int n = 0; + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; self->coded_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); self->bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); @@ -135,16 +30,16 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_data_apply_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_values(dumper, a); } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_data_apply_bitmap_t::value_count(grib_accessor* a, long* count) { - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; - size_t len = 0; - int ret = 0; + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + size_t len = 0; + int ret = GRIB_SUCCESS; if (grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) ret = grib_get_size(grib_handle_of_accessor(a), self->bitmap, &len); @@ -156,18 +51,17 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) +int grib_accessor_class_data_apply_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) { - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; - grib_handle* gh = grib_handle_of_accessor(a); - int err = 0, i = 0; - size_t cidx = 0; + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + size_t i = 0, cidx = 0; double missing_value = 0; double* bvals = NULL; size_t n_vals = 0; long nn = 0; - err = grib_value_count(a, &nn); + int err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -203,20 +97,20 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return grib_get_double_element_internal(gh, self->coded_values, cidx, val); } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +int grib_accessor_class_data_apply_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) { - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; - grib_handle* gh = grib_handle_of_accessor(a); + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); int err = 0, all_missing = 1; - size_t cidx = 0; /* index into the coded_values array */ - size_t* cidx_array = NULL; /* array of indexes into the coded_values */ - double* cval_array = NULL; /* array of values of the coded_values */ + size_t cidx = 0; /* index into the coded_values array */ + size_t* cidx_array = NULL; /* array of indexes into the coded_values */ + double* cval_array = NULL; /* array of values of the coded_values */ double missing_value = 0; double* bvals = NULL; size_t n_vals = 0, i = 0, j = 0, idx = 0, count_1s = 0, ci = 0; long nn = 0; - err = grib_value_count(a, &nn); + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -231,7 +125,8 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array for (i = 0; i < len; i++) { if (val_array[i] == 0) { val_array[i] = missing_value; - } else { + } + else { all_missing = 0; count_1s++; } @@ -256,7 +151,7 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array ci = 0; for (i = 0; i < len; i++) { if (val_array[i] == 1) { - idx = index_array[i]; + idx = index_array[i]; cidx = 0; for (j = 0; j < idx; j++) { cidx += bvals[j]; @@ -283,18 +178,18 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_data_apply_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; - int err = 0; - size_t bmaplen = *len; - long coded_n_vals = 0; - double* coded_vals = NULL; - long i = 0; - long j = 0; - double missing_value = 0; - grib_handle* hand = grib_handle_of_accessor(a); - grib_context* ctxt = a->context; + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + int err = 0; + size_t bmaplen = *len; + long coded_n_vals = 0; + double* coded_vals = NULL; + long i = 0; + long j = 0; + double missing_value = 0; + grib_handle* hand = grib_handle_of_accessor(a); + grib_context* ctxt = a->context; if (*len == 0) return GRIB_NO_VALUES; @@ -343,22 +238,22 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return err; } + template static int unpack(grib_accessor* a, T* val, size_t* len) { static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; + grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; size_t i = 0; size_t j = 0; size_t n_vals = 0; long nn = 0; - int err = 0; size_t coded_n_vals = 0; - T* coded_vals = NULL; + T* coded_vals = NULL; double missing_value = 0; - err = grib_value_count(a, &nn); + int err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -399,8 +294,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_class_data_apply_bitmap: %s : creating %s, %d values", - __func__, - a->name, n_vals); + __func__, a->name, n_vals); for (i = 0; i < n_vals; i++) { if (val[i] == 0) { @@ -426,25 +320,24 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return err; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_data_apply_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len) { return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) +int grib_accessor_class_data_apply_bitmap_t::unpack_float(grib_accessor* a, float* val, size_t* len) { return unpack(a, val, len); } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_data_apply_bitmap_t::get_native_type(grib_accessor* a) { - //grib_accessor_data_apply_bitmap* self = (grib_accessor_data_apply_bitmap*)a; - //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); - + // grib_accessor_data_apply_bitmap_t* self = (grib_accessor_data_apply_bitmap_t*)a; + // return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); return GRIB_TYPE_DOUBLE; } -static int compare(grib_accessor* a, grib_accessor* b) +int grib_accessor_class_data_apply_bitmap_t::compare(grib_accessor* a, grib_accessor* b) { int retval = GRIB_SUCCESS; double* aval = 0; @@ -455,12 +348,12 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); + err = b->value_count(&count); if (err) return err; blen = count; @@ -471,11 +364,10 @@ static int compare(grib_accessor* a, grib_accessor* b) aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - + a->unpack_double(aval, &alen); + b->unpack_double(bval, &blen); retval = GRIB_SUCCESS; - for (size_t i=0; ivalues = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); self->numberOfRows = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); self->numberOfColumns = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); @@ -130,32 +29,30 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_data_apply_boustrophedonic_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_values(dumper, a); } -static int value_count(grib_accessor* a, long* numberOfPoints) +int grib_accessor_class_data_apply_boustrophedonic_t::value_count(grib_accessor* a, long* numberOfPoints) { - grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a; - int ret = 0; + grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; *numberOfPoints = 0; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints); - - return ret; + return grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints); } template static int unpack(grib_accessor* a, T* val, size_t* len) { - grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a; - size_t plSize = 0; - long* pl = 0; - double* values = 0; - double* pvalues = 0; - T* pval = 0; - size_t valuesSize = 0; + grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; + + size_t plSize = 0; + long* pl = 0; + double* values = 0; + double* pvalues = 0; + T* pval = 0; + size_t valuesSize = 0; long i, j; int ret; long numberOfPoints, numberOfRows, numberOfColumns; @@ -241,24 +138,23 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double(grib_accessor* a, double* val, size_t* len) { return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_float(grib_accessor* a, float* val, size_t* len) { return unpack(a, val, len); } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) { size_t size; double* values; - int err = 0; /* GRIB-564: The index idx relates to codedValues NOT values! */ - err = grib_get_size(a->parent->h, "codedValues", &size); + int err = grib_get_size(a->parent->h, "codedValues", &size); if (err) return err; if (idx > size) @@ -275,7 +171,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) { size_t size = 0, i = 0; double* values; @@ -303,20 +199,20 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_data_apply_boustrophedonic_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_data_apply_boustrophedonic* self = (grib_accessor_data_apply_boustrophedonic*)a; - size_t plSize = 0; - long* pl = 0; - double* values = 0; - double* pvalues = 0; - double* pval = 0; - size_t valuesSize = 0; + grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a; + + size_t plSize = 0; + long* pl = 0; + double* values = 0; + double* pvalues = 0; + double* pval = 0; + size_t valuesSize = 0; long i, j; - int ret; long numberOfPoints, numberOfRows, numberOfColumns; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints); + int ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints); if (ret) return ret; @@ -386,7 +282,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_data_apply_boustrophedonic_t::get_native_type(grib_accessor* a) { return GRIB_TYPE_DOUBLE; } diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h new file mode 100644 index 000000000..97987d217 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_apply_boustrophedonic_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_apply_boustrophedonic */ + const char* values; + const char* numberOfRows; + const char* numberOfColumns; + const char* numberOfPoints; + const char* pl; +}; + +class grib_accessor_class_data_apply_boustrophedonic_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_apply_boustrophedonic_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_boustrophedonic_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc similarity index 69% rename from src/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc rename to src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc index b68e362db..f796cfb02 100644 --- a/src/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,122 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = unpack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = dump;get_native_type - MEMBERS=const char* coded_values - MEMBERS=const char* bitmap - MEMBERS=const char* missing_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* numberOfRows - MEMBERS=const char* numberOfColumns - MEMBERS=const char* numberOfPoints - - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_apply_boustrophedonic_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_apply_boustrophedonic_bitmap */ - const char* coded_values; - const char* bitmap; - const char* missing_value; - const char* binary_scale_factor; - const char* numberOfRows; - const char* numberOfColumns; - const char* numberOfPoints; -} grib_accessor_data_apply_boustrophedonic_bitmap; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_data_apply_boustrophedonic_bitmap = { - &grib_accessor_class_gen, /* super */ - "data_apply_boustrophedonic_bitmap", /* name */ - sizeof(grib_accessor_data_apply_boustrophedonic_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_apply_boustrophedonic_bitmap.h" +grib_accessor_class_data_apply_boustrophedonic_bitmap_t _grib_accessor_class_data_apply_boustrophedonic_bitmap{"data_apply_boustrophedonic_bitmap"}; grib_accessor_class* grib_accessor_class_data_apply_boustrophedonic_bitmap = &_grib_accessor_class_data_apply_boustrophedonic_bitmap; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ +void grib_accessor_class_data_apply_boustrophedonic_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); int n = 0; - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->coded_values = grib_arguments_get_name(gh, args, n++); @@ -138,14 +33,12 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_data_apply_boustrophedonic_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_values(dumper, a); } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); size_t len = 0; int ret = 0; @@ -158,9 +51,8 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); size_t i = 0, j = 0, n_vals = 0, irow = 0; @@ -171,8 +63,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) double missing_value = 0; long numberOfPoints, numberOfRows, numberOfColumns; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -268,9 +159,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return err; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int err = 0, i = 0; size_t cidx = 0; @@ -279,8 +169,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) size_t n_vals = 0; long nn = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -315,9 +204,8 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return grib_get_double_element_internal(gh, self->coded_values, cidx, val); } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int err = 0, all_missing = 1; size_t cidx = 0; /* index into the coded_values array */ @@ -328,8 +216,7 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array size_t n_vals = 0, i = 0, j = 0, idx = 0, count_1s = 0, ci = 0; long nn = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; if (!grib_find_accessor(gh, self->bitmap)) @@ -395,9 +282,8 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; grib_handle* gh = grib_handle_of_accessor(a); int err = 0; size_t bmaplen = *len; @@ -495,9 +381,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return err; } -static int get_native_type(grib_accessor* a) -{ - //grib_accessor_data_apply_boustrophedonic_bitmap* self = (grib_accessor_data_apply_boustrophedonic_bitmap*)a; +int grib_accessor_class_data_apply_boustrophedonic_bitmap_t::get_native_type(grib_accessor* a){ + //grib_accessor_data_apply_boustrophedonic_bitmap_t* self = (grib_accessor_data_apply_boustrophedonic_bitmap_t*)a; //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); return GRIB_TYPE_DOUBLE; diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h new file mode 100644 index 000000000..fee603876 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.h @@ -0,0 +1,41 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_apply_boustrophedonic_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_apply_boustrophedonic_bitmap */ + const char* coded_values; + const char* bitmap; + const char* missing_value; + const char* binary_scale_factor; + const char* numberOfRows; + const char* numberOfColumns; + const char* numberOfPoints; +}; + +class grib_accessor_class_data_apply_boustrophedonic_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_apply_boustrophedonic_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_apply_boustrophedonic_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc similarity index 67% rename from src/grib_accessor_class_data_ccsds_packing.cc rename to src/accessor/grib_accessor_class_data_ccsds_packing.cc index 28e961e86..5b0813bfd 100644 --- a/src/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,138 +9,26 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_bits_any_endian_simple.h" -#include "grib_scaling.h" -#include -#include +#include "grib_accessor_class_data_ccsds_packing.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - MEMBERS=const char* number_of_values - MEMBERS=const char* reference_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* decimal_scale_factor - MEMBERS=const char* optimize_scaling_factor - MEMBERS=const char* bits_per_value - MEMBERS=const char* number_of_data_points - MEMBERS=const char* ccsds_flags - MEMBERS=const char* ccsds_block_size - MEMBERS=const char* ccsds_rsi - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_ccsds_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_ccsds_packing */ - const char* number_of_values; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - const char* bits_per_value; - const char* number_of_data_points; - const char* ccsds_flags; - const char* ccsds_block_size; - const char* ccsds_rsi; -} grib_accessor_data_ccsds_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_ccsds_packing = { - &grib_accessor_class_values, /* super */ - "data_ccsds_packing", /* name */ - sizeof(grib_accessor_data_ccsds_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; +#if defined(HAVE_LIBAEC) || defined(HAVE_AEC) + #include + #ifndef LIBAEC_DLL_EXPORTED + #error Version of libaec appears to be too old. Please upgrade. + #endif +#endif +grib_accessor_class_data_ccsds_packing_t _grib_accessor_class_data_ccsds_packing{ "data_ccsds_packing" }; grib_accessor_class* grib_accessor_class_data_ccsds_packing = &_grib_accessor_class_data_ccsds_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) +void grib_accessor_class_data_ccsds_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) { - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; - grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_class_values_t::init(a, v, args); + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; + + grib_handle* h = grib_handle_of_accessor(a); self->number_of_values = grib_arguments_get_name(h, args, self->carg++); self->reference_value = grib_arguments_get_name(h, args, self->carg++); @@ -155,24 +44,18 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_data_ccsds_packing_t::value_count(grib_accessor* a, long* count) { - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; *count = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, count); } #if defined(HAVE_LIBAEC) || defined(HAVE_AEC) -#include - -#ifndef LIBAEC_DLL_EXPORTED - #error Version of libaec appears to be too old. Please upgrade. -#endif - static bool is_big_endian() { - unsigned char is_big_endian = 0; + unsigned char is_big_endian = 0; unsigned short endianess_test = 1; return reinterpret_cast(&endianess_test)[0] == is_big_endian; } @@ -182,38 +65,38 @@ static void modify_aec_flags(long* flags) // ECC-1602: Performance improvement: enabled the use of native data types *flags &= ~AEC_DATA_3BYTE; // disable support for 3-bytes per value if (is_big_endian()) - *flags |= AEC_DATA_MSB; // enable big-endian + *flags |= AEC_DATA_MSB; // enable big-endian else *flags &= ~AEC_DATA_MSB; // enable little-endian } static const char* aec_get_error_message(int code) { - if (code == AEC_MEM_ERROR) return "AEC_MEM_ERROR"; - if (code == AEC_DATA_ERROR) return "AEC_DATA_ERROR"; + if (code == AEC_MEM_ERROR) return "AEC_MEM_ERROR"; + if (code == AEC_DATA_ERROR) return "AEC_DATA_ERROR"; if (code == AEC_STREAM_ERROR) return "AEC_STREAM_ERROR"; - if (code == AEC_CONF_ERROR) return "AEC_CONF_ERROR"; - if (code == AEC_OK) return "AEC_OK"; + if (code == AEC_CONF_ERROR) return "AEC_CONF_ERROR"; + if (code == AEC_OK) return "AEC_OK"; return "Unknown error code"; } static void print_aec_stream_info(struct aec_stream* strm, const char* func) { - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.flags=%u\n", func, strm->flags); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.flags=%u\n", func, strm->flags); fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.bits_per_sample=%u\n", func, strm->bits_per_sample); - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.block_size=%u\n", func, strm->block_size); - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.rsi=%u\n", func, strm->rsi); - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_out=%lu\n", func, strm->avail_out); - fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.block_size=%u\n", func, strm->block_size); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.rsi=%u\n", func, strm->rsi); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_out=%lu\n", func, strm->avail_out); + fprintf(stderr, "ECCODES DEBUG CCSDS %s aec_stream.avail_in=%lu\n", func, strm->avail_in); } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_handle* hand = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; - int err = GRIB_SUCCESS; + int err = GRIB_SUCCESS; size_t buflen = 0, i = 0; bool is_constant_field = false; @@ -223,9 +106,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) long binary_scale_factor = 0; long decimal_scale_factor = 0; - //long optimize_scaling_factor = 0; - double reference_value = 0; - long bits_per_value = 0; + // long optimize_scaling_factor = 0; + double reference_value = 0; + long bits_per_value = 0; double max, min, d, divisor; long number_of_data_points; @@ -249,8 +132,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if ((err = grib_get_long_internal(hand, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) return err; - //if ((err = grib_get_long_internal(gh, self->optimize_scaling_factor, &optimize_scaling_factor)) != GRIB_SUCCESS) - // return err; + // if ((err = grib_get_long_internal(gh, self->optimize_scaling_factor, &optimize_scaling_factor)) != GRIB_SUCCESS) + // return err; if ((err = grib_get_long_internal(hand, self->ccsds_flags, &ccsds_flags)) != GRIB_SUCCESS) return err; @@ -270,8 +153,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) max = val[0]; min = max; for (i = 1; i < n_vals; i++) { - if (val[i] > max) max = val[i]; - else if (val[i] < min) min = val[i]; + if (val[i] > max) + max = val[i]; + else if (val[i] < min) + min = val[i]; } if ((err = grib_check_data_values_minmax(hand, min, max)) != GRIB_SUCCESS) { @@ -280,10 +165,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if (min == max) { is_constant_field = true; - } else { + } + else { if (bits_per_value == 0) { // ECC-1202: A non-constant field with bitsPerValue==0! - bits_per_value = 24; //Set sane value + bits_per_value = 24; // Set sane value } } @@ -303,7 +189,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if ((err = grib_set_long_internal(hand, self->number_of_values, n_vals)) != GRIB_SUCCESS) return err; - bits_per_value = 0; // ECC-1387 + bits_per_value = 0; // ECC-1387 if ((err = grib_set_long_internal(hand, self->bits_per_value, bits_per_value)) != GRIB_SUCCESS) return err; @@ -322,25 +208,25 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if (grib_get_nearest_smaller_value(hand, self->reference_value, min, &reference_value) != GRIB_SUCCESS) { grib_context_log(a->context, GRIB_LOG_ERROR, - "%s %s: Unable to find nearest_smaller_value of %g for %s", cclass_name, __func__, min, self->reference_value); + "%s %s: Unable to find nearest_smaller_value of %g for %s", cclass_name, __func__, min, self->reference_value); return GRIB_INTERNAL_ERROR; } if (reference_value > min) { grib_context_log(a->context, GRIB_LOG_ERROR, - "%s %s: reference_value=%g min_value=%g diff=%g", cclass_name, __func__, reference_value, min, reference_value - min); + "%s %s: reference_value=%g min_value=%g diff=%g", cclass_name, __func__, reference_value, min, reference_value - min); DEBUG_ASSERT(reference_value <= min); return GRIB_INTERNAL_ERROR; } } else { - int last = 127; // last must be a parameter coming from the def file - double range = 0; + int last = 127; // last must be a parameter coming from the def file + double range = 0; double minrange = 0, maxrange = 0; double unscaled_max = 0; double unscaled_min = 0; - double f = 0; - double decimal = 1; + double f = 0; + double decimal = 1; decimal_scale_factor = 0; range = (max - min); @@ -423,17 +309,17 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) } break; default: - grib_context_log(a->context, GRIB_LOG_ERROR,"%s pack_double: packing %s, bits_per_value=%ld (max 32)", - cclass_name, a->name, bits_per_value); + grib_context_log(a->context, GRIB_LOG_ERROR, "%s pack_double: packing %s, bits_per_value=%ld (max 32)", + cclass_name, a->name, bits_per_value); err = GRIB_INVALID_BPV; goto cleanup; } - grib_context_log(a->context, GRIB_LOG_DEBUG,"%s pack_double: packing %s, %zu values", cclass_name, a->name, n_vals); + grib_context_log(a->context, GRIB_LOG_DEBUG, "%s pack_double: packing %s, %zu values", cclass_name, a->name, n_vals); // ECC-1431: GRIB2: CCSDS encoding failure AEC_STREAM_ERROR buflen = (nbytes * n_vals) * 67 / 64 + 256; - buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context, buflen); + buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context, buflen); if (!buf) { err = GRIB_OUT_OF_MEMORY; @@ -448,7 +334,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) grib_get_double_internal(hand, self->reference_value, &ref); if (ref != reference_value) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: %s (ref=%.10e != reference_value=%.10e)", - cclass_name, __func__, self->reference_value, ref, reference_value); + cclass_name, __func__, self->reference_value, ref, reference_value); return GRIB_INTERNAL_ERROR; } } @@ -469,7 +355,6 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) strm.next_in = encoded; strm.avail_in = nbytes * n_vals; - // This does not support spherical harmonics, and treats 24 differently than: // see http://cdo.sourcearchive.com/documentation/1.5.1.dfsg.1-1/cgribexlib_8c_source.html @@ -477,7 +362,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if ((err = aec_buffer_encode(&strm)) != AEC_OK) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_encode error %d (%s)", - cclass_name, __func__, err, aec_get_error_message(err)); + cclass_name, __func__, err, aec_get_error_message(err)); err = GRIB_ENCODING_ERROR; goto cleanup; } @@ -502,21 +387,21 @@ template static int unpack(grib_accessor* a, T* val, size_t* len) { static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; int err = GRIB_SUCCESS, i = 0; size_t buflen = 0; struct aec_stream strm; - double bscale = 0; - double dscale = 0; - unsigned char* buf = NULL; - size_t n_vals = 0; - size_t size = 0; + double bscale = 0; + double dscale = 0; + unsigned char* buf = NULL; + size_t n_vals = 0; + size_t size = 0; unsigned char* decoded = NULL; // unsigned char* p = NULL; - long nn = 0; + long nn = 0; long binary_scale_factor = 0; long decimal_scale_factor = 0; @@ -530,7 +415,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) self->dirty = 0; - if ((err = grib_value_count(a, &nn)) != GRIB_SUCCESS) + if ((err = a->value_count(&nn)) != GRIB_SUCCESS) return err; n_vals = nn; @@ -569,10 +454,9 @@ static int unpack(grib_accessor* a, T* val, size_t* len) bscale = codes_power(binary_scale_factor, 2); dscale = codes_power(-decimal_scale_factor, 10); - buflen = grib_byte_count(a); - buf = (unsigned char*)hand->buffer->data; - buf += grib_byte_offset(a); - + buflen = a->byte_count(); + buf = (unsigned char*)hand->buffer->data; + buf += a->byte_offset(); strm.flags = ccsds_flags; strm.bits_per_sample = bits_per_value; strm.block_size = ccsds_block_size; @@ -598,13 +482,13 @@ static int unpack(grib_accessor* a, T* val, size_t* len) if ((err = aec_buffer_decode(&strm)) != AEC_OK) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: aec_buffer_decode error %d (%s)", - cclass_name, __func__, err, aec_get_error_message(err)); + cclass_name, __func__, err, aec_get_error_message(err)); err = GRIB_DECODING_ERROR; goto cleanup; } // ECC-1427: Performance improvement (replaced by ECC-1602) - //grib_decode_array(decoded, &pos, bits8 , reference_value, bscale, dscale, n_vals, val); + // grib_decode_array(decoded, &pos, bits8 , reference_value, bscale, dscale, n_vals, val); // ECC-1602: Performance improvement switch (nbytes) { @@ -625,7 +509,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) break; default: grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: unpacking %s, bits_per_value=%ld (max 32)", - cclass_name, __func__, a->name, bits_per_value); + cclass_name, __func__, a->name, bits_per_value); err = GRIB_INVALID_BPV; goto cleanup; } @@ -637,26 +521,27 @@ cleanup: return err; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) { return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) +int grib_accessor_class_data_ccsds_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) { return unpack(a, val, len); } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) { // The index idx relates to codedValues NOT values! - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int err = 0; - size_t size = 0; - long bits_per_value = 0; + const grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; + + grib_handle* hand = grib_handle_of_accessor(a); + int err = 0; + size_t size = 0; + long bits_per_value = 0; double reference_value = 0; - double* values = NULL; + double* values = NULL; if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) return err; @@ -684,14 +569,14 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) { - grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a; + const grib_accessor_data_ccsds_packing_t* self = (grib_accessor_data_ccsds_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0, i = 0; - double* values = NULL; - int err = 0; - long bits_per_value = 0; + double* values = NULL; + int err = 0; + long bits_per_value = 0; double reference_value = 0; if ((err = grib_get_long_internal(hand, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) @@ -738,27 +623,27 @@ static void print_error_feature_not_enabled(grib_context* c) "CCSDS support not enabled. " "Please rebuild with -DENABLE_AEC=ON (Adaptive Entropy Coding library)"); } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_data_ccsds_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) { print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_data_ccsds_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) { print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_float(grib_accessor* a, float* val, size_t* len) +int grib_accessor_class_data_ccsds_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) { print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) { print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +int grib_accessor_class_data_ccsds_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) { print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.h b/src/accessor/grib_accessor_class_data_ccsds_packing.h new file mode 100644 index 000000000..0f9430232 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.h @@ -0,0 +1,45 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_values.h" +#include "grib_scaling.h" + +class grib_accessor_data_ccsds_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_ccsds_packing */ + const char* number_of_values; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scaling_factor; + const char* bits_per_value; + const char* number_of_data_points; + const char* ccsds_flags; + const char* ccsds_block_size; + const char* ccsds_rsi; +}; + + +class grib_accessor_class_data_ccsds_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_ccsds_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_ccsds_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/grib_accessor_class_data_complex_packing.cc b/src/accessor/grib_accessor_class_data_complex_packing.cc similarity index 77% rename from src/grib_accessor_class_data_complex_packing.cc rename to src/accessor/grib_accessor_class_data_complex_packing.cc index 49d312611..81e402303 100644 --- a/src/grib_accessor_class_data_complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_complex_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,148 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_ieeefloat.h" -#include "grib_scaling.h" -#include -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS= const char* GRIBEX_sh_bug_present - MEMBERS= const char* ieee_floats - MEMBERS= const char* laplacianOperatorIsSet - MEMBERS= const char* laplacianOperator - MEMBERS= const char* sub_j - MEMBERS= const char* sub_k - MEMBERS= const char* sub_m - MEMBERS= const char* pen_j - MEMBERS= const char* pen_k - MEMBERS= const char* pen_m - END_CLASS_DEF - - */ - - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_complex_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_complex_packing */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -} grib_accessor_data_complex_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_complex_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_complex_packing", /* name */ - sizeof(grib_accessor_data_complex_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_complex_packing.h" +grib_accessor_class_data_complex_packing_t _grib_accessor_class_data_complex_packing{ "data_complex_packing" }; grib_accessor_class* grib_accessor_class_data_complex_packing = &_grib_accessor_class_data_complex_packing; -/* END_CLASS_IMP */ - -typedef unsigned long (*encode_float_proc)(double); -typedef double (*decode_float_proc)(unsigned long); - -static void init(grib_accessor* a, const long v, grib_arguments* args) +void grib_accessor_class_data_complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) { - grib_accessor_data_complex_packing* self = (grib_accessor_data_complex_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); self->GRIBEX_sh_bug_present = grib_arguments_get_name(gh, args, self->carg++); self->ieee_floats = grib_arguments_get_name(gh, args, self->carg++); @@ -165,15 +34,16 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_data_complex_packing_t::value_count(grib_accessor* a, long* count) { - grib_accessor_data_complex_packing* self = (grib_accessor_data_complex_packing*)a; - int ret = 0; + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; + + int ret = GRIB_SUCCESS; grib_handle* gh = grib_handle_of_accessor(a); - long pen_j = 0; - long pen_k = 0; - long pen_m = 0; - *count = 0; + long pen_j = 0; + long pen_k = 0; + long pen_m = 0; + *count = 0; if (a->length == 0) return 0; @@ -195,7 +65,7 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static double calculate_pfactor(const grib_context* ctx, const double* spectralField, long fieldTruncation, long subsetTruncation) +double calculate_pfactor(const grib_context* ctx, const double* spectralField, long fieldTruncation, long subsetTruncation) { /*long n_vals = ((fieldTruncation+1)*(fieldTruncation+2));*/ long loop, index, m, n = 0; @@ -229,7 +99,6 @@ static double calculate_pfactor(const grib_context* ctx, const double* spectralF /* * Form norms for the rows which contain part of the unscaled subset. */ - index = -2; for (m = 0; m < subsetTruncation; m++) { for (n = m; n <= fieldTruncation; n++) { @@ -244,7 +113,6 @@ static double calculate_pfactor(const grib_context* ctx, const double* spectralF /* * Form norms for the rows which do not contain part of the unscaled subset. */ - for (m = subsetTruncation; m <= fieldTruncation; m++) { for (n = m; n <= fieldTruncation; n++) { index += 2; @@ -280,7 +148,6 @@ static double calculate_pfactor(const grib_context* ctx, const double* spectralF /* * Perform a least square fit for the equation */ - for (loop = ismin; loop <= ismax; loop++) { x = log((double)(loop * (loop + 1))); y = log(norms[loop]); @@ -302,11 +169,11 @@ static double calculate_pfactor(const grib_context* ctx, const double* spectralF return pFactor; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_data_complex_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_data_complex_packing* self = (grib_accessor_data_complex_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; size_t i = 0; int ret = GRIB_SUCCESS; @@ -654,7 +521,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) grib_get_double_internal(gh, self->reference_value, &ref); if (ref != reference_value) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s %s: %s (ref=%.10e != reference_value=%.10e)", - cclass_name, __func__, self->reference_value, ref, reference_value); + cclass_name, __func__, self->reference_value, ref, reference_value); return GRIB_INTERNAL_ERROR; } } @@ -671,32 +538,31 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return ret; } - template -static int unpack(grib_accessor* a, T* val, size_t* len) +static int unpack_real(grib_accessor* a, T* val, size_t* len) { static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_complex_packing* self = (grib_accessor_data_complex_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; + grib_accessor_data_complex_packing_t* self = (grib_accessor_data_complex_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; - size_t i = 0; - int ret = GRIB_SUCCESS; - long hcount = 0; - long lcount = 0; - long hpos = 0; - long lup = 0; - long mmax = 0; - long n_vals = 0; - T* scals = NULL; - T* pscals = NULL, *pval = NULL; + size_t i = 0; + int ret = GRIB_SUCCESS; + long hcount = 0; + long lcount = 0; + long hpos = 0; + long lup = 0; + long mmax = 0; + long n_vals = 0; + T* scals = NULL; + T *pscals = NULL, *pval = NULL; T s = 0; T d = 0; T laplacianOperator = 0; - unsigned char* buf = NULL; - unsigned char* hres = NULL; - unsigned char* lres = NULL; + unsigned char* buf = NULL; + unsigned char* hres = NULL; + unsigned char* lres = NULL; unsigned long packed_offset; long lpos = 0; @@ -706,7 +572,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) long offsetdata = 0; long bits_per_value = 0; - T reference_value = 0; + T reference_value = 0; long binary_scale_factor = 0; long decimal_scale_factor = 0; @@ -724,7 +590,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) decode_float_proc decode_float = NULL; - err = grib_value_count(a, &n_vals); + err = a->value_count(&n_vals); if (err) return err; @@ -798,7 +664,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) maxv = pen_j + 1; - buf += grib_byte_offset(a); + buf += a->byte_offset(); hres = buf; lres = buf; @@ -814,9 +680,8 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return 0; } - packed_offset = grib_byte_offset(a) + bytes * (sub_k + 1) * (sub_k + 2); - - lpos = 8 * (packed_offset - offsetdata); + packed_offset = a->byte_offset() + bytes * (sub_k + 1) * (sub_k + 2); + lpos = 8 * (packed_offset - offsetdata); s = codes_power(binary_scale_factor, 2); d = codes_power(-decimal_scale_factor, 10); @@ -831,7 +696,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) scals[i] = (1.0 / operat); else { grib_context_log(a->context, GRIB_LOG_WARNING, - "%s: Problem with operator div by zero at index %d of %d", cclass_name, i, maxv); + "%s: Problem with operator div by zero at index %d of %d", cclass_name, i, maxv); scals[i] = 0; } } @@ -895,34 +760,31 @@ static int unpack(grib_accessor* a, T* val, size_t* len) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_data_complex_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) { - return unpack(a, val, len); + return unpack_real(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) +int grib_accessor_class_data_complex_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) { // TODO(maee): See ECC-1579 // Investigate why results are not bit-identical // return unpack(a, val, len); - int err = 0; - size_t i = 0; - size_t size = *len; - double* val8 = NULL; - val8 = (double*)grib_context_malloc(a->context, size*(sizeof(double))); + size_t size = *len; + double* val8 = (double*)grib_context_malloc(a->context, size * (sizeof(double))); if (!val8) return GRIB_OUT_OF_MEMORY; - err = unpack(a, val8, len); + int err = unpack_real(a, val8, len); if (err) { - grib_context_free(a->context,val8); + grib_context_free(a->context, val8); return err; } - for(i=0; icontext,val8); + grib_context_free(a->context, val8); return GRIB_SUCCESS; } diff --git a/src/accessor/grib_accessor_class_data_complex_packing.h b/src/accessor/grib_accessor_class_data_complex_packing.h new file mode 100644 index 000000000..ee19b195c --- /dev/null +++ b/src/accessor/grib_accessor_class_data_complex_packing.h @@ -0,0 +1,46 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" +#include "grib_ieeefloat.h" + +typedef unsigned long (*encode_float_proc)(double); +typedef double (*decode_float_proc)(unsigned long); + +class grib_accessor_data_complex_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_complex_packing */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_complex_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_complex_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_dummy_field.cc b/src/accessor/grib_accessor_class_data_dummy_field.cc new file mode 100644 index 000000000..eddadcc08 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_dummy_field.cc @@ -0,0 +1,102 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_dummy_field.h" + +grib_accessor_class_data_dummy_field_t _grib_accessor_class_data_dummy_field{"data_dummy_field"}; +grib_accessor_class* grib_accessor_class_data_dummy_field = &_grib_accessor_class_data_dummy_field; + + +void grib_accessor_class_data_dummy_field_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_g1simple_packing_t::init(a, v, args); + grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; + self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); +} + +int grib_accessor_class_data_dummy_field_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; + size_t i = 0, n_vals = 0; + long numberOfPoints; + double missing_value = 0; + int err = 0; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints)) != GRIB_SUCCESS) + return err; + n_vals = numberOfPoints; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < n_vals; i++) + val[i] = missing_value; + + if (grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) { + if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->bitmap, val, n_vals)) != GRIB_SUCCESS) + return err; + } + + *len = (long)n_vals; + return err; +} + +int grib_accessor_class_data_dummy_field_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; + + size_t n_vals = *len; + int err = 0; + long bits_per_value = 0; + long half_byte = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + + buflen = (1 + ((bits_per_value * n_vals) / 8)) * sizeof(unsigned char); + + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); + if (!buf) + return GRIB_OUT_OF_MEMORY; + + half_byte = (buflen * 8) - ((*len) * bits_per_value); + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, half_byte)) != GRIB_SUCCESS) { + grib_context_free(a->context, buf); + return err; + } + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_free(a->context, buf); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_data_dummy_field_t::value_count(grib_accessor* a, long* numberOfPoints){ + grib_accessor_data_dummy_field_t* self = (grib_accessor_data_dummy_field_t*)a; + int err = 0; + *numberOfPoints = 0; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints)) != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to get count of %s (%s)", a->name, grib_get_error_message(err)); + } + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_dummy_field.h b/src/accessor/grib_accessor_class_data_dummy_field.h new file mode 100644 index 000000000..c846abb98 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_dummy_field.h @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_g1simple_packing.h" + +class grib_accessor_data_dummy_field_t : public grib_accessor_data_g1simple_packing_t +{ +public: + /* Members defined in data_dummy_field */ + const char* missing_value; + const char* numberOfPoints; + const char* bitmap; +}; + +class grib_accessor_class_data_dummy_field_t : public grib_accessor_class_data_g1simple_packing_t +{ +public: + grib_accessor_class_data_dummy_field_t(const char* name) : grib_accessor_class_data_g1simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_dummy_field_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.cc b/src/accessor/grib_accessor_class_data_g1complex_packing.cc new file mode 100644 index 000000000..5ac11346e --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.cc @@ -0,0 +1,112 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_g1complex_packing.h" + +grib_accessor_class_data_g1complex_packing_t _grib_accessor_class_data_g1complex_packing{"data_g1complex_packing"}; +grib_accessor_class* grib_accessor_class_data_g1complex_packing = &_grib_accessor_class_data_g1complex_packing; + + +void grib_accessor_class_data_g1complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_complex_packing_t::init(a, v, args); + grib_accessor_data_g1complex_packing_t* self = (grib_accessor_data_g1complex_packing_t*)a; + self->half_byte = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->N = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->packingType = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->ieee_packing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->edition = 1; + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_g1complex_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g1complex_packing_t* self = (grib_accessor_data_g1complex_packing_t*)a; + int ret = GRIB_SUCCESS; + long seclen = 0; + long sub_j = 0; + long sub_k = 0; + long sub_m = 0; + long n = 0; + long half_byte = 0; + long bits_per_value = 0; + size_t buflen = 0; + + if (*len == 0) + return GRIB_NO_VALUES; + +// /* TODO: spectral_ieee does not work */ +// if (c->ieee_packing && self->ieee_packing) { +// grib_handle* h = grib_handle_of_accessor(a); +// grib_context* c = a->context; +// char* packingType_s = NULL; +// char* ieee_packing_s = NULL; +// long precision = c->ieee_packing == 32 ? 1 : 2; +// size_t lenstr = strlen(self->ieee_packing); + +// packingType_s = grib_context_strdup(c, self->packingType); +// ieee_packing_s = grib_context_strdup(c, self->ieee_packing); +// precision_s = grib_context_strdup(c, self->precision); + +// grib_set_string(h, packingType_s, ieee_packing_s, &lenstr); +// grib_set_long(h, precision_s, precision); + +// grib_context_free(c, packingType_s); +// grib_context_free(c, ieee_packing_s); +// grib_context_free(c, precision_s); +// return grib_set_double_array(h, "values", val, *len); +// } + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_j, &sub_j)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_k, &sub_k)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_m, &sub_m)) != GRIB_SUCCESS) + return ret; + + self->dirty = 1; + + Assert((sub_j == sub_k) && (sub_m == sub_j)); + + ret = grib_accessor_class_data_complex_packing_t::pack_double(a, val, len); + + if (ret == GRIB_SUCCESS) { + n = a->offset + 4 * ((sub_k + 1) * (sub_k + 2)); + + /* Octet number starts from beginning of message but shouldn't */ + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n)) != GRIB_SUCCESS) + return ret; + + // ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection); + // if (ret != GRIB_SUCCESS) + // return ret; + // if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n - offsetsection)) != GRIB_SUCCESS) + // return ret; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value); + if (ret != GRIB_SUCCESS) + return ret; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->seclen, &seclen); + if (ret != GRIB_SUCCESS) + return ret; + + buflen = 32 * (sub_k + 1) * (sub_k + 2) + (*len - (sub_k + 1) * (sub_k + 2)) * bits_per_value + 18 * 8; + half_byte = seclen * 8 - buflen; + if (a->context->debug == -1) { + fprintf(stderr, "ECCODES DEBUG: half_byte=%ld\n", half_byte); + } + + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, half_byte); + if (ret != GRIB_SUCCESS) + return ret; + } + return ret; +} diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.h b/src/accessor/grib_accessor_class_data_g1complex_packing.h new file mode 100644 index 000000000..51457e40e --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.h @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_complex_packing.h" + +class grib_accessor_data_g1complex_packing_t : public grib_accessor_data_complex_packing_t +{ +public: + /* Members defined in data_g1complex_packing */ + const char* N; + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; +}; + +class grib_accessor_class_data_g1complex_packing_t : public grib_accessor_class_data_complex_packing_t +{ +public: + grib_accessor_class_data_g1complex_packing_t(const char* name) : grib_accessor_class_data_complex_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_data_g1second_order_constant_width_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc similarity index 57% rename from src/grib_accessor_class_data_g1second_order_constant_width_packing.cc rename to src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc index 079e91829..579fbd8cb 100644 --- a/src/grib_accessor_class_data_g1second_order_constant_width_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,157 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_data_g1second_order_constant_width_packing.h" #include "grib_scaling.h" -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - MEMBERS=const char* widthOfFirstOrderValues - MEMBERS=const char* N1 - MEMBERS=const char* N2 - MEMBERS=const char* numberOfGroups - MEMBERS=const char* numberOfSecondOrderPackedValues - MEMBERS=const char* extraValues - MEMBERS=const char* pl - MEMBERS=const char* Ni - MEMBERS=const char* Nj - MEMBERS=const char* jPointsAreConsecutive - MEMBERS=const char* bitmap - MEMBERS=const char* groupWidth - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_g1second_order_constant_width_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1second_order_constant_width_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidth; -} grib_accessor_data_g1second_order_constant_width_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1second_order_constant_width_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1second_order_constant_width_packing", /* name */ - sizeof(grib_accessor_data_g1second_order_constant_width_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_data_g1second_order_constant_width_packing_t _grib_accessor_class_data_g1second_order_constant_width_packing{"data_g1second_order_constant_width_packing"}; grib_accessor_class* grib_accessor_class_data_g1second_order_constant_width_packing = &_grib_accessor_class_data_g1second_order_constant_width_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1second_order_constant_width_packing* self = (grib_accessor_data_g1second_order_constant_width_packing*)a; +void grib_accessor_class_data_g1second_order_constant_width_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_g1second_order_constant_width_packing_t* self = (grib_accessor_data_g1second_order_constant_width_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(hand, args, self->carg++); @@ -181,10 +41,9 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues){ int err = 0; - grib_accessor_data_g1second_order_constant_width_packing* self = (grib_accessor_data_g1second_order_constant_width_packing*)a; + grib_accessor_data_g1second_order_constant_width_packing_t* self = (grib_accessor_data_g1second_order_constant_width_packing_t*)a; *numberOfSecondOrderPackedValues = 0; err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, numberOfSecondOrderPackedValues); @@ -192,14 +51,12 @@ static int value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) return err; } -static int unpack_float(grib_accessor*, float* val, size_t* len) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::unpack_float(grib_accessor*, float* val, size_t* len){ return GRIB_NOT_IMPLEMENTED; } -static int unpack_double(grib_accessor* a, double* values, size_t* len) -{ - grib_accessor_data_g1second_order_constant_width_packing* self = (grib_accessor_data_g1second_order_constant_width_packing*)a; +int grib_accessor_class_data_g1second_order_constant_width_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len){ + grib_accessor_data_g1second_order_constant_width_packing_t* self = (grib_accessor_data_g1second_order_constant_width_packing_t*)a; int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; long groupWidth = 0; @@ -218,8 +75,7 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len) long* secondaryBitmap; grib_handle* hand = grib_handle_of_accessor(a); - buf += grib_byte_offset(a); - + buf += a->byte_offset(); if ((ret = grib_get_long_internal(hand, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) return ret; @@ -321,15 +177,13 @@ static int unpack_double(grib_accessor* a, double* values, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, "%s: %s: Not implemented", cclass_name, __func__); return GRIB_NOT_IMPLEMENTED; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0; double* values = NULL; @@ -354,8 +208,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_g1second_order_constant_width_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0, i = 0; double* values = NULL; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h new file mode 100644 index 000000000..8d2d53f0a --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.h @@ -0,0 +1,49 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1second_order_constant_width_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_constant_width_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidth; +}; + +class grib_accessor_class_data_g1second_order_constant_width_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_constant_width_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_constant_width_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc similarity index 84% rename from src/grib_accessor_class_data_g1second_order_general_extended_packing.cc rename to src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index d337dba48..f78bb1806 100644 --- a/src/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,181 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_data_g1second_order_general_extended_packing.h" #include "grib_scaling.h" -#include "grib_api_internal.h" -#include "grib_optimize_decimal_factor.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - IMPLEMENTS = destroy - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - MEMBERS=const char* widthOfFirstOrderValues - MEMBERS=const char* firstOrderValues - MEMBERS=const char* N1 - MEMBERS=const char* N2 - MEMBERS=const char* numberOfGroups - MEMBERS=const char* codedNumberOfGroups - MEMBERS=const char* numberOfSecondOrderPackedValues - MEMBERS=const char* extraValues - MEMBERS=const char* groupWidths - MEMBERS=const char* widthOfWidths - MEMBERS=const char* groupLengths - MEMBERS=const char* widthOfLengths - MEMBERS=const char* NL - MEMBERS=const char* SPD - MEMBERS=const char* widthOfSPD - MEMBERS=const char* orderOfSPD - MEMBERS=const char* numberOfPoints - MEMBERS=const char* dataFlag - MEMBERS=double* dvalues - MEMBERS=float* fvalues - MEMBERS=int double_dirty - MEMBERS=int float_dirty - MEMBERS=size_t size - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_g1second_order_general_extended_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1second_order_general_extended_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* firstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* codedNumberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* groupWidths; - const char* widthOfWidths; - const char* groupLengths; - const char* widthOfLengths; - const char* NL; - const char* SPD; - const char* widthOfSPD; - const char* orderOfSPD; - const char* numberOfPoints; - const char* dataFlag; - double* dvalues; - float* fvalues; - int double_dirty; - int float_dirty; - size_t size; -} grib_accessor_data_g1second_order_general_extended_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1second_order_general_extended_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1second_order_general_extended_packing", /* name */ - sizeof(grib_accessor_data_g1second_order_general_extended_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_data_g1second_order_general_extended_packing_t _grib_accessor_class_data_g1second_order_general_extended_packing{ "data_g1second_order_general_extended_packing" }; grib_accessor_class* grib_accessor_class_data_g1second_order_general_extended_packing = &_grib_accessor_class_data_g1second_order_general_extended_packing; -/* END_CLASS_IMP */ #define MAX_NUMBER_OF_GROUPS 65534 -#define EFDEBUG 0 +#define EFDEBUG 0 static const unsigned long nbits[64] = { 0x1, 0x2, 0x4, 0x8, @@ -203,7 +38,7 @@ static const unsigned long nbits[64] = { 0x1000000000000000, 0x2000000000000000, 0x4000000000000000, 0x8000000000000000 }; -static long number_of_bits(grib_handle* h, unsigned long x) +long number_of_bits(grib_handle* h, unsigned long x) { const unsigned long* n = nbits; const int count = sizeof(nbits) / sizeof(nbits[0]); @@ -220,10 +55,11 @@ static long number_of_bits(grib_handle* h, unsigned long x) return i; } -static void init(grib_accessor* a, const long v, grib_arguments* args) +void grib_accessor_class_data_g1second_order_general_extended_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) { - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; - grib_handle* handle = grib_handle_of_accessor(a); + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; + grib_handle* handle = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(handle, args, self->carg++); self->packingType = grib_arguments_get_name(handle, args, self->carg++); @@ -249,18 +85,18 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) self->dataFlag = grib_arguments_get_name(handle, args, self->carg++); self->edition = 1; self->dirty = 1; - self->dvalues = NULL; - self->fvalues = NULL; + self->dvalues = NULL; + self->fvalues = NULL; self->double_dirty = self->float_dirty = 1; - self->size = 0; + self->size = 0; a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_data_g1second_order_general_extended_packing_t::value_count(grib_accessor* a, long* count) { - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; - long numberOfCodedValues = 0; - long numberOfGroups = 0; + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; + long numberOfCodedValues = 0; + long numberOfGroups = 0; size_t ngroups; long* groupLengths; long orderOfSPD = 0; @@ -293,7 +129,7 @@ static int value_count(grib_accessor* a, long* count) return err; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) { size_t size; double* values; @@ -317,7 +153,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) { size_t size = 0, i = 0; double* values; @@ -345,10 +181,10 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len) +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len) { - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; - int ret = 0; + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; + int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; long* firstOrderValues = 0; long* X = 0; @@ -396,8 +232,9 @@ static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len self->float_dirty = 0; } - buf += grib_byte_offset(a); - ret = value_count(a, &numberOfValues); + buf += a->byte_offset(); + ret = a->value_count(&numberOfValues); + if (ret) return ret; @@ -461,14 +298,13 @@ static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len n++; } -// for (j=0;jdvalues) { if (numberOfValues != self->size) { grib_context_free(a->context, self->dvalues); @@ -565,12 +401,12 @@ static int unpack(grib_accessor* a, double* dvalues, float* fvalues, size_t* len return ret; } -static int unpack_float(grib_accessor* a, float* values, size_t* len) +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len) { return unpack(a, NULL, values, len); } -static int unpack_double(grib_accessor* a, double* values, size_t* len) +int grib_accessor_class_data_g1second_order_general_extended_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len) { return unpack(a, values, NULL, len); } @@ -698,7 +534,8 @@ static int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, lo /* Note: on a 32bit system, the most significant bit is for signedness, so we have to drop one bit */ if (sizeof(long) == 4) { *bits_per_value = 31; - } else { + } + else { *bits_per_value = 32; } } @@ -708,11 +545,11 @@ static int get_bits_per_value(grib_handle* h, const char* bits_per_value_str, lo // For the old implementation of pack_double, see // src/deprecated/grib_accessor_class_data_g1second_order_general_extended_packing.pack_double.cc // See ECC-441 and ECC-261 -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_data_g1second_order_general_extended_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; - int ret = 0; - int grib2 = 0; + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; + int ret = 0; + int grib2 = 0; long bits_per_value, orderOfSPD, binary_scale_factor; long numberOfValues; double max, min; @@ -1303,7 +1140,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) pos = 0; if (orderOfSPD) { - long SPD[4] = {0,}; + long SPD[4] = { + 0, + }; size_t nSPD = orderOfSPD + 1; Assert(orderOfSPD <= 3); for (i = 0; i < orderOfSPD; i++) @@ -1365,9 +1204,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static void destroy(grib_context* context, grib_accessor* a) +void grib_accessor_class_data_g1second_order_general_extended_packing_t::destroy(grib_context* context, grib_accessor* a) { - grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a; + grib_accessor_data_g1second_order_general_extended_packing_t* self = (grib_accessor_data_g1second_order_general_extended_packing_t*)a; if (self->dvalues != NULL) { grib_context_free(context, self->dvalues); self->dvalues = NULL; @@ -1376,4 +1215,5 @@ static void destroy(grib_context* context, grib_accessor* a) grib_context_free(context, self->fvalues); self->fvalues = NULL; } + grib_accessor_class_data_simple_packing_t::destroy(context, a); } diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h new file mode 100644 index 000000000..4bb50ae34 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.h @@ -0,0 +1,64 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1second_order_general_extended_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_general_extended_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* firstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* codedNumberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* groupWidths; + const char* widthOfWidths; + const char* groupLengths; + const char* widthOfLengths; + const char* NL; + const char* SPD; + const char* widthOfSPD; + const char* orderOfSPD; + const char* numberOfPoints; + const char* dataFlag; + double* dvalues; + float* fvalues; + int double_dirty; + int float_dirty; + size_t size; +}; + +class grib_accessor_class_data_g1second_order_general_extended_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_general_extended_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_general_extended_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + +private: + int unpack(grib_accessor* a, double*, float*, size_t*); +}; diff --git a/src/grib_accessor_class_data_g1second_order_general_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc similarity index 50% rename from src/grib_accessor_class_data_g1second_order_general_packing.cc rename to src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc index 3e41fd3e0..8fb0165d0 100644 --- a/src/grib_accessor_class_data_g1second_order_general_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,157 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" -#include "grib_api_internal.h" -#include - - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = value_count - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - MEMBERS=const char* widthOfFirstOrderValues - MEMBERS=const char* N1 - MEMBERS=const char* N2 - MEMBERS=const char* numberOfGroups - MEMBERS=const char* numberOfSecondOrderPackedValues - MEMBERS=const char* extraValues - MEMBERS=const char* pl - MEMBERS=const char* Ni - MEMBERS=const char* Nj - MEMBERS=const char* jPointsAreConsecutive - MEMBERS=const char* bitmap - MEMBERS=const char* groupWidths - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1second_order_general_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1second_order_general_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidths; -} grib_accessor_data_g1second_order_general_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1second_order_general_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1second_order_general_packing", /* name */ - sizeof(grib_accessor_data_g1second_order_general_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_g1second_order_general_packing.h" +grib_accessor_class_data_g1second_order_general_packing_t _grib_accessor_class_data_g1second_order_general_packing{ "data_g1second_order_general_packing" }; grib_accessor_class* grib_accessor_class_data_g1second_order_general_packing = &_grib_accessor_class_data_g1second_order_general_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) +void grib_accessor_class_data_g1second_order_general_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) { - grib_accessor_data_g1second_order_general_packing* self = (grib_accessor_data_g1second_order_general_packing*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(hand, args, self->carg++); self->packingType = grib_arguments_get_name(hand, args, self->carg++); @@ -180,23 +41,22 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) +int grib_accessor_class_data_g1second_order_general_packing_t::value_count(grib_accessor* a, long* numberOfSecondOrderPackedValues) { - int err = 0; - grib_accessor_data_g1second_order_general_packing* self = (grib_accessor_data_g1second_order_general_packing*)a; - *numberOfSecondOrderPackedValues = 0; + grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; + *numberOfSecondOrderPackedValues = 0; - err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, numberOfSecondOrderPackedValues); + int err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfSecondOrderPackedValues, numberOfSecondOrderPackedValues); return err; } template -static int unpack(grib_accessor* a, T* values, size_t* len) +static int unpack_real(grib_accessor* a, T* values, size_t* len) { static_assert(std::is_floating_point::value, "Requires floating point numbers"); - grib_accessor_data_g1second_order_general_packing* self = (grib_accessor_data_g1second_order_general_packing*)a; - int ret = 0; + grib_accessor_data_g1second_order_general_packing_t* self = (grib_accessor_data_g1second_order_general_packing_t*)a; + int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; long* groupWidths = 0; long* firstOrderValues = 0; @@ -213,8 +73,7 @@ static int unpack(grib_accessor* a, T* values, size_t* len) long groupLength, j; size_t groupWidthsSize; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) return ret; @@ -296,25 +155,24 @@ static int unpack(grib_accessor* a, T* values, size_t* len) return ret; } -static int unpack_float(grib_accessor* a, float* values, size_t* len) +int grib_accessor_class_data_g1second_order_general_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len) { - return unpack(a, values, len); + return unpack_real(a, values, len); } -static int unpack_double(grib_accessor* a, double* values, size_t* len) +int grib_accessor_class_data_g1second_order_general_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len) { - return unpack(a, values, len); + return unpack_real(a, values, len); } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) +int grib_accessor_class_data_g1second_order_general_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len) { /* return GRIB_NOT_IMPLEMENTED; */ - int err = 0; char type[] = "grid_second_order"; size_t size = strlen(type); grib_handle* hand = grib_handle_of_accessor(a); - err = grib_set_string(hand, "packingType", type, &size); + int err = grib_set_string(hand, "packingType", type, &size); if (err) return err; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h new file mode 100644 index 000000000..95295dae1 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.h @@ -0,0 +1,48 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" + +class grib_accessor_data_g1second_order_general_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_general_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidths; +}; + +class grib_accessor_class_data_g1second_order_general_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_general_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_general_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_data_g1second_order_row_by_row_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc similarity index 61% rename from src/grib_accessor_class_data_g1second_order_row_by_row_packing.cc rename to src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc index b801b3b1c..afed13ca2 100644 --- a/src/grib_accessor_class_data_g1second_order_row_by_row_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,155 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = value_count - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - MEMBERS=const char* widthOfFirstOrderValues - MEMBERS=const char* N1 - MEMBERS=const char* N2 - MEMBERS=const char* numberOfGroups - MEMBERS=const char* numberOfSecondOrderPackedValues - MEMBERS=const char* extraValues - MEMBERS=const char* pl - MEMBERS=const char* Ni - MEMBERS=const char* Nj - MEMBERS=const char* jPointsAreConsecutive - MEMBERS=const char* bitmap - MEMBERS=const char* groupWidths - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1second_order_row_by_row_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1second_order_row_by_row_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - const char* widthOfFirstOrderValues; - const char* N1; - const char* N2; - const char* numberOfGroups; - const char* numberOfSecondOrderPackedValues; - const char* extraValues; - const char* pl; - const char* Ni; - const char* Nj; - const char* jPointsAreConsecutive; - const char* bitmap; - const char* groupWidths; -} grib_accessor_data_g1second_order_row_by_row_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1second_order_row_by_row_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1second_order_row_by_row_packing", /* name */ - sizeof(grib_accessor_data_g1second_order_row_by_row_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_g1second_order_row_by_row_packing.h" +grib_accessor_class_data_g1second_order_row_by_row_packing_t _grib_accessor_class_data_g1second_order_row_by_row_packing{ "data_g1second_order_row_by_row_packing" }; grib_accessor_class* grib_accessor_class_data_g1second_order_row_by_row_packing = &_grib_accessor_class_data_g1second_order_row_by_row_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) +void grib_accessor_class_data_g1second_order_row_by_row_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) { - grib_accessor_data_g1second_order_row_by_row_packing* self = (grib_accessor_data_g1second_order_row_by_row_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); self->half_byte = grib_arguments_get_name(gh, args, self->carg++); self->packingType = grib_arguments_get_name(gh, args, self->carg++); @@ -178,12 +41,13 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::value_count(grib_accessor* a, long* count) { - grib_accessor_data_g1second_order_row_by_row_packing* self = (grib_accessor_data_g1second_order_row_by_row_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); + grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; + + grib_handle* gh = grib_handle_of_accessor(a); long n = 0, i = 0; - long numberOfRows = 0; + long numberOfRows = 0; long jPointsAreConsecutive = 0; long Ni = 0, Nj = 0; int bitmapPresent = 0; @@ -254,11 +118,12 @@ static int value_count(grib_accessor* a, long* count) } template -static int unpack(grib_accessor* a, T* values, size_t* len) +static int unpack_real(grib_accessor* a, T* values, size_t* len) { - grib_accessor_data_g1second_order_row_by_row_packing* self = (grib_accessor_data_g1second_order_row_by_row_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); - int ret = 0; + grib_accessor_data_g1second_order_row_by_row_packing_t* self = (grib_accessor_data_g1second_order_row_by_row_packing_t*)a; + + grib_handle* gh = grib_handle_of_accessor(a); + int ret = 0; long numberOfGroups, numberOfSecondOrderPackedValues; long* groupWidths = 0; long* firstOrderValues = 0; @@ -279,8 +144,7 @@ static int unpack(grib_accessor* a, T* values, size_t* len) size_t plSize = 0; long* pl = 0; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); if ((ret = grib_get_long_internal(gh, self->numberOfGroups, &numberOfGroups)) != GRIB_SUCCESS) return ret; @@ -421,17 +285,17 @@ static int unpack(grib_accessor* a, T* values, size_t* len) return ret; } -static int unpack_float(grib_accessor* a, float* values, size_t* len) +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_float(grib_accessor* a, float* values, size_t* len) { - return unpack(a, values, len); + return unpack_real(a, values, len); } -static int unpack_double(grib_accessor* a, double* values, size_t* len) +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::unpack_double(grib_accessor* a, double* values, size_t* len) { - return unpack(a, values, len); + return unpack_real(a, values, len); } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) +int grib_accessor_class_data_g1second_order_row_by_row_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len) { int err = 0; grib_handle* gh = grib_handle_of_accessor(a); diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h new file mode 100644 index 000000000..eca551669 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.h @@ -0,0 +1,48 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" +#include "grib_scaling.h" + +class grib_accessor_data_g1second_order_row_by_row_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1second_order_row_by_row_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; + const char* widthOfFirstOrderValues; + const char* N1; + const char* N2; + const char* numberOfGroups; + const char* numberOfSecondOrderPackedValues; + const char* extraValues; + const char* pl; + const char* Ni; + const char* Nj; + const char* jPointsAreConsecutive; + const char* bitmap; + const char* groupWidths; +}; + +class grib_accessor_class_data_g1second_order_row_by_row_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1second_order_row_by_row_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1second_order_row_by_row_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc new file mode 100644 index 000000000..3697f6f75 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc @@ -0,0 +1,128 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_g1secondary_bitmap.h" + +grib_accessor_class_data_g1secondary_bitmap_t _grib_accessor_class_data_g1secondary_bitmap{"data_g1secondary_bitmap"}; +grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap = &_grib_accessor_class_data_g1secondary_bitmap; + + +void grib_accessor_class_data_g1secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_secondary_bitmap_t::init(a, v, args); + grib_accessor_data_g1secondary_bitmap_t* self = (grib_accessor_data_g1secondary_bitmap_t*)a; + self->number_of_ones = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); +} + +int grib_accessor_class_data_g1secondary_bitmap_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_g1secondary_bitmap_t* self = (grib_accessor_data_g1secondary_bitmap_t*)a; + size_t len = 0; + int err = 0; + long expand_by; + *count = 0; + + err = grib_get_long_internal(grib_handle_of_accessor(a), self->expand_by, &expand_by); + if (err) + return err; + + err = grib_get_size(grib_handle_of_accessor(a), self->primary_bitmap, &len); + if (err) + return err; + + *count = expand_by * len; + return GRIB_SUCCESS; +} + +int grib_accessor_class_data_g1secondary_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g1secondary_bitmap_t* self = (grib_accessor_data_g1secondary_bitmap_t*)a; + + int err = 0; + + long primary_len = 0; + long secondary_len = 0; + double* primary_bitmap = NULL; + double* secondary_bitmap = NULL; + long i = 0; + long j = 0; + long on = 0; + long k; + long m; + double missing_value = 0; + double present_value = 0; + long expand_by = 0; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) + return err; + if (expand_by <= 0) + return GRIB_ENCODING_ERROR; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len % expand_by) { + /*TODO: issue warning */ + return GRIB_ENCODING_ERROR; + } + + primary_len = *len / expand_by; + primary_bitmap = (double*)grib_context_malloc_clear(a->context, primary_len * sizeof(double)); + if (!primary_bitmap) + return GRIB_OUT_OF_MEMORY; + + secondary_len = *len; + secondary_bitmap = (double*)grib_context_malloc_clear(a->context, secondary_len * sizeof(double)); + if (!secondary_bitmap) { + grib_context_free(a->context, primary_bitmap); + return GRIB_OUT_OF_MEMORY; + } + + if (missing_value == 0) + present_value = 1; + else + present_value = 0; + + k = 0; + m = 0; + for (i = 0; i < *len; i += expand_by) { + int cnt = 0; + for (j = 0; j < expand_by; j++) + if (val[i + j] == missing_value) + cnt++; + + if (cnt == expand_by) /* all expand_by values are missing */ + primary_bitmap[k++] = missing_value; + else { + primary_bitmap[k++] = present_value; + for (j = 0; j < expand_by; j++) + secondary_bitmap[m++] = val[i + j]; + on++; + } + } + + *len = k; + + /*printf("QQQQQQQ %ld %ld second=%ld\n",primary_len,on,m);*/ + Assert(k == primary_len); + + err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_bitmap, k); + if (err == GRIB_SUCCESS) + err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_bitmap, m); + + grib_context_free(a->context, primary_bitmap); + grib_context_free(a->context, secondary_bitmap); + + if (err == GRIB_SUCCESS) + err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_ones, on); + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h new file mode 100644 index 000000000..63ee792ae --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_secondary_bitmap.h" + +class grib_accessor_data_g1secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t +{ +public: + /* Members defined in data_g1secondary_bitmap */ + const char* number_of_ones; +}; + +class grib_accessor_class_data_g1secondary_bitmap_t : public grib_accessor_class_data_secondary_bitmap_t +{ +public: + grib_accessor_class_data_g1secondary_bitmap_t(const char* name) : grib_accessor_class_data_secondary_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1secondary_bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc b/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc new file mode 100644 index 000000000..f1f06d654 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.cc @@ -0,0 +1,63 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_g1shsimple_packing.h" + +grib_accessor_class_data_g1shsimple_packing_t _grib_accessor_class_data_g1shsimple_packing{"data_g1shsimple_packing"}; +grib_accessor_class* grib_accessor_class_data_g1shsimple_packing = &_grib_accessor_class_data_g1shsimple_packing; + + + +int grib_accessor_class_data_g1shsimple_packing_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_g1shsimple_packing_t* self = (grib_accessor_data_g1shsimple_packing_t*)a; + size_t len = 0; + int err = 0; + + err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &len); + len += 1; + + *count = len; + return err; +} + +int grib_accessor_class_data_g1shsimple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_g1shsimple_packing_t* self = (grib_accessor_data_g1shsimple_packing_t*)a; + int err = GRIB_SUCCESS; + + size_t coded_n_vals = 0; + size_t n_vals = 0; + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) + return err; + + n_vals = coded_n_vals + 1; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->real_part, val)) != GRIB_SUCCESS) + return err; + + val++; + + if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, &coded_n_vals)) != GRIB_SUCCESS) + return err; + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "grib_accessor_data_g1shsimple_packing_t_bitmap : unpack_double : creating %s, %d values", + a->name, n_vals); + + *len = n_vals; + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_g1shsimple_packing.h b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h new file mode 100644 index 000000000..c852c7213 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1shsimple_packing.h @@ -0,0 +1,28 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_shsimple_packing.h" + +class grib_accessor_data_g1shsimple_packing_t : public grib_accessor_data_shsimple_packing_t +{ +public: + /* Members defined in data_g1shsimple_packing */ +}; + +class grib_accessor_class_data_g1shsimple_packing_t : public grib_accessor_class_data_shsimple_packing_t +{ +public: + grib_accessor_class_data_g1shsimple_packing_t(const char* name) : grib_accessor_class_data_shsimple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1shsimple_packing_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; +}; diff --git a/src/grib_accessor_class_data_g1simple_packing.cc b/src/accessor/grib_accessor_class_data_g1simple_packing.cc similarity index 62% rename from src/grib_accessor_class_data_g1simple_packing.cc rename to src/accessor/grib_accessor_class_data_g1simple_packing.cc index e9f4aefdc..a19132f1a 100644 --- a/src/grib_accessor_class_data_g1simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,126 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_data_g1simple_packing.h" #include "grib_scaling.h" -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1simple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1simple_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; -} grib_accessor_data_g1simple_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1simple_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g1simple_packing", /* name */ - sizeof(grib_accessor_data_g1simple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_data_g1simple_packing_t _grib_accessor_class_data_g1simple_packing{"data_g1simple_packing"}; grib_accessor_class* grib_accessor_class_data_g1simple_packing = &_grib_accessor_class_data_g1simple_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1simple_packing* self = (grib_accessor_data_g1simple_packing*)a; +void grib_accessor_class_data_g1simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_g1simple_packing_t* self = (grib_accessor_data_g1simple_packing_t*)a; self->half_byte = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); self->packingType = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); @@ -137,9 +28,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* number_of_values) -{ - grib_accessor_data_g1simple_packing* self = (grib_accessor_data_g1simple_packing*)a; +int grib_accessor_class_data_g1simple_packing_t::value_count(grib_accessor* a, long* number_of_values){ + grib_accessor_data_g1simple_packing_t* self = (grib_accessor_data_g1simple_packing_t*)a; *number_of_values = 0; /* Special case for when values are cleared */ @@ -149,10 +39,8 @@ static int value_count(grib_accessor* a, long* number_of_values) return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, number_of_values); } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ - grib_accessor_data_g1simple_packing* self = (grib_accessor_data_g1simple_packing*)a; - grib_accessor_class* super = *(a->cclass->super); +int grib_accessor_class_data_g1simple_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ + grib_accessor_data_g1simple_packing_t* self = (grib_accessor_data_g1simple_packing_t*)a; size_t n_vals = *len; long half_byte = 0; @@ -194,16 +82,22 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) } if (units_factor != 1.0) { - if (units_bias != 0.0) - for (i = 0; i < n_vals; i++) + if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { val[i] = val[i] * units_factor + units_bias; - else - for (i = 0; i < n_vals; i++) + } + } + else { + for (i = 0; i < n_vals; i++) { val[i] *= units_factor; + } + } } - else if (units_bias != 0.0) - for (i = 0; i < n_vals; i++) + else if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { val[i] += units_bias; + } + } if (c->ieee_packing && self->ieee_packing) { long precision = 0; /* Either 1(=32 bits) or 2(=64 bits) */ @@ -228,7 +122,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) } } - ret = super->pack_double(a, val, len); + ret = grib_accessor_class_data_simple_packing_t::pack_double(a, val, len); switch (ret) { case GRIB_CONSTANT_FIELD: ret = grib_get_long(grib_handle_of_accessor(a), "constantFieldHalfByte", &constantFieldHalfByte); @@ -239,7 +133,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) ret = grib_buffer_replace(a, NULL, 0, 1, 1); if (ret != GRIB_SUCCESS) return ret; return GRIB_SUCCESS; - break; + case GRIB_NO_VALUES: ret = grib_get_long(grib_handle_of_accessor(a), "constantFieldHalfByte", &constantFieldHalfByte); if (ret) @@ -256,7 +150,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) ret = grib_buffer_replace(a, NULL, 0, 1, 1); if (ret != GRIB_SUCCESS) return ret; return GRIB_SUCCESS; - break; + case GRIB_INVALID_BPV: grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to compute packing parameters. Invalid bits per value"); return ret; @@ -313,7 +207,7 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) grib_encode_double_array(n_vals, val, bits_per_value, reference_value, decimal, divisor, encoded, &off); grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_data_g1simple_packing : pack_double : packing %s, %d values", a->name, n_vals); + "grib_accessor_data_g1simple_packing_t : pack_double : packing %s, %d values", a->name, n_vals); ret = grib_buffer_replace(a, buf, buflen, 1, 1); if (ret != GRIB_SUCCESS) return ret; diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.h b/src/accessor/grib_accessor_class_data_g1simple_packing.h new file mode 100644 index 000000000..c82532361 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.h @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g1simple_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g1simple_packing */ + const char* half_byte; + const char* packingType; + const char* ieee_packing; + const char* precision; +}; + +class grib_accessor_class_data_g1simple_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g1simple_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g1simple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_data_g22order_packing.cc b/src/accessor/grib_accessor_class_data_g22order_packing.cc similarity index 85% rename from src/grib_accessor_class_data_g22order_packing.cc rename to src/accessor/grib_accessor_class_data_g22order_packing.cc index f45d9f722..bbc698100 100644 --- a/src/grib_accessor_class_data_g22order_packing.cc +++ b/src/accessor/grib_accessor_class_data_g22order_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,164 +9,23 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_data_g22order_packing.h" -#include "grib_scaling.h" -#include "grib_api_internal.h" -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - MEMBERS=const char* numberOfValues - MEMBERS=const char* bits_per_value - MEMBERS=const char* reference_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* decimal_scale_factor - MEMBERS=const char* optimize_scale_factor - MEMBERS=const char* typeOfOriginalFieldValues - MEMBERS=const char* groupSplittingMethodUsed - MEMBERS=const char* missingValueManagementUsed - MEMBERS=const char* primaryMissingValueSubstitute - MEMBERS=const char* secondaryMissingValueSubstitute - MEMBERS=const char* numberOfGroupsOfDataValues - MEMBERS=const char* referenceForGroupWidths - MEMBERS=const char* numberOfBitsUsedForTheGroupWidths - MEMBERS=const char* referenceForGroupLengths - MEMBERS=const char* lengthIncrementForTheGroupLengths - MEMBERS=const char* trueLengthOfLastGroup - MEMBERS=const char* numberOfBitsUsedForTheScaledGroupLengths - MEMBERS=const char* orderOfSpatialDifferencing - MEMBERS=const char* numberOfOctetsExtraDescriptors - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_g22order_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_g22order_packing */ - const char* numberOfValues; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scale_factor; - const char* typeOfOriginalFieldValues; - const char* groupSplittingMethodUsed; - const char* missingValueManagementUsed; - const char* primaryMissingValueSubstitute; - const char* secondaryMissingValueSubstitute; - const char* numberOfGroupsOfDataValues; - const char* referenceForGroupWidths; - const char* numberOfBitsUsedForTheGroupWidths; - const char* referenceForGroupLengths; - const char* lengthIncrementForTheGroupLengths; - const char* trueLengthOfLastGroup; - const char* numberOfBitsUsedForTheScaledGroupLengths; - const char* orderOfSpatialDifferencing; - const char* numberOfOctetsExtraDescriptors; -} grib_accessor_data_g22order_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_g22order_packing = { - &grib_accessor_class_values, /* super */ - "data_g22order_packing", /* name */ - sizeof(grib_accessor_data_g22order_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_g22order_packing_t _grib_accessor_class_data_g22order_packing{ "data_g22order_packing" }; grib_accessor_class* grib_accessor_class_data_g22order_packing = &_grib_accessor_class_data_g22order_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) +void grib_accessor_class_data_g22order_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) { - grib_accessor_data_g22order_packing* self = reinterpret_cast(a); - grib_handle* gh = grib_handle_of_accessor(a); + grib_accessor_class_values_t::init(a, v, args); + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); + grib_handle* gh = grib_handle_of_accessor(a); - self->numberOfValues = grib_arguments_get_name(gh, args, self->carg++); - self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); - self->reference_value = grib_arguments_get_name(gh, args, self->carg++); - self->binary_scale_factor = grib_arguments_get_name(gh, args, self->carg++); - self->decimal_scale_factor = grib_arguments_get_name(gh, args, self->carg++); + self->numberOfValues = grib_arguments_get_name(gh, args, self->carg++); + self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); + self->reference_value = grib_arguments_get_name(gh, args, self->carg++); + self->binary_scale_factor = grib_arguments_get_name(gh, args, self->carg++); + self->decimal_scale_factor = grib_arguments_get_name(gh, args, self->carg++); self->optimize_scale_factor = grib_arguments_get_name(gh, args, self->carg++); self->typeOfOriginalFieldValues = grib_arguments_get_name(gh, args, self->carg++); @@ -186,33 +46,33 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } - #define ONES (~(int)0) // #define UNDEFINED 9.999e20 // #define UNDEFINED_LOW 9.9989e20 // #define UNDEFINED_HIGH 9.9991e20 -#define UNDEFINED 9999.0 -#define UNDEFINED_LOW 9998.9 -#define UNDEFINED_HIGH 9999.1 +#define UNDEFINED 9999.0 +#define UNDEFINED_LOW 9998.9 +#define UNDEFINED_HIGH 9999.1 #define UNDEFINED_VAL(x) ((x) >= UNDEFINED_LOW && (x) <= UNDEFINED_HIGH) -#define DEFINED_VAL(x) ((x) < UNDEFINED_LOW || (x) > UNDEFINED_HIGH) -#define UNDEFINED_ANGLE 999.0 +#define DEFINED_VAL(x) ((x) < UNDEFINED_LOW || (x) > UNDEFINED_HIGH) +#define UNDEFINED_ANGLE 999.0 -struct bitstream_context { +struct bitstream_context +{ unsigned char* bitstream; int rbits; int reg; int n_bitstream; }; -static void init_bitstream(bitstream_context *ctx, unsigned char* new_bitstream) +void init_bitstream(bitstream_context* ctx, unsigned char* new_bitstream) { ctx->bitstream = new_bitstream; ctx->n_bitstream = ctx->reg = ctx->rbits = 0; } -static void finish_bitstream(bitstream_context *ctx) +void finish_bitstream(bitstream_context* ctx) { if (ctx->rbits) { ctx->n_bitstream++; @@ -221,7 +81,7 @@ static void finish_bitstream(bitstream_context *ctx) } } -static void add_many_bitstream(bitstream_context *ctx, grib_accessor* a, int* t, int n, int n_bits) +void add_many_bitstream(bitstream_context* ctx, grib_accessor* a, int* t, int n, int n_bits) { unsigned int jmask; int i; @@ -245,7 +105,7 @@ static void add_many_bitstream(bitstream_context *ctx, grib_accessor* a, int* t, } } -static void add_bitstream(bitstream_context *ctx, grib_accessor* a, int t, int n_bits) +void add_bitstream(bitstream_context* ctx, grib_accessor* a, int t, int n_bits) { unsigned int jmask; const int max_numbits = 25; @@ -506,255 +366,6 @@ static int post_process(grib_context* c, long* vals, long len, long order, long return GRIB_SUCCESS; } -template -static int unpack(grib_accessor* a, T* val, const size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating points numbers"); - grib_accessor_data_g22order_packing* self = reinterpret_cast(a); - const char* cclass_name = a->cclass->name; - grib_handle* gh = grib_handle_of_accessor(a); - - size_t i = 0; - size_t j = 0; - long n_vals = 0; - long vcount = 0; - int err = GRIB_SUCCESS; - long* sec_val = NULL; - unsigned char* buf = reinterpret_cast(gh->buffer->data); - unsigned char* buf_ref = NULL; - unsigned char* buf_width = NULL; - unsigned char* buf_length = NULL; - unsigned char* buf_vals = NULL; - - long length_p = 0; - long ref_p = 0; - long width_p = 0; - long vals_p = 0; - long nvals_per_group = 0; - long nbits_per_group_val = 0; - long group_ref_val = 0; - - long bits_per_value = 0; - T binary_s = 0; - T decimal_s = 0; - double reference_value = 0; - - long binary_scale_factor; - long decimal_scale_factor; - long typeOfOriginalFieldValues; - long groupSplittingMethodUsed; - long missingValueManagementUsed; - long primaryMissingValueSubstitute; - long secondaryMissingValueSubstitute; - long numberOfGroupsOfDataValues; - long referenceForGroupWidths; - long numberOfBitsUsedForTheGroupWidths; - long referenceForGroupLengths; - long lengthIncrementForTheGroupLengths; - long trueLengthOfLastGroup; - long numberOfBitsUsedForTheScaledGroupLengths; - long orderOfSpatialDifferencing = 0; - long numberOfOctetsExtraDescriptors = 0; - double missingValue = 0; - - err = grib_value_count(a, &n_vals); - if (err) - return err; - - if (*len < static_cast(n_vals)) - return GRIB_ARRAY_TOO_SMALL; - - if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->typeOfOriginalFieldValues, &typeOfOriginalFieldValues)) != GRIB_SUCCESS) - return err; - - // Don't call grib_get_long_internal to suppress error message being output - if ((err = grib_get_long(gh, self->groupSplittingMethodUsed, &groupSplittingMethodUsed)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->missingValueManagementUsed, &missingValueManagementUsed)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->primaryMissingValueSubstitute, &primaryMissingValueSubstitute)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->secondaryMissingValueSubstitute, &secondaryMissingValueSubstitute)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfGroupsOfDataValues, &numberOfGroupsOfDataValues)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->referenceForGroupWidths, &referenceForGroupWidths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheGroupWidths, &numberOfBitsUsedForTheGroupWidths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->referenceForGroupLengths, &referenceForGroupLengths)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long_internal(gh, self->lengthIncrementForTheGroupLengths, &lengthIncrementForTheGroupLengths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->trueLengthOfLastGroup, &trueLengthOfLastGroup)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheScaledGroupLengths, &numberOfBitsUsedForTheScaledGroupLengths)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->orderOfSpatialDifferencing, &orderOfSpatialDifferencing)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(gh, self->numberOfOctetsExtraDescriptors, &numberOfOctetsExtraDescriptors)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_double_internal(gh, "missingValue", &missingValue)) != GRIB_SUCCESS) - return err; - - self->dirty = 0; - - sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long)); - if (!sec_val) return GRIB_OUT_OF_MEMORY; - memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718 - - buf_ref = buf + a->offset; - - ref_p = (numberOfGroupsOfDataValues * bits_per_value); - - if (orderOfSpatialDifferencing) - ref_p += (1 + orderOfSpatialDifferencing) * (numberOfOctetsExtraDescriptors * 8); - - buf_width = buf_ref + (ref_p / 8) + ((ref_p % 8) ? 1 : 0); - - width_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheGroupWidths); - buf_length = buf_width + (width_p / 8) + ((width_p % 8) ? 1 : 0); - - length_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheScaledGroupLengths); - buf_vals = buf_length + (length_p / 8) + ((length_p % 8) ? 1 : 0); - - length_p = 0; - ref_p = orderOfSpatialDifferencing ? (orderOfSpatialDifferencing + 1) * (numberOfOctetsExtraDescriptors * 8) : 0; - width_p = 0; - vals_p = 0; - vcount = 0; - - for (i = 0; i < numberOfGroupsOfDataValues; i++) { - group_ref_val = grib_decode_unsigned_long(buf_ref, &ref_p, bits_per_value); - nvals_per_group = grib_decode_unsigned_long(buf_length, &length_p, numberOfBitsUsedForTheScaledGroupLengths); - nbits_per_group_val = grib_decode_unsigned_long(buf_width, &width_p, numberOfBitsUsedForTheGroupWidths); - - nvals_per_group *= lengthIncrementForTheGroupLengths; - nvals_per_group += referenceForGroupLengths; - nbits_per_group_val += referenceForGroupWidths; - - if (i == numberOfGroupsOfDataValues - 1) - nvals_per_group = trueLengthOfLastGroup; - if (n_vals < vcount + nvals_per_group) { - return GRIB_DECODING_ERROR; - } - - // grib_decode_long_array(buf_vals, &vals_p, nbits_per_group_val, nvals_per_group, &sec_val[vcount]); - if (missingValueManagementUsed == 0) { - // No explicit missing values included within data values - for (j = 0; j < nvals_per_group; j++) { - DEBUG_ASSERT_ACCESS(sec_val, (long)(vcount + j), n_vals); - sec_val[vcount + j] = group_ref_val + grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - // printf("sec_val[%ld]=%ld\n", vcount+j, sec_val[vcount+j]); - } - } - else if (missingValueManagementUsed == 1) { - // Primary missing values included within data values - long maxn = 0; // (1 << bits_per_value) - 1; - for (j = 0; j < nvals_per_group; j++) { - if (nbits_per_group_val == 0) { - maxn = (1 << bits_per_value) - 1; - if (group_ref_val == maxn) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - sec_val[vcount + j] = group_ref_val + temp; - } - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - maxn = (1 << nbits_per_group_val) - 1; - if (temp == maxn) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - sec_val[vcount + j] = group_ref_val + temp; - } - } - } - } - else if (missingValueManagementUsed == 2) { - // Primary and secondary missing values included within data values - long maxn = (1 << bits_per_value) - 1; - long maxn2 = 0; // maxn - 1 - for (j = 0; j < nvals_per_group; j++) { - if (nbits_per_group_val == 0) { - maxn2 = maxn - 1; - if (group_ref_val == maxn || group_ref_val == maxn2) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - sec_val[vcount + j] = group_ref_val + temp; - } - } - else { - long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); - maxn = (1 << nbits_per_group_val) - 1; - maxn2 = maxn - 1; - if (temp == maxn || temp == maxn2) { - sec_val[vcount + j] = LONG_MAX; // missing value - } - else { - sec_val[vcount + j] = group_ref_val + temp; - } - } - } - } - - vcount += nvals_per_group; - } - - if (orderOfSpatialDifferencing) { - long bias = 0; - unsigned long extras[2] = {0, }; - ref_p = 0; - - // For Complex packing, order == 0 - // For Complex packing and spatial differencing, order == 1 or 2 (code table 5.6) - if (orderOfSpatialDifferencing != 1 && orderOfSpatialDifferencing != 2) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unpacking: Unsupported order of spatial differencing %ld", cclass_name, orderOfSpatialDifferencing); - return GRIB_INTERNAL_ERROR; - } - - for (i = 0; i < orderOfSpatialDifferencing; i++) { - extras[i] = grib_decode_unsigned_long(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); - } - - bias = grib_decode_signed_longb(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); - - post_process(a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias, extras); - // de_spatial_difference (a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias); - } - - binary_s = (T)codes_power(binary_scale_factor, 2); - decimal_s = (T)codes_power(-decimal_scale_factor, 10); - - for (i = 0; i < n_vals; i++) { - if (sec_val[i] == LONG_MAX) { - val[i] = (T)missingValue; - } - else { - val[i] = (T)((((T)sec_val[i]) * binary_s) + reference_value) * decimal_s; - } - } - - grib_context_free(a->context, sec_val); - return err; -} - static int find_nbits(unsigned int i) { #if !defined __GNUC__ || __GNUC__ < 4 @@ -1164,9 +775,9 @@ static void merge_j(struct section* h, int ref_bits, int width_bits, int has_und } } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_data_g22order_packing* self = reinterpret_cast(a); + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; @@ -1205,7 +816,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) return err; - optimize_scale_factor = 1; // TODO(masn): To be reviewed + optimize_scale_factor = 1; // TODO(masn): To be reviewed if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) return err; @@ -1235,7 +846,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) // orderOfSpatialDifferencing = 1 means "grid_complex_spatial_differencing" with orderOfSpatialDifferencing=1 // orderOfSpatialDifferencing = 2 means "grid_complex_spatial_differencing" with orderOfSpatialDifferencing=2 - use_bitmap = bitmap_present; + use_bitmap = bitmap_present; wanted_bits = bits_per_value; for (i = 0; i < *len; i++) { @@ -1247,7 +858,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if (ndef == 0) { // Special case: All undefined values // Section 5 const char* packing_type = "grid_complex"; - size_t packing_type_len = strlen(packing_type); + size_t packing_type_len = strlen(packing_type); grib_set_string_internal(gh, "packingType", packing_type, &packing_type_len); if ((err = grib_set_double_internal(gh, self->reference_value, grib_ieee_to_long(0.0))) != GRIB_SUCCESS) @@ -1287,8 +898,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) if ((err = grib_set_long_internal(gh, "bitmapPresent", 0)) != GRIB_SUCCESS) return err; // Section 7 - constexpr size_t sec7_size = 3; - unsigned char empty_sec7[sec7_size] = {255, 0, 0}; // group reference, group width, group length + constexpr size_t sec7_size = 3; + unsigned char empty_sec7[sec7_size] = { 255, 0, 0 }; // group reference, group width, group length grib_buffer_replace(a, empty_sec7, sec7_size, 1, 1); return GRIB_SUCCESS; } @@ -1304,12 +915,12 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) dec_scale = -decimal_scale_factor; bin_scale = binary_scale_factor; - //compute bitmap section - //if (use_bitmap == 0 || ndef == ndata) { - // if ((err = grib_set_long_internal(gh, "bitmapPresent", 0)) != GRIB_SUCCESS) return err; - //} else { - // if ((err = grib_set_long_internal(gh, "bitmapPresent", 1)) != GRIB_SUCCESS) return err; - //} + // compute bitmap section + // if (use_bitmap == 0 || ndef == ndata) { + // if ((err = grib_set_long_internal(gh, "bitmapPresent", 0)) != GRIB_SUCCESS) return err; + // } else { + // if ((err = grib_set_long_internal(gh, "bitmapPresent", 1)) != GRIB_SUCCESS) return err; + // } nndata = use_bitmap ? ndef : ndata; has_undef = use_bitmap ? 0 : ndata != ndef; @@ -1478,7 +1089,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) #ifdef DEBUG grib_context_log(a->context, GRIB_LOG_DEBUG, "COMPLEX: 2: vmx %d vmn %d nbits %d", vmx, vmn, - find_nbits(vmx - vmn + has_undef)); + find_nbits(vmx - vmn + has_undef)); #endif for (i = 0; i < nndata; i++) { @@ -1499,7 +1110,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) list = reinterpret_cast(grib_context_malloc_clear(a->context, nstruct * sizeof(section))); if (list == NULL) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: memory allocation of list failed",cclass_name); + grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: memory allocation of list failed", cclass_name); return GRIB_OUT_OF_MEMORY; } @@ -1575,10 +1186,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) LEN_SEC_MAX); j = size_all(start.tail, vbits, LEN_BITS + est_group_width, has_undef); #ifdef DEBUG - grib_context_log(a->context, GRIB_LOG_DEBUG, - "COMPLEX: complex inc segments size size0 %d size1 %d segsize %d " - "LEN_BITS=%d", - j0, j, LEN_SEC_MAX, LEN_BITS); + grib_context_log(a->context, GRIB_LOG_DEBUG, + "COMPLEX: complex inc segments size size0 %d size1 %d segsize %d " + "LEN_BITS=%d", + j0, j, LEN_SEC_MAX, LEN_BITS); #endif if (j > j0) { memcpy(list, list_backup, nstruct * sizeof(struct section)); @@ -1586,7 +1197,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) LEN_SEC_MAX = (LEN_SEC_MAX - 1) / 2; } } - grib_context_free(a->context,list_backup); + grib_context_free(a->context, list_backup); exchange(start.tail, v, has_undef, LEN_SEC_MAX); #ifdef DEBUG @@ -1637,7 +1248,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) itmp2 = reinterpret_cast(grib_context_malloc(a->context, ngroups * sizeof(int))); if (lens == NULL || widths == NULL || refs == NULL || itmp == NULL || itmp2 == NULL) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: memory alloc of lens/widths/refs/itmp/itmp2 failed",cclass_name); + grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: memory alloc of lens/widths/refs/itmp/itmp2 failed", cclass_name); return GRIB_OUT_OF_MEMORY; } @@ -1694,7 +1305,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) } } - bits_per_value = find_nbits(grefmx + has_undef); + bits_per_value = find_nbits(grefmx + has_undef); numberOfBitsUsedForTheGroupWidths = find_nbits(gwidmx - gwidmn + has_undef); if ((err = grib_set_long_internal(gh, self->bits_per_value, bits_per_value)) != GRIB_SUCCESS) @@ -1772,7 +1383,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) unsigned char* sec7 = reinterpret_cast(grib_context_malloc(a->context, size_sec7)); if (sec7 == NULL) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s packing: unable to allocate %d bytes", cclass_name, size_sec7); + grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Unable to allocate %d bytes", cclass_name, size_sec7); return GRIB_OUT_OF_MEMORY; } @@ -1850,17 +1461,268 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +template +static int unpack(grib_accessor* a, T* val, const size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating points numbers"); + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); + const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + + size_t i = 0; + size_t j = 0; + long n_vals = 0; + long vcount = 0; + int err = GRIB_SUCCESS; + long* sec_val = NULL; + unsigned char* buf = reinterpret_cast(gh->buffer->data); + unsigned char* buf_ref = NULL; + unsigned char* buf_width = NULL; + unsigned char* buf_length = NULL; + unsigned char* buf_vals = NULL; + + long length_p = 0; + long ref_p = 0; + long width_p = 0; + long vals_p = 0; + long nvals_per_group = 0; + long nbits_per_group_val = 0; + long group_ref_val = 0; + + long bits_per_value = 0; + T binary_s = 0; + T decimal_s = 0; + double reference_value = 0; + + long binary_scale_factor; + long decimal_scale_factor; + long typeOfOriginalFieldValues; + long groupSplittingMethodUsed; + long missingValueManagementUsed; + long primaryMissingValueSubstitute; + long secondaryMissingValueSubstitute; + long numberOfGroupsOfDataValues; + long referenceForGroupWidths; + long numberOfBitsUsedForTheGroupWidths; + long referenceForGroupLengths; + long lengthIncrementForTheGroupLengths; + long trueLengthOfLastGroup; + long numberOfBitsUsedForTheScaledGroupLengths; + long orderOfSpatialDifferencing = 0; + long numberOfOctetsExtraDescriptors = 0; + double missingValue = 0; + + err = a->value_count(&n_vals); + if (err) + return err; + + if (*len < static_cast(n_vals)) + return GRIB_ARRAY_TOO_SMALL; + + if ((err = grib_get_long_internal(gh, self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(gh, self->reference_value, &reference_value)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->typeOfOriginalFieldValues, &typeOfOriginalFieldValues)) != GRIB_SUCCESS) + return err; + + // Don't call grib_get_long_internal to suppress error message being output + if ((err = grib_get_long(gh, self->groupSplittingMethodUsed, &groupSplittingMethodUsed)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->missingValueManagementUsed, &missingValueManagementUsed)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->primaryMissingValueSubstitute, &primaryMissingValueSubstitute)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->secondaryMissingValueSubstitute, &secondaryMissingValueSubstitute)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfGroupsOfDataValues, &numberOfGroupsOfDataValues)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->referenceForGroupWidths, &referenceForGroupWidths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheGroupWidths, &numberOfBitsUsedForTheGroupWidths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->referenceForGroupLengths, &referenceForGroupLengths)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long_internal(gh, self->lengthIncrementForTheGroupLengths, &lengthIncrementForTheGroupLengths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->trueLengthOfLastGroup, &trueLengthOfLastGroup)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfBitsUsedForTheScaledGroupLengths, &numberOfBitsUsedForTheScaledGroupLengths)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->orderOfSpatialDifferencing, &orderOfSpatialDifferencing)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long_internal(gh, self->numberOfOctetsExtraDescriptors, &numberOfOctetsExtraDescriptors)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_double_internal(gh, "missingValue", &missingValue)) != GRIB_SUCCESS) + return err; + + self->dirty = 0; + + sec_val = (long*)grib_context_malloc(a->context, (n_vals) * sizeof(long)); + if (!sec_val) return GRIB_OUT_OF_MEMORY; + memset(sec_val, 0, (n_vals) * sizeof(long)); // See SUP-718 + + buf_ref = buf + a->offset; + + ref_p = (numberOfGroupsOfDataValues * bits_per_value); + + if (orderOfSpatialDifferencing) + ref_p += (1 + orderOfSpatialDifferencing) * (numberOfOctetsExtraDescriptors * 8); + + buf_width = buf_ref + (ref_p / 8) + ((ref_p % 8) ? 1 : 0); + + width_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheGroupWidths); + buf_length = buf_width + (width_p / 8) + ((width_p % 8) ? 1 : 0); + + length_p = (numberOfGroupsOfDataValues * numberOfBitsUsedForTheScaledGroupLengths); + buf_vals = buf_length + (length_p / 8) + ((length_p % 8) ? 1 : 0); + + length_p = 0; + ref_p = orderOfSpatialDifferencing ? (orderOfSpatialDifferencing + 1) * (numberOfOctetsExtraDescriptors * 8) : 0; + width_p = 0; + vals_p = 0; + vcount = 0; + + for (i = 0; i < numberOfGroupsOfDataValues; i++) { + group_ref_val = grib_decode_unsigned_long(buf_ref, &ref_p, bits_per_value); + nvals_per_group = grib_decode_unsigned_long(buf_length, &length_p, numberOfBitsUsedForTheScaledGroupLengths); + nbits_per_group_val = grib_decode_unsigned_long(buf_width, &width_p, numberOfBitsUsedForTheGroupWidths); + + nvals_per_group *= lengthIncrementForTheGroupLengths; + nvals_per_group += referenceForGroupLengths; + nbits_per_group_val += referenceForGroupWidths; + + if (i == numberOfGroupsOfDataValues - 1) + nvals_per_group = trueLengthOfLastGroup; + if (n_vals < vcount + nvals_per_group) { + return GRIB_DECODING_ERROR; + } + + // grib_decode_long_array(buf_vals, &vals_p, nbits_per_group_val, nvals_per_group, &sec_val[vcount]); + if (missingValueManagementUsed == 0) { + // No explicit missing values included within data values + for (j = 0; j < nvals_per_group; j++) { + DEBUG_ASSERT_ACCESS(sec_val, (long)(vcount + j), n_vals); + sec_val[vcount + j] = group_ref_val + grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + // printf("sec_val[%ld]=%ld\n", vcount+j, sec_val[vcount+j]); + } + } + else if (missingValueManagementUsed == 1) { + // Primary missing values included within data values + long maxn = 0; // (1 << bits_per_value) - 1; + for (j = 0; j < nvals_per_group; j++) { + if (nbits_per_group_val == 0) { + maxn = (1 << bits_per_value) - 1; + if (group_ref_val == maxn) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + sec_val[vcount + j] = group_ref_val + temp; + } + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + maxn = (1 << nbits_per_group_val) - 1; + if (temp == maxn) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + sec_val[vcount + j] = group_ref_val + temp; + } + } + } + } + else if (missingValueManagementUsed == 2) { + // Primary and secondary missing values included within data values + long maxn = (1 << bits_per_value) - 1; + long maxn2 = 0; // maxn - 1 + for (j = 0; j < nvals_per_group; j++) { + if (nbits_per_group_val == 0) { + maxn2 = maxn - 1; + if (group_ref_val == maxn || group_ref_val == maxn2) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + sec_val[vcount + j] = group_ref_val + temp; + } + } + else { + long temp = grib_decode_unsigned_long(buf_vals, &vals_p, nbits_per_group_val); + maxn = (1 << nbits_per_group_val) - 1; + maxn2 = maxn - 1; + if (temp == maxn || temp == maxn2) { + sec_val[vcount + j] = LONG_MAX; // missing value + } + else { + sec_val[vcount + j] = group_ref_val + temp; + } + } + } + } + + vcount += nvals_per_group; + } + + if (orderOfSpatialDifferencing) { + long bias = 0; + unsigned long extras[2] = { + 0, + }; + ref_p = 0; + + // For Complex packing, order == 0 + // For Complex packing and spatial differencing, order == 1 or 2 (code table 5.6) + if (orderOfSpatialDifferencing != 1 && orderOfSpatialDifferencing != 2) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unpacking: Unsupported order of spatial differencing %ld", cclass_name, orderOfSpatialDifferencing); + return GRIB_INTERNAL_ERROR; + } + + for (i = 0; i < orderOfSpatialDifferencing; i++) { + extras[i] = grib_decode_unsigned_long(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); + } + + bias = grib_decode_signed_longb(buf_ref, &ref_p, numberOfOctetsExtraDescriptors * 8); + + post_process(a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias, extras); + // de_spatial_difference (a->context, sec_val, n_vals, orderOfSpatialDifferencing, bias); + } + + binary_s = (T)codes_power(binary_scale_factor, 2); + decimal_s = (T)codes_power(-decimal_scale_factor, 10); + + for (i = 0; i < n_vals; i++) { + if (sec_val[i] == LONG_MAX) { + val[i] = (T)missingValue; + } + else { + val[i] = (T)((((T)sec_val[i]) * binary_s) + reference_value) * decimal_s; + } + } + + grib_context_free(a->context, sec_val); + return err; +} + +int grib_accessor_class_data_g22order_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) { return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) +int grib_accessor_class_data_g22order_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) { return unpack(a, val, len); } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) +int grib_accessor_class_data_g22order_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) { size_t size = 0; double* values = NULL; @@ -1881,7 +1743,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +int grib_accessor_class_data_g22order_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) { size_t size = 0, i = 0; double* values; @@ -1909,9 +1771,9 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_data_g22order_packing_t::value_count(grib_accessor* a, long* count) { - grib_accessor_data_g22order_packing* self = reinterpret_cast(a); - *count = 0; + grib_accessor_data_g22order_packing_t* self = reinterpret_cast(a); + *count = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, count); } diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.h b/src/accessor/grib_accessor_class_data_g22order_packing.h new file mode 100644 index 000000000..329823633 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g22order_packing.h @@ -0,0 +1,54 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_values.h" +#include "grib_scaling.h" + +class grib_accessor_data_g22order_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_g22order_packing */ + const char* numberOfValues; + const char* bits_per_value; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scale_factor; + const char* typeOfOriginalFieldValues; + const char* groupSplittingMethodUsed; + const char* missingValueManagementUsed; + const char* primaryMissingValueSubstitute; + const char* secondaryMissingValueSubstitute; + const char* numberOfGroupsOfDataValues; + const char* referenceForGroupWidths; + const char* numberOfBitsUsedForTheGroupWidths; + const char* referenceForGroupLengths; + const char* lengthIncrementForTheGroupLengths; + const char* trueLengthOfLastGroup; + const char* numberOfBitsUsedForTheScaledGroupLengths; + const char* orderOfSpatialDifferencing; + const char* numberOfOctetsExtraDescriptors; +}; + +class grib_accessor_class_data_g22order_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_g22order_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g22order_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/grib_accessor_class_data_g2bifourier_packing.cc b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc similarity index 79% rename from src/grib_accessor_class_data_g2bifourier_packing.cc rename to src/accessor/grib_accessor_class_data_g2bifourier_packing.cc index 86275d470..a014ef3c2 100644 --- a/src/grib_accessor_class_data_g2bifourier_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,156 +9,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/******************************** - * philippe.marguinaud@meteo.fr - *******************************/ - +#include "grib_accessor_class_data_g2bifourier_packing.h" #include "grib_scaling.h" -#include "grib_api_internal.h" -#include "grib_optimize_decimal_factor.h" -#include -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS= const char* ieee_floats - MEMBERS= const char* laplacianOperatorIsSet - MEMBERS= const char* laplacianOperator - MEMBERS= const char* biFourierTruncationType - MEMBERS= const char* sub_i - MEMBERS= const char* sub_j - MEMBERS= const char* bif_i - MEMBERS= const char* bif_j - MEMBERS= const char* biFourierSubTruncationType - MEMBERS= const char* biFourierDoNotPackAxes - MEMBERS= const char* biFourierMakeTemplate - MEMBERS= const char* totalNumberOfValuesInUnpackedSubset - MEMBERS=const char* numberOfValues - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2bifourier_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g2bifourier_packing */ - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* biFourierTruncationType; - const char* sub_i; - const char* sub_j; - const char* bif_i; - const char* bif_j; - const char* biFourierSubTruncationType; - const char* biFourierDoNotPackAxes; - const char* biFourierMakeTemplate; - const char* totalNumberOfValuesInUnpackedSubset; - const char* numberOfValues; -} grib_accessor_data_g2bifourier_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g2bifourier_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g2bifourier_packing", /* name */ - sizeof(grib_accessor_data_g2bifourier_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_data_g2bifourier_packing_t _grib_accessor_class_data_g2bifourier_packing{"data_g2bifourier_packing"}; grib_accessor_class* grib_accessor_class_data_g2bifourier_packing = &_grib_accessor_class_data_g2bifourier_packing; -/* END_CLASS_IMP */ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; +void grib_accessor_class_data_g2bifourier_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); self->ieee_floats = grib_arguments_get_name(gh, args, self->carg++); @@ -178,9 +42,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) self->dirty = 1; } -static int value_count(grib_accessor* a, long* numberOfValues) -{ - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; +int grib_accessor_class_data_g2bifourier_packing_t::value_count(grib_accessor* a, long* numberOfValues){ + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); *numberOfValues = 0; @@ -496,7 +359,7 @@ static void free_bif_trunc(bif_trunc_t* bt, grib_accessor* a) static bif_trunc_t* new_bif_trunc(grib_accessor* a) { int ret; - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); bif_trunc_t* bt = (bif_trunc_t*)grib_context_malloc(gh->context, sizeof(bif_trunc_t)); @@ -607,9 +470,8 @@ cleanup: return NULL; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; +int grib_accessor_class_data_g2bifourier_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); unsigned char* buf = NULL; @@ -633,7 +495,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) int ret = GRIB_SUCCESS; int i, j, k; - if ((ret = grib_value_count(a, &count)) != GRIB_SUCCESS) + if ((ret = a->value_count(&count)) != GRIB_SUCCESS) goto cleanup; bt = new_bif_trunc(a); @@ -659,8 +521,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) self->dirty = 0; buf = (unsigned char*)gh->buffer->data; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); s = codes_power(bt->binary_scale_factor, 2); d = codes_power(-bt->decimal_scale_factor, 10); @@ -670,7 +531,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) hres = buf; lres = buf; - packed_offset = grib_byte_offset(a) + bt->bytes * bt->n_vals_sub; + packed_offset = a->byte_offset() + bt->bytes * bt->n_vals_sub; lpos = 8 * (packed_offset - offsetdata); hpos = 0; @@ -706,9 +567,8 @@ cleanup: return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2bifourier_packing* self = (grib_accessor_data_g2bifourier_packing*)a; +int grib_accessor_class_data_g2bifourier_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2bifourier_packing_t* self = (grib_accessor_data_g2bifourier_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.h b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h new file mode 100644 index 000000000..2fd7378a5 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.h @@ -0,0 +1,43 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g2bifourier_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_g2bifourier_packing */ + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* biFourierTruncationType; + const char* sub_i; + const char* sub_j; + const char* bif_i; + const char* bif_j; + const char* biFourierSubTruncationType; + const char* biFourierDoNotPackAxes; + const char* biFourierMakeTemplate; + const char* totalNumberOfValuesInUnpackedSubset; + const char* numberOfValues; +}; + +class grib_accessor_class_data_g2bifourier_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g2bifourier_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2bifourier_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.cc b/src/accessor/grib_accessor_class_data_g2complex_packing.cc new file mode 100644 index 000000000..c1e5e7aad --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.cc @@ -0,0 +1,47 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_g2complex_packing.h" + +grib_accessor_class_data_g2complex_packing_t _grib_accessor_class_data_g2complex_packing{"data_g2complex_packing"}; +grib_accessor_class* grib_accessor_class_data_g2complex_packing = &_grib_accessor_class_data_g2complex_packing; + + +void grib_accessor_class_data_g2complex_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_complex_packing_t::init(a, v, args); + grib_accessor_data_g2complex_packing_t* self = (grib_accessor_data_g2complex_packing_t*)a; + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->edition = 2; + + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_g2complex_packing_t::value_count(grib_accessor* a, long* numberOfValues){ + grib_accessor_data_g2complex_packing_t* self = (grib_accessor_data_g2complex_packing_t*)a; + *numberOfValues = 0; + + return grib_get_long(grib_handle_of_accessor(a), self->numberOfValues, numberOfValues); +} + +int grib_accessor_class_data_g2complex_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2complex_packing_t* self = (grib_accessor_data_g2complex_packing_t*)a; + int ret = GRIB_SUCCESS; + + if (*len == 0) + return GRIB_NO_VALUES; + + ret = grib_accessor_class_data_complex_packing_t::pack_double(a, val, len); + + if (ret == GRIB_SUCCESS) + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, *len); + + return ret; +} diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.h b/src/accessor/grib_accessor_class_data_g2complex_packing.h new file mode 100644 index 000000000..49f33a711 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_complex_packing.h" + +class grib_accessor_data_g2complex_packing_t : public grib_accessor_data_complex_packing_t +{ +public: + /* Members defined in data_g2complex_packing */ + const char* numberOfValues; +}; + +class grib_accessor_class_data_g2complex_packing_t : public grib_accessor_class_data_complex_packing_t +{ +public: + grib_accessor_class_data_g2complex_packing_t(const char* name) : grib_accessor_class_data_complex_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2complex_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc new file mode 100644 index 000000000..a6fd7bd46 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc @@ -0,0 +1,107 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_g2secondary_bitmap.h" + +grib_accessor_class_data_g2secondary_bitmap_t _grib_accessor_class_data_g2secondary_bitmap{"data_g2secondary_bitmap"}; +grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap = &_grib_accessor_class_data_g2secondary_bitmap; + + +void grib_accessor_class_data_g2secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_secondary_bitmap_t::init(a, v, args); + grib_accessor_data_g2secondary_bitmap_t* self = (grib_accessor_data_g2secondary_bitmap_t*)a; + self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); +} + +int grib_accessor_class_data_g2secondary_bitmap_t::value_count(grib_accessor* a, long* len){ + grib_accessor_data_g2secondary_bitmap_t* self = (grib_accessor_data_g2secondary_bitmap_t*)a; + *len = 0; + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, len); +} + +int grib_accessor_class_data_g2secondary_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2secondary_bitmap_t* self = (grib_accessor_data_g2secondary_bitmap_t*)a; + int err = 0; + + long primary_len = 0, secondary_len = 0; + double* primary_bitmap = NULL; + double* secondary_bitmap = NULL; + long i = 0, j = 0, k = 0, m = 0; + double missing_value = 0, present_value = 0; + long expand_by = 0; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) + return err; + if (expand_by <= 0) + return GRIB_ENCODING_ERROR; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if (*len % expand_by) { + /*TODO: issue warning */ + return GRIB_ENCODING_ERROR; + } + + primary_len = *len / expand_by; + primary_bitmap = (double*)grib_context_malloc_clear(a->context, primary_len * sizeof(double)); + if (!primary_bitmap) + return GRIB_OUT_OF_MEMORY; + + secondary_len = *len; + secondary_bitmap = (double*)grib_context_malloc_clear(a->context, secondary_len * sizeof(double)); + if (!secondary_bitmap) { + grib_context_free(a->context, primary_bitmap); + return GRIB_OUT_OF_MEMORY; + } + + if (missing_value == 0) + present_value = 1; + else + present_value = 0; + + k = 0; + m = 0; + for (i = 0; i < *len; i += expand_by) { + int cnt = 0; + for (j = 0; j < expand_by; j++) + if (val[i + j] == missing_value) + cnt++; + + if (cnt == expand_by) /* all expand_by values are missing */ + primary_bitmap[k++] = missing_value; + else { + primary_bitmap[k++] = present_value; + for (j = 0; j < expand_by; j++) + secondary_bitmap[m++] = val[i + j]; + //on++; + } + } + + *len = k; + + Assert(k == primary_len); + + err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_bitmap, k); + if (err == GRIB_SUCCESS) + err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_bitmap, m); + + grib_context_free(a->context, primary_bitmap); + grib_context_free(a->context, secondary_bitmap); + + if (err == GRIB_SUCCESS) + err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, *len * expand_by); + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h new file mode 100644 index 000000000..f981e1e6c --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_secondary_bitmap.h" + +class grib_accessor_data_g2secondary_bitmap_t : public grib_accessor_data_secondary_bitmap_t +{ +public: + /* Members defined in data_g2secondary_bitmap */ + const char* number_of_values; +}; + +class grib_accessor_class_data_g2secondary_bitmap_t : public grib_accessor_class_data_secondary_bitmap_t +{ +public: + grib_accessor_class_data_g2secondary_bitmap_t(const char* name) : grib_accessor_class_data_secondary_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2secondary_bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc new file mode 100644 index 000000000..7e2b5cd54 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc @@ -0,0 +1,92 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_g2shsimple_packing.h" + +grib_accessor_class_data_g2shsimple_packing_t _grib_accessor_class_data_g2shsimple_packing{"data_g2shsimple_packing"}; +grib_accessor_class* grib_accessor_class_data_g2shsimple_packing = &_grib_accessor_class_data_g2shsimple_packing; + + +void grib_accessor_class_data_g2shsimple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_shsimple_packing_t::init(a, v, args); + grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; + + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); + self->numberOfDataPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, 3); + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_g2shsimple_packing_t::value_count(grib_accessor* a, long* len){ + grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; + *len = 0; + return grib_get_long(grib_handle_of_accessor(a), self->numberOfValues, len); +} + +int grib_accessor_class_data_g2shsimple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; + int err = GRIB_SUCCESS; + + size_t n_vals = 0; + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &n_vals)) != GRIB_SUCCESS) + return err; + + self->dirty = 0; + + /* n_vals = coded_n_vals+1; */ + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->real_part, val)) != GRIB_SUCCESS) + return err; + + val++; + + if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, &n_vals)) != GRIB_SUCCESS) + return err; + + *len = n_vals; + + return err; +} + +int grib_accessor_class_data_g2shsimple_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_g2shsimple_packing_t* self = (grib_accessor_data_g2shsimple_packing_t*)a; + int err = GRIB_SUCCESS; + + size_t coded_n_vals = *len - 1; + size_t n_vals = *len; + + if (*len == 0) + return GRIB_NO_VALUES; + + self->dirty = 1; + + if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->real_part, *val)) != GRIB_SUCCESS) + return err; + + val++; + + if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, coded_n_vals)) != GRIB_SUCCESS) + return err; + + *len = n_vals; + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, (long)n_vals)) != GRIB_SUCCESS) + return err; + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfDataPoints, (long)n_vals)) != GRIB_SUCCESS) + return err; + + return err; +} diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.h b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h new file mode 100644 index 000000000..02da8345e --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.h @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_shsimple_packing.h" + +class grib_accessor_data_g2shsimple_packing_t : public grib_accessor_data_shsimple_packing_t +{ +public: + /* Members defined in data_g2shsimple_packing */ + const char* numberOfValues; + const char* numberOfDataPoints; +}; + +class grib_accessor_class_data_g2shsimple_packing_t : public grib_accessor_class_data_shsimple_packing_t +{ +public: + grib_accessor_class_data_g2shsimple_packing_t(const char* name) : grib_accessor_class_data_shsimple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2shsimple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing.cc new file mode 100644 index 000000000..08aa11699 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.cc @@ -0,0 +1,154 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_g2simple_packing.h" +#include "grib_scaling.h" + +grib_accessor_class_data_g2simple_packing_t _grib_accessor_class_data_g2simple_packing{"data_g2simple_packing"}; +grib_accessor_class* grib_accessor_class_data_g2simple_packing = &_grib_accessor_class_data_g2simple_packing; + + +void grib_accessor_class_data_g2simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_g2simple_packing_t* self = (grib_accessor_data_g2simple_packing_t*)a; + a->flags |= GRIB_ACCESSOR_FLAG_DATA; + self->edition = 2; +} + +int grib_accessor_class_data_g2simple_packing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_g2simple_packing_t* self = (grib_accessor_data_g2simple_packing_t*)a; + *n_vals = 0; + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); +} + +int grib_accessor_class_data_g2simple_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ + grib_accessor_data_g2simple_packing_t* self = (grib_accessor_data_g2simple_packing_t*)a; + //grib_accessor_class* super = *(a->cclass->super); + size_t n_vals = *len; + double reference_value = 0; + long binary_scale_factor = 0; + long bits_per_value = 0; + long decimal_scale_factor = 0; + double decimal = 1; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned char* encoded = NULL; + double divisor = 1; + long off = 0; + int ret = 0; + double units_factor = 1.0; + double units_bias = 0.0; + double* val = (double*)cval; + int i; + grib_context* c = a->context; + + if (*len == 0) { + grib_buffer_replace(a, NULL, 0, 1, 1); + return GRIB_SUCCESS; + } + + if (ret == GRIB_SUCCESS) + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, *len); + + if (ret != GRIB_SUCCESS) + return ret; + + if (self->units_factor && + (grib_get_double_internal(grib_handle_of_accessor(a), self->units_factor, &units_factor) == GRIB_SUCCESS)) { + grib_set_double_internal(grib_handle_of_accessor(a), self->units_factor, 1.0); + } + + if (self->units_bias && + (grib_get_double_internal(grib_handle_of_accessor(a), self->units_bias, &units_bias) == GRIB_SUCCESS)) { + grib_set_double_internal(grib_handle_of_accessor(a), self->units_bias, 0.0); + } + + if (units_factor != 1.0) { + if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { + val[i] = val[i] * units_factor + units_bias; + } + } else { + for (i = 0; i < n_vals; i++) { + val[i] *= units_factor; + } + } + } + else if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { + val[i] += units_bias; + } + } + + /* IEEE packing */ + if (c->ieee_packing) { + grib_handle* h = grib_handle_of_accessor(a); + long precision = 0; /* Either 1(=32 bits) or 2(=64 bits) */ + size_t lenstr = 10; + if ((ret = codes_check_grib_ieee_packing_value(c->ieee_packing)) != GRIB_SUCCESS) + return ret; + precision = c->ieee_packing == 32 ? 1 : 2; + if ((ret = grib_set_string(h, "packingType", "grid_ieee", &lenstr)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long(h, "precision", precision)) != GRIB_SUCCESS) + return ret; + + return grib_set_double_array(h, "values", val, *len); + } + + ret = grib_accessor_class_data_simple_packing_t::pack_double(a, cval, len); + switch (ret) { + case GRIB_CONSTANT_FIELD: + grib_buffer_replace(a, NULL, 0, 1, 1); + return GRIB_SUCCESS; + case GRIB_SUCCESS: + break; + default: + grib_context_log(a->context, GRIB_LOG_ERROR, "GRIB2 simple packing: unable to set values (%s)", grib_get_error_message(ret)); + return ret; + } + + if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->reference_value, &reference_value)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) + return ret; + + decimal = codes_power(decimal_scale_factor, 10); + divisor = codes_power(-binary_scale_factor, 2); + + buflen = (((bits_per_value * n_vals) + 7) / 8) * sizeof(unsigned char); + buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context, buflen); + encoded = buf; + + grib_encode_double_array(n_vals, val, bits_per_value, reference_value, decimal, divisor, encoded, &off); + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "grib_accessor_data_g2simple_packing_t : pack_double : packing %s, %d values", a->name, n_vals); + + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_buffer_free(a->context, buf); + + return ret; +} + +int grib_accessor_class_data_g2simple_packing_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len){ + size_t length = *len; + grib_buffer_replace(a, val, length, 1, 1); + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing.h b/src/accessor/grib_accessor_class_data_g2simple_packing.h new file mode 100644 index 000000000..a88cccac0 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing.h @@ -0,0 +1,26 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_g2simple_packing_t : public grib_accessor_data_simple_packing_t {}; + +class grib_accessor_class_data_g2simple_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_g2simple_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2simple_packing_t{}; } + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc new file mode 100644 index 000000000..fc87df231 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc @@ -0,0 +1,175 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_g2simple_packing_with_preprocessing.h" +#define DIRECT 0 +#define INVERSE 1 + +grib_accessor_class_data_g2simple_packing_with_preprocessing_t _grib_accessor_class_data_g2simple_packing_with_preprocessing{ "data_g2simple_packing_with_preprocessing" }; +grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing = &_grib_accessor_class_data_g2simple_packing_with_preprocessing; + + +void grib_accessor_class_data_g2simple_packing_with_preprocessing_t::init(grib_accessor* a, const long v, grib_arguments* args) +{ + grib_accessor_class_data_g2simple_packing_t::init(a, v, args); + grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; + self->pre_processing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->pre_processing_parameter = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::value_count(grib_accessor* a, long* n_vals) +{ + grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; + *n_vals = 0; + + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); +} + +static int pre_processing_func(double* values, long length, long pre_processing, + double* pre_processing_parameter, int mode) +{ + int i = 0, ret = 0; + double min = values[0]; + double next_min = values[0]; + Assert(length > 0); + + switch (pre_processing) { + /* NONE */ + case 0: + break; + /* LOGARITHM */ + case 1: + if (mode == DIRECT) { + for (i = 0; i < length; i++) { + if (values[i] < min) + min = values[i]; + if (values[i] > next_min) + next_min = values[i]; + } + for (i = 0; i < length; i++) { + if (values[i] > min && values[i] < next_min) + next_min = values[i]; + } + if (min > 0) { + *pre_processing_parameter = 0; + for (i = 0; i < length; i++) { + DEBUG_ASSERT(values[i] > 0); + values[i] = log(values[i]); + } + } + else { + double ppp = 0; + *pre_processing_parameter = next_min - 2 * min; + if (next_min == min) + return ret; + ppp = *pre_processing_parameter; + for (i = 0; i < length; i++) { + DEBUG_ASSERT((values[i] + ppp) > 0); + values[i] = log(values[i] + ppp); + } + } + } + else { + Assert(mode == INVERSE); + if (*pre_processing_parameter == 0) { + for (i = 0; i < length; i++) + values[i] = exp(values[i]); + } + else { + for (i = 0; i < length; i++) + values[i] = exp(values[i]) - *pre_processing_parameter; + } + } + break; + default: + ret = GRIB_NOT_IMPLEMENTED; + break; + } + + return ret; +} + +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; + + size_t n_vals = 0; + long nn = 0; + int err = 0; + + long pre_processing; + double pre_processing_parameter; + + err = a->value_count(&nn); + n_vals = nn; + if (err) + return err; + + if (n_vals == 0) { + *len = 0; + return GRIB_SUCCESS; + } + + self->dirty = 0; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->pre_processing, &pre_processing)) != GRIB_SUCCESS) { + return err; + } + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->pre_processing_parameter, &pre_processing_parameter)) != GRIB_SUCCESS) { + return err; + } + + err = grib_accessor_class_data_simple_packing_t::unpack_double(a, val, &n_vals); + if (err != GRIB_SUCCESS) + return err; + + err = pre_processing_func(val, n_vals, pre_processing, &pre_processing_parameter, INVERSE); + if (err != GRIB_SUCCESS) + return err; + + *len = (long)n_vals; + + return err; +} + +int grib_accessor_class_data_g2simple_packing_with_preprocessing_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + grib_accessor_data_g2simple_packing_with_preprocessing_t* self = (grib_accessor_data_g2simple_packing_with_preprocessing_t*)a; + + size_t n_vals = *len; + int err = 0; + + long pre_processing = 0; + double pre_processing_parameter = 0; + + self->dirty = 1; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->pre_processing, &pre_processing)) != GRIB_SUCCESS) + return err; + + err = pre_processing_func((double*)val, n_vals, pre_processing, &pre_processing_parameter, DIRECT); + if (err != GRIB_SUCCESS) + return err; + + err = grib_accessor_class_data_g2simple_packing_t::pack_double(a, val, len); + if (err != GRIB_SUCCESS) + return err; + + if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->pre_processing_parameter, pre_processing_parameter)) != GRIB_SUCCESS) + return err; + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals)) != GRIB_SUCCESS) + return err; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h new file mode 100644 index 000000000..4e2437e8b --- /dev/null +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.h @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_g2simple_packing.h" + +class grib_accessor_data_g2simple_packing_with_preprocessing_t : public grib_accessor_data_g2simple_packing_t +{ +public: + /* Members defined in data_g2simple_packing_with_preprocessing */ + const char* pre_processing; + const char* pre_processing_parameter; +}; + +class grib_accessor_class_data_g2simple_packing_with_preprocessing_t : public grib_accessor_class_data_g2simple_packing_t +{ +public: + grib_accessor_class_data_g2simple_packing_with_preprocessing_t(const char* name) : grib_accessor_class_data_g2simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_g2simple_packing_with_preprocessing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc similarity index 72% rename from src/grib_accessor_class_data_jpeg2000_packing.cc rename to src/accessor/grib_accessor_class_data_jpeg2000_packing.cc index 66d6f6767..5ce5ae154 100644 --- a/src/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,148 +9,21 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double;unpack_float - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = value_count - MEMBERS=const char* type_of_compression_used - MEMBERS=const char* target_compression_ratio - MEMBERS=const char* ni - MEMBERS=const char* nj - MEMBERS=const char* list_defining_points - MEMBERS=const char* number_of_data_points - MEMBERS=const char* scanning_mode - MEMBERS=int jpeg_lib - MEMBERS=const char* dump_jpg - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_jpeg2000_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_jpeg2000_packing */ - const char* type_of_compression_used; - const char* target_compression_ratio; - const char* ni; - const char* nj; - const char* list_defining_points; - const char* number_of_data_points; - const char* scanning_mode; - int jpeg_lib; - const char* dump_jpg; -} grib_accessor_data_jpeg2000_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_jpeg2000_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_jpeg2000_packing", /* name */ - sizeof(grib_accessor_data_jpeg2000_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_data_jpeg2000_packing.h" +grib_accessor_class_data_jpeg2000_packing_t _grib_accessor_class_data_jpeg2000_packing{"data_jpeg2000_packing"}; grib_accessor_class* grib_accessor_class_data_jpeg2000_packing = &_grib_accessor_class_data_jpeg2000_packing; -/* END_CLASS_IMP */ static int first = 1; #define JASPER_LIB 1 #define OPENJPEG_LIB 2 -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ +void grib_accessor_class_data_jpeg2000_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); const char* user_lib = NULL; - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->jpeg_lib = 0; @@ -204,9 +78,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) } } -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; *n_vals = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); @@ -215,19 +88,16 @@ static int value_count(grib_accessor* a, long* n_vals) #define EXTRA_BUFFER_SIZE 10240 #if HAVE_JPEG -static int unpack_float(grib_accessor*, float* val, size_t* len) -{ +int grib_accessor_class_data_jpeg2000_packing_t::unpack_float(grib_accessor*, float* val, size_t* len){ return GRIB_NOT_IMPLEMENTED; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; int err = GRIB_SUCCESS; - int i; - size_t buflen = grib_byte_count(a); - + size_t i = 0; + size_t buflen = a->byte_count(); double bscale = 0; double dscale = 0; unsigned char* buf = NULL; @@ -242,8 +112,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) double units_bias = 0.0; n_vals = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; @@ -282,8 +151,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); switch (self->jpeg_lib) { case OPENJPEG_LIB: if ((err = grib_openjpeg_decode(a->context, buf, &buflen, val, &n_vals)) != GRIB_SUCCESS) @@ -304,24 +172,27 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) val[i] = (val[i] * bscale + reference_value) * dscale; } if (units_factor != 1.0) { - if (units_bias != 0.0) - for (i = 0; i < n_vals; i++) + if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { val[i] = val[i] * units_factor + units_bias; - else - for (i = 0; i < n_vals; i++) + } + } else { + for (i = 0; i < n_vals; i++) { val[i] *= units_factor; + } + } } - else if (units_bias != 0.0) - for (i = 0; i < n_vals; i++) + else if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { val[i] += units_bias; + } + } return err; } -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; - grib_accessor_class* super = *(a->cclass->super); +int grib_accessor_class_data_jpeg2000_packing_t::pack_double(grib_accessor* a, const double* cval, size_t* len){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; size_t n_vals = *len; int err = 0; int i; @@ -378,13 +249,13 @@ static int pack_double(grib_accessor* a, const double* cval, size_t* len) for (i = 0; i < n_vals; i++) val[i] += units_bias; - ret = super->pack_double(a, val, len); + ret = grib_accessor_class_data_simple_packing_t::pack_double(a, val, len); + switch (ret) { case GRIB_CONSTANT_FIELD: grib_buffer_replace(a, NULL, 0, 1, 1); err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, *len); return err; - break; case GRIB_SUCCESS: break; default: @@ -557,33 +428,28 @@ cleanup: } #else -static void print_error_feature_not_enabled(grib_context* c) -{ +static void print_error_feature_not_enabled(grib_context* c){ grib_context_log(c, GRIB_LOG_ERROR, "JPEG support not enabled. Please rebuild with -DENABLE_JPG=ON"); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ +int grib_accessor_class_data_jpeg2000_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_jpeg2000_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ +int grib_accessor_class_data_jpeg2000_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } #endif -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0; double* values = NULL; @@ -620,9 +486,8 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - grib_accessor_data_jpeg2000_packing* self = (grib_accessor_data_jpeg2000_packing*)a; +int grib_accessor_class_data_jpeg2000_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + grib_accessor_data_jpeg2000_packing_t* self = (grib_accessor_data_jpeg2000_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); size_t size = 0, i = 0; double* values = NULL; diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.h b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h new file mode 100644 index 000000000..54dcc457c --- /dev/null +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.h @@ -0,0 +1,42 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_jpeg2000_packing_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_jpeg2000_packing */ + const char* type_of_compression_used; + const char* target_compression_ratio; + const char* ni; + const char* nj; + const char* list_defining_points; + const char* number_of_data_points; + const char* scanning_mode; + int jpeg_lib; + const char* dump_jpg; +}; + +class grib_accessor_class_data_jpeg2000_packing_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_jpeg2000_packing_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_jpeg2000_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc similarity index 76% rename from src/grib_accessor_class_data_png_packing.cc rename to src/accessor/grib_accessor_class_data_png_packing.cc index e9747b19d..690070214 100644 --- a/src/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,134 +9,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_data_png_packing.h" #include "grib_scaling.h" -#include "grib_api_internal.h" + #define PNG_ANYBITS -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = unpack_double_element;unpack_double_element_set - MEMBERS=const char* number_of_values - MEMBERS=const char* reference_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* decimal_scale_factor - MEMBERS=const char* bits_per_value - MEMBERS=const char* ni - MEMBERS=const char* nj - MEMBERS=const char* list_defining_points - MEMBERS=const char* number_of_data_points - MEMBERS=const char* scanning_mode - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_png_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_png_packing */ - const char* number_of_values; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* bits_per_value; - const char* ni; - const char* nj; - const char* list_defining_points; - const char* number_of_data_points; - const char* scanning_mode; -} grib_accessor_data_png_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_png_packing = { - &grib_accessor_class_values, /* super */ - "data_png_packing", /* name */ - sizeof(grib_accessor_data_png_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_png_packing_t _grib_accessor_class_data_png_packing{"data_png_packing"}; grib_accessor_class* grib_accessor_class_data_png_packing = &_grib_accessor_class_data_png_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; +void grib_accessor_class_data_png_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_values_t::init(a, v, args); + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; grib_handle* h = grib_handle_of_accessor(a); self->number_of_values = grib_arguments_get_name(h, args, self->carg++); @@ -151,9 +36,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; +int grib_accessor_class_data_png_packing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; *n_vals = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); } @@ -196,14 +80,12 @@ static void png_flush_callback(png_structp png) /* Empty */ } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; +int grib_accessor_class_data_png_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; int err = GRIB_SUCCESS; int i, j; - size_t buflen = grib_byte_count(a); - + size_t buflen = a->byte_count(); double bscale = 0; double dscale = 0; unsigned char* buf = NULL; @@ -227,8 +109,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) self->dirty = 0; - err = grib_value_count(a, &nn); - n_vals = nn; + err = a->value_count(&nn); n_vals = nn; if (err) return err; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) @@ -257,8 +138,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - buf += grib_byte_offset(a); - + buf += a->byte_offset(); if (png_sig_cmp(buf, 0, 8) != 0) return GRIB_INVALID_MESSAGE; @@ -356,9 +236,8 @@ static bool is_constant(const double* values, size_t n_vals) return isConstant; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; +int grib_accessor_class_data_png_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; const char* cclass_name = a->cclass->name; int err = GRIB_SUCCESS; @@ -545,7 +424,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) } /* buflen = n_vals*(bits_per_value/8); */ grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_data_png_packing : pack_double : packing %s, %d values", a->name, n_vals); + "grib_accessor_data_png_packing_t : pack_double : packing %s, %d values", a->name, n_vals); buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context, buflen); if (!buf) { @@ -652,10 +531,9 @@ cleanup: return err; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_png_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ /* The index idx relates to codedValues NOT values! */ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; size_t size = 0; @@ -688,10 +566,9 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return GRIB_SUCCESS; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_png_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ /* The index idx relates to codedValues NOT values! */ - grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a; + grib_accessor_data_png_packing_t* self = (grib_accessor_data_png_packing_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; size_t size = 0, i = 0; @@ -735,29 +612,24 @@ static int unpack_double_element_set(grib_accessor* a, const size_t* index_array #else -static void print_error_feature_not_enabled(grib_context* c) -{ +static void print_error_feature_not_enabled(grib_context* c){ grib_context_log(c, GRIB_LOG_ERROR, "PNG support not enabled. Please rebuild with -DENABLE_PNG=ON"); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_data_png_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ +int grib_accessor_class_data_png_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ +int grib_accessor_class_data_png_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ +int grib_accessor_class_data_png_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ print_error_feature_not_enabled(a->context); return GRIB_FUNCTIONALITY_NOT_ENABLED; } diff --git a/src/accessor/grib_accessor_class_data_png_packing.h b/src/accessor/grib_accessor_class_data_png_packing.h new file mode 100644 index 000000000..841ed9d31 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_png_packing.h @@ -0,0 +1,41 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_values.h" + +class grib_accessor_data_png_packing_t : public grib_accessor_values_t +{ +public: + const char* number_of_values; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* bits_per_value; + const char* ni; + const char* nj; + const char* list_defining_points; + const char* number_of_data_points; + const char* scanning_mode; +}; + +class grib_accessor_class_data_png_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_png_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_png_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; +}; diff --git a/src/accessor/grib_accessor_class_data_raw_packing.cc b/src/accessor/grib_accessor_class_data_raw_packing.cc new file mode 100644 index 000000000..499b46bec --- /dev/null +++ b/src/accessor/grib_accessor_class_data_raw_packing.cc @@ -0,0 +1,194 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_raw_packing.h" +#include "grib_ieeefloat.h" + +grib_accessor_class_data_raw_packing_t _grib_accessor_class_data_raw_packing{"data_raw_packing"}; +grib_accessor_class* grib_accessor_class_data_raw_packing = &_grib_accessor_class_data_raw_packing; + + +void grib_accessor_class_data_raw_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_values_t::init(a, v, args); + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + + self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); + a->flags |= GRIB_ACCESSOR_FLAG_DATA; +} + +int grib_accessor_class_data_raw_packing_t::value_count(grib_accessor* a, long* n_vals){ + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + *n_vals = 0; + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); +} + +int grib_accessor_class_data_raw_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + unsigned char* buf = NULL; + int bytes = 0; + size_t nvals = 0; + long inlen = a->byte_count(); + long precision = 0; + + int code = GRIB_SUCCESS; + + if ((code = grib_get_long(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) + return code; + + self->dirty = 0; + + buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + buf += a->byte_offset(); + switch (precision) { + case 1: + bytes = 4; + break; + case 2: + bytes = 8; + break; + default: + return GRIB_NOT_IMPLEMENTED; + } + + nvals = inlen / bytes; + + if (*len < nvals) + return GRIB_ARRAY_TOO_SMALL; + + code = grib_ieee_decode_array(a->context, buf, nvals, bytes, val); + + *len = nvals; + + return code; +} + +int grib_accessor_class_data_raw_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + + int bytes = 0; + unsigned char* buffer = NULL; + + long precision = 0; + + double* values = (double*)val; + size_t inlen = *len; + + /*int free_buffer = 0; + *int free_values = 0;*/ + + int code = GRIB_SUCCESS; + + size_t bufsize = 0; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((code = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) + return code; + + self->dirty = 1; + + switch (precision) { + case 1: + bytes = 4; + break; + + case 2: + bytes = 8; + break; + + default: + code = GRIB_NOT_IMPLEMENTED; + goto clean_up; + } + + bufsize = bytes * inlen; + + buffer = (unsigned char*)grib_context_malloc(a->context, bufsize); + + if (!buffer) { + code = GRIB_OUT_OF_MEMORY; + goto clean_up; + } + + code = grib_ieee_encode_array(a->context, values, inlen, bytes, buffer); + +clean_up: + /*if (free_buffer) + * free(buffer); + * if (free_values) + * free(values); + */ + + grib_buffer_replace(a, buffer, bufsize, 1, 1); + + grib_context_buffer_free(a->context, buffer); + + if (code == GRIB_SUCCESS) { + code = grib_set_long(grib_handle_of_accessor(a), self->number_of_values, inlen); + if (code == GRIB_READ_ONLY) + code = 0; + } + + return code; +} + +int grib_accessor_class_data_raw_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ + int ret = 0; + grib_accessor_data_raw_packing_t* self = (grib_accessor_data_raw_packing_t*)a; + unsigned char* buf = NULL; + int bytes = 0; + size_t nvals = 0; + long inlen = a->byte_count(); long pos = 0; + long precision = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) + return ret; + + self->dirty = 0; + + buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + buf += a->byte_offset(); + switch (precision) { + case 1: + bytes = 4; + break; + + case 2: + bytes = 8; + break; + + default: + return GRIB_NOT_IMPLEMENTED; + } + + pos = bytes * idx; + + Assert(pos <= inlen); + + nvals = 1; + buf += pos; + + ret = grib_ieee_decode_array(a->context, buf, nvals, bytes, val); + + return ret; +} + +int grib_accessor_class_data_raw_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array){ + int err = 0; + size_t i = 0; + for (i=0; inumber_of_values = grib_arguments_get_name(gh, args, self->carg++); self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); @@ -133,16 +29,14 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->flags |= GRIB_ACCESSOR_FLAG_DATA; } -static int value_count(grib_accessor* a, long* number_of_values) -{ - grib_accessor_data_run_length_packing* self = (grib_accessor_data_run_length_packing*)a; +int grib_accessor_class_data_run_length_packing_t::value_count(grib_accessor* a, long* number_of_values){ + grib_accessor_data_run_length_packing_t* self = (grib_accessor_data_run_length_packing_t*)a; *number_of_values = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, number_of_values); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_run_length_packing* self = (grib_accessor_data_run_length_packing*)a; +int grib_accessor_class_data_run_length_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_run_length_packing_t* self = (grib_accessor_data_run_length_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; int err = GRIB_SUCCESS; @@ -204,8 +98,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } compressed_values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * number_of_compressed_values); buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - offsetBeforeData = grib_byte_offset(a); - buf += offsetBeforeData; + offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; pos = 0; grib_decode_long_array(buf, &pos, bits_per_value, number_of_compressed_values, compressed_values); j = 0; @@ -246,9 +139,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return err; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_run_length_packing* self = (grib_accessor_data_run_length_packing*)a; +int grib_accessor_class_data_run_length_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_run_length_packing_t* self = (grib_accessor_data_run_length_packing_t*)a; grib_handle* gh = grib_handle_of_accessor(a); const char* cclass_name = a->cclass->name; int err = GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.h b/src/accessor/grib_accessor_class_data_run_length_packing.h new file mode 100644 index 000000000..5a69a7ba0 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_run_length_packing.h @@ -0,0 +1,36 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_values.h" + +class grib_accessor_data_run_length_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_run_length_packing */ + const char* number_of_values; + const char* bits_per_value; + const char* max_level_value; + const char* number_of_level_values; + const char* decimal_scale_factor; + const char* level_values; +}; + +class grib_accessor_class_data_run_length_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_run_length_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_run_length_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc new file mode 100644 index 000000000..f79098f84 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc @@ -0,0 +1,118 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_secondary_bitmap.h" + +grib_accessor_class_data_secondary_bitmap_t _grib_accessor_class_data_secondary_bitmap{"data_secondary_bitmap"}; +grib_accessor_class* grib_accessor_class_data_secondary_bitmap = &_grib_accessor_class_data_secondary_bitmap; + + +void grib_accessor_class_data_secondary_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); + grib_accessor_data_secondary_bitmap_t* self = (grib_accessor_data_secondary_bitmap_t*)a; + self->primary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); + self->secondary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); + self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); + self->expand_by = grib_arguments_get_name(grib_handle_of_accessor(a), args, 3); + + a->length = 0; +} + +void grib_accessor_class_data_secondary_bitmap_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_values(dumper, a); +} + +int grib_accessor_class_data_secondary_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_secondary_bitmap_t* self = (grib_accessor_data_secondary_bitmap_t*)a; + + size_t i = 0; + size_t j = 0; + size_t k = 0; + size_t m = 0; + size_t n_vals = 0; + long nn = 0; + long expand_by = 0; + int err = 0; + size_t primary_len; + size_t secondary_len; + double* primary_vals; + double* secondary_vals; + err = a->value_count(&nn); n_vals = nn; + if (err) + return err; + + if (*len < n_vals) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->primary_bitmap, &primary_len)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_size(grib_handle_of_accessor(a), self->secondary_bitmap, &secondary_len)) != GRIB_SUCCESS) + return err; + + primary_vals = (double*)grib_context_malloc(a->context, primary_len * sizeof(double)); + if (!primary_vals) + return GRIB_OUT_OF_MEMORY; + + secondary_vals = (double*)grib_context_malloc(a->context, secondary_len * sizeof(double)); + if (!secondary_vals) { + grib_context_free(a->context, primary_vals); + return GRIB_OUT_OF_MEMORY; + } + + if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_vals, &primary_len)) != GRIB_SUCCESS) { + grib_context_free(a->context, secondary_vals); + grib_context_free(a->context, primary_vals); + return err; + } + + if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_vals, &secondary_len)) != GRIB_SUCCESS) { + grib_context_free(a->context, secondary_vals); + grib_context_free(a->context, primary_vals); + return err; + } + + k = 0; + m = 0; + for (i = 0; i < primary_len; i++) { + /* if(primary_vals[i]) f++; */ + if (primary_vals[i]) { + for (j = 0; j < expand_by; j++) + val[k++] = secondary_vals[m++]; + } + else { + for (j = 0; j < expand_by; j++) + val[k++] = 0; + } + } + + Assert(k <= *len); + Assert(m <= secondary_len); + + /*printf("FOOBAR %d %d %ld %d\n",f,primary_len,expand_by,n_vals);*/ + + *len = n_vals; + + grib_context_free(a->context, primary_vals); + grib_context_free(a->context, secondary_vals); + return err; +} + +int grib_accessor_class_data_secondary_bitmap_t::get_native_type(grib_accessor* a){ + // grib_accessor_data_secondary_bitmap_t* self = (grib_accessor_data_secondary_bitmap_t*)a; + //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); + return GRIB_TYPE_DOUBLE; +} diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.h b/src/accessor/grib_accessor_class_data_secondary_bitmap.h new file mode 100644 index 000000000..a24772be4 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.h @@ -0,0 +1,34 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_secondary_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_secondary_bitmap */ + const char* primary_bitmap; + const char* secondary_bitmap; + const char* missing_value; + const char* expand_by; +}; + +class grib_accessor_class_data_secondary_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_secondary_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_secondary_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_data_sh_packed.cc b/src/accessor/grib_accessor_class_data_sh_packed.cc similarity index 63% rename from src/grib_accessor_class_data_sh_packed.cc rename to src/accessor/grib_accessor_class_data_sh_packed.cc index 25687d262..80bc7648f 100644 --- a/src/grib_accessor_class_data_sh_packed.cc +++ b/src/accessor/grib_accessor_class_data_sh_packed.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,142 +9,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_data_sh_packed.h" #include "grib_scaling.h" -#include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS= const char* GRIBEX_sh_bug_present - MEMBERS= const char* ieee_floats - MEMBERS= const char* laplacianOperatorIsSet - MEMBERS= const char* laplacianOperator - MEMBERS= const char* sub_j - MEMBERS= const char* sub_k - MEMBERS= const char* sub_m - MEMBERS= const char* pen_j - MEMBERS= const char* pen_k - MEMBERS= const char* pen_m - END_CLASS_DEF - - */ - - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_sh_packed -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_sh_packed */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -} grib_accessor_data_sh_packed; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_sh_packed = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_sh_packed", /* name */ - sizeof(grib_accessor_data_sh_packed), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_data_sh_packed_t _grib_accessor_class_data_sh_packed{"data_sh_packed"}; grib_accessor_class* grib_accessor_class_data_sh_packed = &_grib_accessor_class_data_sh_packed; -/* END_CLASS_IMP */ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_sh_packed* self = (grib_accessor_data_sh_packed*)a; +void grib_accessor_class_data_sh_packed_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_sh_packed_t* self = (grib_accessor_data_sh_packed_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->GRIBEX_sh_bug_present = grib_arguments_get_name(hand, args, self->carg++); @@ -161,9 +39,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_sh_packed* self = (grib_accessor_data_sh_packed*)a; +int grib_accessor_class_data_sh_packed_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_sh_packed_t* self = (grib_accessor_data_sh_packed_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int ret = 0; const char* cclass_name = a->cclass->name; @@ -198,9 +75,8 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_sh_packed* self = (grib_accessor_data_sh_packed*)a; +int grib_accessor_class_data_sh_packed_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_sh_packed_t* self = (grib_accessor_data_sh_packed_t*)a; size_t i = 0; int ret = GRIB_SUCCESS; @@ -234,8 +110,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) decode_float_proc decode_float = NULL; n_vals = 0; - err = grib_value_count(a, &n_vals); - if (err) + err = a->value_count(&n_vals); if (err) return err; if (*len < n_vals) { diff --git a/src/accessor/grib_accessor_class_data_sh_packed.h b/src/accessor/grib_accessor_class_data_sh_packed.h new file mode 100644 index 000000000..bbe3caafe --- /dev/null +++ b/src/accessor/grib_accessor_class_data_sh_packed.h @@ -0,0 +1,39 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_sh_packed_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_sh_packed */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_sh_packed_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_sh_packed_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_sh_packed_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_data_sh_unpacked.cc b/src/accessor/grib_accessor_class_data_sh_unpacked.cc similarity index 61% rename from src/grib_accessor_class_data_sh_unpacked.cc rename to src/accessor/grib_accessor_class_data_sh_unpacked.cc index 394793612..efa738c65 100644 --- a/src/grib_accessor_class_data_sh_unpacked.cc +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,142 +9,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +#include "grib_accessor_class_data_sh_unpacked.h" #include "grib_scaling.h" -#include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS= const char* GRIBEX_sh_bug_present - MEMBERS= const char* ieee_floats - MEMBERS= const char* laplacianOperatorIsSet - MEMBERS= const char* laplacianOperator - MEMBERS= const char* sub_j - MEMBERS= const char* sub_k - MEMBERS= const char* sub_m - MEMBERS= const char* pen_j - MEMBERS= const char* pen_k - MEMBERS= const char* pen_m - END_CLASS_DEF - - */ - - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_sh_unpacked -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_sh_unpacked */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; -} grib_accessor_data_sh_unpacked; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_sh_unpacked = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_sh_unpacked", /* name */ - sizeof(grib_accessor_data_sh_unpacked), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_data_sh_unpacked_t _grib_accessor_class_data_sh_unpacked{"data_sh_unpacked"}; grib_accessor_class* grib_accessor_class_data_sh_unpacked = &_grib_accessor_class_data_sh_unpacked; -/* END_CLASS_IMP */ typedef unsigned long (*encode_float_proc)(double); typedef double (*decode_float_proc)(unsigned long); -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_sh_unpacked* self = (grib_accessor_data_sh_unpacked*)a; +void grib_accessor_class_data_sh_unpacked_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_data_simple_packing_t::init(a, v, args); + grib_accessor_data_sh_unpacked_t* self = (grib_accessor_data_sh_unpacked_t*)a; grib_handle* hand = grib_handle_of_accessor(a); self->GRIBEX_sh_bug_present = grib_arguments_get_name(hand, args, self->carg++); @@ -161,9 +39,8 @@ static void init(grib_accessor* a, const long v, grib_arguments* args) a->length = 0; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_sh_unpacked* self = (grib_accessor_data_sh_unpacked*)a; +int grib_accessor_class_data_sh_unpacked_t::value_count(grib_accessor* a, long* count){ + grib_accessor_data_sh_unpacked_t* self = (grib_accessor_data_sh_unpacked_t*)a; int ret = 0; long sub_j = 0; @@ -185,9 +62,8 @@ static int value_count(grib_accessor* a, long* count) return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_sh_unpacked* self = (grib_accessor_data_sh_unpacked*)a; +int grib_accessor_class_data_sh_unpacked_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_data_sh_unpacked_t* self = (grib_accessor_data_sh_unpacked_t*)a; size_t i = 0; int ret = GRIB_SUCCESS; @@ -234,8 +110,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) decode_float_proc decode_float = NULL; n_vals = 0; - err = grib_value_count(a, &n_vals); - if (err) + err = a->value_count(&n_vals); if (err) return err; if (*len < n_vals) { diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.h b/src/accessor/grib_accessor_class_data_sh_unpacked.h new file mode 100644 index 000000000..7907b8c68 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.h @@ -0,0 +1,39 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_data_simple_packing.h" + +class grib_accessor_data_sh_unpacked_t : public grib_accessor_data_simple_packing_t +{ +public: + /* Members defined in data_sh_unpacked */ + const char* GRIBEX_sh_bug_present; + const char* ieee_floats; + const char* laplacianOperatorIsSet; + const char* laplacianOperator; + const char* sub_j; + const char* sub_k; + const char* sub_m; + const char* pen_j; + const char* pen_k; + const char* pen_m; +}; + +class grib_accessor_class_data_sh_unpacked_t : public grib_accessor_class_data_simple_packing_t +{ +public: + grib_accessor_class_data_sh_unpacked_t(const char* name) : grib_accessor_class_data_simple_packing_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_sh_unpacked_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.cc b/src/accessor/grib_accessor_class_data_shsimple_packing.cc new file mode 100644 index 000000000..0de921d06 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.cc @@ -0,0 +1,60 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_data_shsimple_packing.h" + +grib_accessor_class_data_shsimple_packing_t _grib_accessor_class_data_shsimple_packing{"data_shsimple_packing"}; +grib_accessor_class* grib_accessor_class_data_shsimple_packing = &_grib_accessor_class_data_shsimple_packing; + + +void grib_accessor_class_data_shsimple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); + grib_accessor_data_shsimple_packing_t* self = (grib_accessor_data_shsimple_packing_t*)a; + + self->coded_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); + self->real_part = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); + a->flags |= GRIB_ACCESSOR_FLAG_DATA; + + a->length = 0; +} + +void grib_accessor_class_data_shsimple_packing_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_values(dumper, a); +} + +int grib_accessor_class_data_shsimple_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_data_shsimple_packing_t* self = (grib_accessor_data_shsimple_packing_t*)a; + int err = GRIB_SUCCESS; + + size_t coded_n_vals = *len - 1; + size_t n_vals = *len; + + self->dirty = 1; + + if (*len == 0) + return GRIB_NO_VALUES; + + if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->real_part, *val)) != GRIB_SUCCESS) + return err; + + val++; + + if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, coded_n_vals)) != GRIB_SUCCESS) + return err; + + *len = n_vals; + + return err; +} + +int grib_accessor_class_data_shsimple_packing_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.h b/src/accessor/grib_accessor_class_data_shsimple_packing.h new file mode 100644 index 000000000..7b1620141 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.h @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_data_shsimple_packing_t : public grib_accessor_gen_t +{ +public: + /* Members defined in data_shsimple_packing */ + const char* coded_values; + const char* real_part; + int dirty; +}; + +class grib_accessor_class_data_shsimple_packing_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_data_shsimple_packing_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_shsimple_packing_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_data_simple_packing.cc b/src/accessor/grib_accessor_class_data_simple_packing.cc similarity index 71% rename from src/grib_accessor_class_data_simple_packing.cc rename to src/accessor/grib_accessor_class_data_simple_packing.cc index 0d44acd7f..591e89526 100644 --- a/src/grib_accessor_class_data_simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_simple_packing.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,148 +9,30 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_scaling.h" -#include "grib_bits_any_endian_simple.h" +#include "grib_accessor_class_data_simple_packing.h" #include "grib_optimize_decimal_factor.h" +#include "grib_bits_any_endian_simple.h" #include #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double;unpack_float - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_double_subarray - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=int edition - MEMBERS=const char* units_factor - MEMBERS=const char* units_bias - MEMBERS=const char* changing_precision - MEMBERS=const char* number_of_values - MEMBERS=const char* bits_per_value - MEMBERS=const char* reference_value - MEMBERS=const char* binary_scale_factor - MEMBERS=const char* decimal_scale_factor - MEMBERS=const char* optimize_scaling_factor - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); -static int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len); - -typedef struct grib_accessor_data_simple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; -} grib_accessor_data_simple_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_simple_packing = { - &grib_accessor_class_values, /* super */ - "data_simple_packing", /* name */ - sizeof(grib_accessor_data_simple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - &unpack_double_subarray, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_data_simple_packing_t _grib_accessor_class_data_simple_packing{ "data_simple_packing" }; grib_accessor_class* grib_accessor_class_data_simple_packing = &_grib_accessor_class_data_simple_packing; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long v, grib_arguments* args) +void grib_accessor_class_data_simple_packing_t::init(grib_accessor* a, const long v, grib_arguments* args) { - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); - self->units_factor = grib_arguments_get_name(gh, args, self->carg++); - self->units_bias = grib_arguments_get_name(gh, args, self->carg++); - self->changing_precision = grib_arguments_get_name(gh, args, self->carg++); - self->number_of_values = grib_arguments_get_name(gh, args, self->carg++); - self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); - self->reference_value = grib_arguments_get_name(gh, args, self->carg++); - self->binary_scale_factor = grib_arguments_get_name(gh, args, self->carg++); - self->decimal_scale_factor = grib_arguments_get_name(gh, args, self->carg++); - self->optimize_scaling_factor = grib_arguments_get_name(gh, args, self->carg++); + grib_accessor_class_values_t::init(a, v, args); + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + self->units_factor = grib_arguments_get_name(gh, args, self->carg++); + self->units_bias = grib_arguments_get_name(gh, args, self->carg++); + self->changing_precision = grib_arguments_get_name(gh, args, self->carg++); + self->number_of_values = grib_arguments_get_name(gh, args, self->carg++); + self->bits_per_value = grib_arguments_get_name(gh, args, self->carg++); + self->reference_value = grib_arguments_get_name(gh, args, self->carg++); + self->binary_scale_factor = grib_arguments_get_name(gh, args, self->carg++); + self->decimal_scale_factor = grib_arguments_get_name(gh, args, self->carg++); + self->optimize_scaling_factor = grib_arguments_get_name(gh, args, self->carg++); a->flags |= GRIB_ACCESSOR_FLAG_DATA; self->dirty = 1; } @@ -178,21 +61,21 @@ static int number_of_bits(unsigned long x, long* result) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* number_of_values) +int grib_accessor_class_data_simple_packing_t::value_count(grib_accessor* a, long* number_of_values) { - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; - *number_of_values = 0; + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + *number_of_values = 0; return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, number_of_values); } -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) +int grib_accessor_class_data_simple_packing_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) { - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; - const char* cclass_name = a->cclass->name; + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + const char* cclass_name = a->cclass->name; - long n_vals; - int err = 0; + long n_vals = 0; + int err = 0; grib_handle* gh = grib_handle_of_accessor(a); double reference_value; @@ -200,12 +83,11 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) long bits_per_value; long decimal_scale_factor; unsigned char* buf = (unsigned char*)gh->buffer->data; - double s = 0; - double d = 0; - long pos = 0; + double s = 0; + double d = 0; + long pos = 0; - n_vals = 0; - err = grib_value_count(a, &n_vals); + err = a->value_count(&n_vals); if (err) return err; @@ -237,8 +119,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) "%s: %s: creating %s, %ld values (idx=%zu)", cclass_name, __func__, a->name, n_vals, idx); - buf += grib_byte_offset(a); - + buf += a->byte_offset(); /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ if (bits_per_value % 8) { @@ -270,12 +151,12 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val) return err; } -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +int grib_accessor_class_data_simple_packing_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) { - int err = 0; + int err = 0; size_t i = 0; - for (i=0; i::value, "Requires floating point numbers"); - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; - const char* cclass_name = a->cclass->name; - grib_handle* gh = grib_handle_of_accessor(a); - unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + const char* cclass_name = a->cclass->name; + grib_handle* gh = grib_handle_of_accessor(a); + unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; size_t i = 0; int err = 0; @@ -307,7 +188,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) double units_factor = 1.0; double units_bias = 0.0; - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; n_vals = count; @@ -369,7 +250,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len) grib_context_log(a->context, GRIB_LOG_DEBUG, "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); - offsetBeforeData = grib_byte_offset(a); + offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ @@ -383,9 +264,9 @@ static int unpack(grib_accessor* a, T* val, size_t* len) const long valuesSize = (bits_per_value * n_vals) / 8; /*in bytes*/ if (offsetBeforeData + valuesSize > offsetAfterData) { grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Data section size mismatch: " - "offset before data=%ld, offset after data=%ld (num values=%zu, bits per value=%ld)", - cclass_name, offsetBeforeData, offsetAfterData, n_vals, bits_per_value); + "%s: Data section size mismatch: " + "offset before data=%ld, offset after data=%ld (num values=%zu, bits per value=%ld)", + cclass_name, offsetBeforeData, offsetAfterData, n_vals, bits_per_value); return GRIB_DECODING_ERROR; } } @@ -406,34 +287,40 @@ static int unpack(grib_accessor* a, T* val, size_t* len) *len = (long)n_vals; if (units_factor != 1.0) { - if (units_bias != 0.0) - for (i = 0; i < n_vals; i++) + if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { val[i] = val[i] * units_factor + units_bias; - else - for (i = 0; i < n_vals; i++) + } + } + else { + for (i = 0; i < n_vals; i++) { val[i] *= units_factor; + } + } } - else if (units_bias != 0.0) - for (i = 0; i < n_vals; i++) + else if (units_bias != 0.0) { + for (i = 0; i < n_vals; i++) { val[i] += units_bias; + } + } return err; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_data_simple_packing_t::unpack_double(grib_accessor* a, double* val, size_t* len) { return unpack(a, val, len); } -static int unpack_float(grib_accessor* a, float* val, size_t* len) +int grib_accessor_class_data_simple_packing_t::unpack_float(grib_accessor* a, float* val, size_t* len) { return unpack(a, val, len); } static int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned char* buf, long pos, size_t n_vals) { - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; size_t i = 0; int err = 0; @@ -505,7 +392,7 @@ static int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned c grib_context_log(a->context, GRIB_LOG_DEBUG, "%s %s: Creating %s, %zu values", cclass_name, __func__, a->name, n_vals); - offsetBeforeData = grib_byte_offset(a); + offsetBeforeData = a->byte_offset(); buf += offsetBeforeData; /*Assert(((bits_per_value*n_vals)/8) < (1<<29));*/ /* See GRIB-787 */ @@ -556,15 +443,16 @@ static int _unpack_double(grib_accessor* a, double* val, size_t* len, unsigned c return err; } -static int unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len) +int grib_accessor_class_data_simple_packing_t::unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len) { - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; - unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - size_t nvals = len; - size_t* plen = &len; - long bits_per_value = 0; - long pos; - int err; + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + + unsigned char* buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; + size_t nvals = len; + size_t* plen = &len; + long bits_per_value = 0; + long pos = 0; + int err = GRIB_SUCCESS; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) @@ -575,15 +463,15 @@ static int unpack_double_subarray(grib_accessor* a, double* val, size_t start, s return _unpack_double(a, val, plen, buf, pos, nvals); } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_data_simple_packing_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; - grib_handle* gh = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; + grib_accessor_data_simple_packing_t* self = (grib_accessor_data_simple_packing_t*)a; + grib_handle* gh = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; - size_t i = 0; - size_t n_vals = *len; - int err = 0; + size_t i = 0; + size_t n_vals = *len; + int err = 0; double reference_value = 0; long binary_scale_factor = 0; long bits_per_value = 0; @@ -628,8 +516,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) max = val[0]; min = max; for (i = 1; i < n_vals; i++) { - if (val[i] > max) max = val[i]; - else if (val[i] < min) min = val[i]; + if (val[i] > max) + max = val[i]; + else if (val[i] < min) + min = val[i]; } if ((err = grib_check_data_values_minmax(gh, min, max)) != GRIB_SUCCESS) { @@ -728,7 +618,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) /* divisor=1; */ } else { - int last = 127; /* 'last' should be a parameter coming from a definitions file */ + int last = 127; /* 'last' should be a parameter coming from a definitions file */ if (c->gribex_mode_on && self->edition == 1) last = 99; /* bits_per_value is given and decimal_scale_factor and binary_scale_factor are calcualated */ diff --git a/src/accessor/grib_accessor_class_data_simple_packing.h b/src/accessor/grib_accessor_class_data_simple_packing.h new file mode 100644 index 000000000..3e50239a0 --- /dev/null +++ b/src/accessor/grib_accessor_class_data_simple_packing.h @@ -0,0 +1,45 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_values.h" +#include "grib_scaling.h" + +class grib_accessor_data_simple_packing_t : public grib_accessor_values_t +{ +public: + /* Members defined in data_simple_packing */ + int edition; + const char* units_factor; + const char* units_bias; + const char* changing_precision; + const char* number_of_values; + const char* bits_per_value; + const char* reference_value; + const char* binary_scale_factor; + const char* decimal_scale_factor; + const char* optimize_scaling_factor; +}; + +class grib_accessor_class_data_simple_packing_t : public grib_accessor_class_values_t +{ +public: + grib_accessor_class_data_simple_packing_t(const char* name) : grib_accessor_class_values_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_data_simple_packing_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; +}; diff --git a/src/accessor/grib_accessor_class_decimal_precision.cc b/src/accessor/grib_accessor_class_decimal_precision.cc new file mode 100644 index 000000000..6149de763 --- /dev/null +++ b/src/accessor/grib_accessor_class_decimal_precision.cc @@ -0,0 +1,103 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_decimal_precision.h" + +grib_accessor_class_decimal_precision_t _grib_accessor_class_decimal_precision{"decimal_precision"}; +grib_accessor_class* grib_accessor_class_decimal_precision = &_grib_accessor_class_decimal_precision; + + +void grib_accessor_class_decimal_precision_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_long_t::init(a, l, args); + int n = 0; + grib_accessor_decimal_precision_t* self = (grib_accessor_decimal_precision_t*)a; + + self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->decimal_scale_factor = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->changing_precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_decimal_precision_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + grib_accessor_decimal_precision_t* self = (grib_accessor_decimal_precision_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(h, self->decimal_scale_factor, val)) != GRIB_SUCCESS) + return ret; + + *len = 1; + return ret; +} + +int grib_accessor_class_decimal_precision_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + long bitsPerValue = 0; + double* values = NULL; + size_t size = 0; + int ret = 0; + grib_accessor_decimal_precision_t* self = (grib_accessor_decimal_precision_t*)a; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (!self->values) { + if ((ret = grib_set_long_internal(h, self->bits_per_value, 0)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_set_long_internal(h, self->decimal_scale_factor, *val)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_set_long_internal(h, self->changing_precision, 1)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + return GRIB_SUCCESS; + } + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_buffer_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->decimal_scale_factor, *val)) != GRIB_SUCCESS) { + grib_context_buffer_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->bits_per_value, bitsPerValue)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->changing_precision, 1)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_buffer_free(c, values); + return ret; + } + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_decimal_precision.h b/src/accessor/grib_accessor_class_decimal_precision.h new file mode 100644 index 000000000..a6b6d4839 --- /dev/null +++ b/src/accessor/grib_accessor_class_decimal_precision.h @@ -0,0 +1,33 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_decimal_precision_t : public grib_accessor_long_t +{ +public: + /* Members defined in decimal_precision */ + const char* values; + const char* bits_per_value; + const char* changing_precision; + const char* decimal_scale_factor; +}; + +class grib_accessor_class_decimal_precision_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_decimal_precision_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_decimal_precision_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_dictionary.cc b/src/accessor/grib_accessor_class_dictionary.cc similarity index 61% rename from src/grib_accessor_class_dictionary.cc rename to src/accessor/grib_accessor_class_dictionary.cc index dde22abdc..9a0b3307d 100644 --- a/src/grib_accessor_class_dictionary.cc +++ b/src/accessor/grib_accessor_class_dictionary.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,114 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump;unpack_string;unpack_long;unpack_double - IMPLEMENTS = value_count; get_native_type; - MEMBERS = const char* dictionary - MEMBERS = const char* key - MEMBERS = long column - MEMBERS = const char* masterDir - MEMBERS = const char* localDir - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_dictionary -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in dictionary */ - const char* dictionary; - const char* key; - long column; - const char* masterDir; - const char* localDir; -} grib_accessor_dictionary; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_dictionary = { - &grib_accessor_class_gen, /* super */ - "dictionary", /* name */ - sizeof(grib_accessor_dictionary), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_dictionary.h" +grib_accessor_class_dictionary_t _grib_accessor_class_dictionary{"dictionary"}; grib_accessor_class* grib_accessor_class_dictionary = &_grib_accessor_class_dictionary; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ +void grib_accessor_class_dictionary_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); int n = 0; - grib_accessor_dictionary* self = (grib_accessor_dictionary*)a; + grib_accessor_dictionary_t* self = (grib_accessor_dictionary_t*)a; self->dictionary = grib_arguments_get_string(grib_handle_of_accessor(a), params, n++); self->key = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); @@ -129,7 +32,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) static grib_trie* load_dictionary(grib_accessor* a, int* err) { - grib_accessor_dictionary* self = (grib_accessor_dictionary*)a; + grib_accessor_dictionary_t* self = (grib_accessor_dictionary_t*)a; char* filename = NULL; char line[1024] = {0,}; @@ -243,8 +146,7 @@ static grib_trie* load_dictionary(grib_accessor* a, int* err) return dictionary; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_dictionary_t::dump(grib_accessor* a, grib_dumper* dumper){ switch (get_native_type(a)) { case GRIB_TYPE_STRING: grib_dump_string(dumper, a, NULL); @@ -258,9 +160,8 @@ static void dump(grib_accessor* a, grib_dumper* dumper) } } -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_dictionary* self = (grib_accessor_dictionary*)a; +int grib_accessor_class_dictionary_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ + grib_accessor_dictionary_t* self = (grib_accessor_dictionary_t*)a; int err = GRIB_SUCCESS; char key[1024] = {0,}; size_t size = 1024; @@ -313,14 +214,12 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) return err; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_dictionary_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_dictionary_t::get_native_type(grib_accessor* a){ int type = GRIB_TYPE_DOUBLE; if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) type = GRIB_TYPE_LONG; @@ -329,8 +228,7 @@ static int get_native_type(grib_accessor* a) return type; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_dictionary_t::unpack_long(grib_accessor* a, long* val, size_t* len){ int err = 0; char buffer[1024] = {0,}; size_t size = 1024; @@ -345,8 +243,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_dictionary_t::unpack_double(grib_accessor* a, double* val, size_t* len){ int err = 0; char buffer[1024] = {0,}; size_t size = 1024; diff --git a/src/accessor/grib_accessor_class_dictionary.h b/src/accessor/grib_accessor_class_dictionary.h new file mode 100644 index 000000000..8dc976e51 --- /dev/null +++ b/src/accessor/grib_accessor_class_dictionary.h @@ -0,0 +1,38 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_dictionary_t : public grib_accessor_gen_t +{ +public: + /* Members defined in dictionary */ + const char* dictionary; + const char* key; + long column; + const char* masterDir; + const char* localDir; +}; + +class grib_accessor_class_dictionary_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_dictionary_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_dictionary_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_dirty.cc b/src/accessor/grib_accessor_class_dirty.cc new file mode 100644 index 000000000..73f11c9d7 --- /dev/null +++ b/src/accessor/grib_accessor_class_dirty.cc @@ -0,0 +1,50 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_dirty.h" + +grib_accessor_class_dirty_t _grib_accessor_class_dirty{ "dirty" }; +grib_accessor_class* grib_accessor_class_dirty = &_grib_accessor_class_dirty; + + +void grib_accessor_class_dirty_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; + self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->length = 0; +} + +int grib_accessor_class_dirty_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; + grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); + + if (x) + x->dirty = *val; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_dirty_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; + grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); + + if (x) + x->dirty = 1; + + *val = 1; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_dirty.h b/src/accessor/grib_accessor_class_dirty.h new file mode 100644 index 000000000..b024b69f7 --- /dev/null +++ b/src/accessor/grib_accessor_class_dirty.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_dirty_t : public grib_accessor_long_t +{ +public: + /* Members defined in dirty */ + const char* accessor; +}; + +class grib_accessor_class_dirty_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_dirty_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_dirty_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_divdouble.cc b/src/accessor/grib_accessor_class_divdouble.cc new file mode 100644 index 000000000..a652752fa --- /dev/null +++ b/src/accessor/grib_accessor_class_divdouble.cc @@ -0,0 +1,43 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_divdouble.h" + +grib_accessor_class_divdouble_t _grib_accessor_class_divdouble{"divdouble"}; +grib_accessor_class* grib_accessor_class_divdouble = &_grib_accessor_class_divdouble; + + +void grib_accessor_class_divdouble_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_divdouble_t* self = (grib_accessor_divdouble_t*)a; + int n = 0; + + self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->divisor = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_divdouble_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + const grib_accessor_divdouble_t* self = (grib_accessor_divdouble_t*)a; + int ret = GRIB_SUCCESS; + double value = 0; + + ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value); + if (ret != GRIB_SUCCESS) + return ret; + + if (self->divisor == 0) { + return GRIB_INVALID_ARGUMENT; + } + *val = value / self->divisor; + + *len = 1; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_divdouble.h b/src/accessor/grib_accessor_class_divdouble.h new file mode 100644 index 000000000..9408b073a --- /dev/null +++ b/src/accessor/grib_accessor_class_divdouble.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_divdouble_t : public grib_accessor_double_t +{ +public: + /* Members defined in divdouble */ + const char* val; + double divisor; +}; + +class grib_accessor_class_divdouble_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_divdouble_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_divdouble_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_double.cc b/src/accessor/grib_accessor_class_double.cc new file mode 100644 index 000000000..a0e3a49b5 --- /dev/null +++ b/src/accessor/grib_accessor_class_double.cc @@ -0,0 +1,105 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_double.h" + +grib_accessor_class_double_t _grib_accessor_class_double{"double"}; +grib_accessor_class* grib_accessor_class_double = &_grib_accessor_class_double; + + +int grib_accessor_class_double_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} + +int grib_accessor_class_double_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + double val = 0; + size_t l = 1; + char repres[1024]; + char format[32] = "%g"; + grib_handle* h = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + + a->unpack_double(&val, &l); + if ((val == GRIB_MISSING_DOUBLE) && ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0)) { + snprintf(repres, sizeof(repres), "MISSING"); + } else { + size_t size = sizeof(format); + grib_get_string(h, "formatForDoubles", format, &size); + snprintf(repres, sizeof(repres), format, val); + } + + l = strlen(repres) + 1; + + if (l > *len) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_long: Casting double %s to string ", a->name); + + *len = l; + + strcpy(v, repres); + return GRIB_SUCCESS; +} + +void grib_accessor_class_double_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_values(dumper, a); +} + +int grib_accessor_class_double_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = 0; + double* aval = 0; + double* bval = 0; + + size_t alen = 0; + size_t blen = 0; + long count = 0; + int err = 0; + + err = a->value_count(&count); if (err) + return err; + alen = count; + + err = b->value_count(&count); if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + retval = GRIB_SUCCESS; + while (alen != 0) { + if (*bval != *aval) + retval = GRIB_DOUBLE_VALUE_MISMATCH; + alen--; + } + + grib_context_free(a->context, aval); + grib_context_free(b->context, bval); + + return retval; +} + +int grib_accessor_class_double_t::pack_missing(grib_accessor* a){ + size_t len = 1; + double value = GRIB_MISSING_DOUBLE; + + if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) + return a->pack_double(&value, &len); + return GRIB_VALUE_CANNOT_BE_MISSING; +} diff --git a/src/accessor/grib_accessor_class_double.h b/src/accessor/grib_accessor_class_double.h new file mode 100644 index 000000000..7ad9771c2 --- /dev/null +++ b/src/accessor/grib_accessor_class_double.h @@ -0,0 +1,27 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_double_t : public grib_accessor_gen_t {}; + +class grib_accessor_class_double_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_double_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_double_t{}; } + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/grib_accessor_class_element.cc b/src/accessor/grib_accessor_class_element.cc similarity index 56% rename from src/grib_accessor_class_element.cc rename to src/accessor/grib_accessor_class_element.cc index 2041cd62d..3d150d79e 100644 --- a/src/grib_accessor_class_element.cc +++ b/src/accessor/grib_accessor_class_element.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,105 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long; - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS=const char* array - MEMBERS=long element - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_element -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in element */ - const char* array; - long element; -} grib_accessor_element; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_element = { - &grib_accessor_class_long, /* super */ - "element", /* name */ - sizeof(grib_accessor_element), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_element.h" +grib_accessor_class_element_t _grib_accessor_class_element{"element"}; grib_accessor_class* grib_accessor_class_element = &_grib_accessor_class_element; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) +void grib_accessor_class_element_t::init(grib_accessor* a, const long l, grib_arguments* c) { - grib_accessor_element* self = (grib_accessor_element*)a; + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_element_t* self = (grib_accessor_element_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -125,9 +37,9 @@ static int check_element_index(const char* func, const char* array_name, long in return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_element_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_element* self = (grib_accessor_element*)a; + grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; long* ar = NULL; @@ -168,9 +80,9 @@ the_end: return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_element_t::pack_long(grib_accessor* a, const long* val, size_t* len) { - grib_accessor_element* self = (grib_accessor_element*)a; + grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; long* ar = NULL; @@ -216,9 +128,9 @@ the_end: return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_element_t::unpack_double(grib_accessor* a, double* val, size_t* len) { - grib_accessor_element* self = (grib_accessor_element*)a; + grib_accessor_element_t* self = (grib_accessor_element_t*)a; int ret = 0; size_t size = 0; double* ar = NULL; diff --git a/src/accessor/grib_accessor_class_element.h b/src/accessor/grib_accessor_class_element.h new file mode 100644 index 000000000..220b8ff84 --- /dev/null +++ b/src/accessor/grib_accessor_class_element.h @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_element_t : public grib_accessor_long_t +{ +public: + /* Members defined in element */ + const char* array; + long element; +}; + +class grib_accessor_class_element_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_element_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_element_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_evaluate.cc b/src/accessor/grib_accessor_class_evaluate.cc new file mode 100644 index 000000000..0312107a4 --- /dev/null +++ b/src/accessor/grib_accessor_class_evaluate.cc @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_evaluate.h" + +grib_accessor_class_evaluate_t _grib_accessor_class_evaluate{ "evaluate" }; +grib_accessor_class* grib_accessor_class_evaluate = &_grib_accessor_class_evaluate; + + +void grib_accessor_class_evaluate_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; + self->arg = c; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_evaluate_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; + grib_expression* e = grib_arguments_get_expression(grib_handle_of_accessor(a), self->arg, 0); + + int ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), e, val); + *len = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_evaluate.h b/src/accessor/grib_accessor_class_evaluate.h new file mode 100644 index 000000000..0e40cf206 --- /dev/null +++ b/src/accessor/grib_accessor_class_evaluate.h @@ -0,0 +1,29 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_evaluate_t : public grib_accessor_long_t +{ +public: + /* Members defined in evaluate */ + grib_arguments* arg; +}; + +class grib_accessor_class_evaluate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_evaluate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_evaluate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc similarity index 77% rename from src/grib_accessor_class_expanded_descriptors.cc rename to src/accessor/grib_accessor_class_expanded_descriptors.cc index d515e4dcb..b30e745a9 100644 --- a/src/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -1,138 +1,20 @@ + /* -* (C) Copyright 2005- ECMWF. -* -* This software is licensed under the terms of the Apache Licence Version 2.0 -* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -* -* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by -* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. -*/ - -/* Sequences and replication (not delayed) are resolved in this class. - Number of elements to which a delayed replication applies are recomputed to - take account of the expansion. - Expanded descriptors cannot contain sequences and only delayed replication - can appear -*/ + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ +#include "grib_accessor_class_expanded_descriptors.h" #include "grib_scaling.h" -#include "grib_api_internal.h" -/* -This is used by make_class.pl - -START_CLASS_DEF -CLASS = accessor -SUPER = grib_accessor_class_long -IMPLEMENTS = unpack_long;pack_long -IMPLEMENTS = unpack_double -IMPLEMENTS = unpack_string_array -IMPLEMENTS = init;dump;destroy -IMPLEMENTS = value_count; get_native_type -MEMBERS = const char* unexpandedDescriptors -MEMBERS = const char* sequence -MEMBERS = const char* expandedName -MEMBERS = const char* tablesAccessorName -MEMBERS = bufr_descriptors_array* expanded -MEMBERS = int rank -MEMBERS = grib_accessor* expandedAccessor -MEMBERS = int do_expand -MEMBERS = grib_accessor* tablesAccessor - -END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_expanded_descriptors -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in expanded_descriptors */ - const char* unexpandedDescriptors; - const char* sequence; - const char* expandedName; - const char* tablesAccessorName; - bufr_descriptors_array* expanded; - int rank; - grib_accessor* expandedAccessor; - int do_expand; - grib_accessor* tablesAccessor; -} grib_accessor_expanded_descriptors; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_expanded_descriptors = { - &grib_accessor_class_long, /* super */ - "expanded_descriptors", /* name */ - sizeof(grib_accessor_expanded_descriptors), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_expanded_descriptors_t _grib_accessor_class_expanded_descriptors{"expanded_descriptors"}; grib_accessor_class* grib_accessor_class_expanded_descriptors = &_grib_accessor_class_expanded_descriptors; -/* END_CLASS_IMP */ #define MYDEBUG 0 #define DESC_SIZE_INIT 400 /* Initial size for grib_bufr_descriptors_array_new */ @@ -159,14 +41,15 @@ typedef struct change_coding_params result = grib_bufr_descriptors_array_pop_front(array); \ } -static void init(grib_accessor* a, const long len, grib_arguments* args) +void grib_accessor_class_expanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - self->tablesAccessorName = grib_arguments_get_name(hand, args, n++); - self->expandedName = grib_arguments_get_name(hand, args, n++); - self->rank = grib_arguments_get_long(hand, args, n++); + grib_accessor_class_long_t::init(a, len, args); + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + self->tablesAccessorName = grib_arguments_get_name(hand, args, n++); + self->expandedName = grib_arguments_get_name(hand, args, n++); + self->rank = grib_arguments_get_long(hand, args, n++); if (self->rank != 0) { self->expandedAccessor = grib_find_accessor(hand, self->expandedName); } @@ -180,11 +63,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_array* unexpanded, change_coding_params* ccp, int* err); #define BUFR_DESCRIPTORS_ARRAY_USED_SIZE(v) ((v)->n) @@ -214,7 +92,7 @@ static char* descriptor_type_name(int dtype) static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_descriptors_array* expanded, change_coding_params* ccp, int* err) { int k, j, i; - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; size_t size = 0; long* v_array = NULL; bufr_descriptor* u = NULL; @@ -237,7 +115,7 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_ if (BUFR_DESCRIPTORS_ARRAY_USED_SIZE(unexpanded) == 0) return; - us = grib_bufr_descriptor_clone(grib_bufr_descriptors_array_get(unexpanded, 0)); + us = grib_bufr_descriptor_clone(grib_bufr_descriptors_array_get(unexpanded, 0)); us->context = c; *err = 0; @@ -268,7 +146,7 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_ inner_unexpanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR); for (i = 0; i < size; i++) { - vv = grib_bufr_descriptor_new(self->tablesAccessor, v_array[i], !SILENT, err); + vv = grib_bufr_descriptor_new(self->tablesAccessor, v_array[i], !SILENT, err); inner_unexpanded = grib_bufr_descriptors_array_push(inner_unexpanded, vv); } grib_context_free(c, v_array); @@ -589,7 +467,7 @@ static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_arra static int expand(grib_accessor* a) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; int err = 0; size_t unexpandedSize = 0; /* grib_iarray* unexp=0; */ @@ -611,7 +489,7 @@ static int expand(grib_accessor* a) self->do_expand = 0; if (self->rank != 0) { err = expand(self->expandedAccessor); - self->expanded = ((grib_accessor_expanded_descriptors*)self->expandedAccessor)->expanded; + self->expanded = ((grib_accessor_expanded_descriptors_t*)self->expandedAccessor)->expanded; return err; } @@ -712,28 +590,28 @@ static int expand(grib_accessor* a) int grib_accessor_class_expanded_descriptors_set_do_expand(grib_accessor* a, long do_expand) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; - self->do_expand = do_expand; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; + self->do_expand = do_expand; return 0; } bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(grib_accessor* a, int* err) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; - *err = expand(a); + const grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; + *err = expand(a); return self->expanded; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_expanded_descriptors_t::unpack_double(grib_accessor* a, double* val, size_t* len) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; - int ret = 0; - int i; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; + int ret = 0; + size_t i = 0; size_t expandedSize; if (self->rank != 2) { long* lval = (long*)grib_context_malloc_clear(a->context, *len * sizeof(long)); - ret = unpack_long(a, lval, len); + ret = unpack_long(a, lval, len); if (ret) return ret; for (i = 0; i < *len; i++) @@ -759,12 +637,12 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_expanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; - int ret = 0; - size_t rlen = 0; - size_t i; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; + int ret = 0; + size_t rlen = 0; + size_t i = 0; ret = expand(a); if (ret) @@ -792,7 +670,6 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) break; case 2: return GRIB_INVALID_TYPE; - break; case 3: for (i = 0; i < *len; i++) val[i] = self->expanded->v[i]->width; @@ -806,7 +683,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +int grib_accessor_class_expanded_descriptors_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) { int err = 0; long* v = NULL; @@ -815,13 +692,11 @@ static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) size_t i = 0, size = 0; const grib_context* c = a->context; - err = grib_value_count(a, &llen); - if (err) return err; + err = a->value_count(&llen); if (err) return err; size = llen; v = (long*)grib_context_malloc_clear(c, sizeof(long) * size); - err = grib_unpack_long(a, v, &size); - if (err) return err; + err = a->unpack_long(v, &size); if (err) return err; for (i = 0; i < size; i++) { snprintf(buf, sizeof(buf), "%06ld", v[i]); @@ -833,18 +708,18 @@ static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) return GRIB_NOT_IMPLEMENTED; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_expanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; - self->do_expand = 1; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; + self->do_expand = 1; return GRIB_NOT_IMPLEMENTED; } -static int value_count(grib_accessor* a, long* rlen) +int grib_accessor_class_expanded_descriptors_t::value_count(grib_accessor* a, long* rlen) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; - int err = 0; - *rlen = 0; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; + int err = 0; + *rlen = 0; err = expand(a); if (err) { @@ -856,16 +731,17 @@ static int value_count(grib_accessor* a, long* rlen) return err; } -static void destroy(grib_context* c, grib_accessor* a) +void grib_accessor_class_expanded_descriptors_t::destroy(grib_context* c, grib_accessor* a) { - // grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + grib_accessor_class_long_t::destroy(c, a); + // grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; // if (self->rank==0 && self->expanded) // grib_bufr_descriptors_array_delete(self->expanded); } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_expanded_descriptors_t::get_native_type(grib_accessor* a) { - grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a; + grib_accessor_expanded_descriptors_t* self = (grib_accessor_expanded_descriptors_t*)a; if (self->rank == 2) return GRIB_TYPE_DOUBLE; else diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.h b/src/accessor/grib_accessor_class_expanded_descriptors.h new file mode 100644 index 000000000..7e42ad28c --- /dev/null +++ b/src/accessor/grib_accessor_class_expanded_descriptors.h @@ -0,0 +1,43 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_expanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in expanded_descriptors */ + const char* unexpandedDescriptors; + const char* sequence; + const char* expandedName; + const char* tablesAccessorName; + bufr_descriptors_array* expanded; + int rank; + grib_accessor* expandedAccessor; + int do_expand; + grib_accessor* tablesAccessor; +}; + +class grib_accessor_class_expanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_expanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_expanded_descriptors_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_from_scale_factor_scaled_value.cc b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc similarity index 59% rename from src/grib_accessor_class_from_scale_factor_scaled_value.cc rename to src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc index 53784e172..4168e1476 100644 --- a/src/grib_accessor_class_from_scale_factor_scaled_value.cc +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,111 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -#include -#ifdef ECCODES_ON_WINDOWS - #include -#endif - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double;is_missing - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS=const char* scaleFactor - MEMBERS=const char* scaledValue - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_from_scale_factor_scaled_value -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in from_scale_factor_scaled_value */ - const char* scaleFactor; - const char* scaledValue; -} grib_accessor_from_scale_factor_scaled_value; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_from_scale_factor_scaled_value = { - &grib_accessor_class_double, /* super */ - "from_scale_factor_scaled_value", /* name */ - sizeof(grib_accessor_from_scale_factor_scaled_value), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_from_scale_factor_scaled_value.h" +grib_accessor_class_from_scale_factor_scaled_value_t _grib_accessor_class_from_scale_factor_scaled_value{"from_scale_factor_scaled_value"}; grib_accessor_class* grib_accessor_class_from_scale_factor_scaled_value = &_grib_accessor_class_from_scale_factor_scaled_value; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; +void grib_accessor_class_from_scale_factor_scaled_value_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -123,11 +28,10 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) // a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ +int grib_accessor_class_from_scale_factor_scaled_value_t::pack_double(grib_accessor* a, const double* val, size_t* len){ // See ECC-979 and ECC-1416 // Evaluate self->scaleFactor and self->scaledValue from input double '*val' - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; int64_t factor = 0; @@ -181,9 +85,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; +int grib_accessor_class_from_scale_factor_scaled_value_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; int err = 0; long scaleFactor = 0, scaledValue = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -257,9 +160,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return err; } -static int is_missing(grib_accessor* a) -{ - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; +int grib_accessor_class_from_scale_factor_scaled_value_t::is_missing(grib_accessor* a){ + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int err = 0; long scaleFactor = 0, scaledValue = 0; @@ -273,9 +175,8 @@ static int is_missing(grib_accessor* a) return ((scaleFactor == GRIB_MISSING_LONG) || (scaledValue == GRIB_MISSING_LONG)); } -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_from_scale_factor_scaled_value* self = (grib_accessor_from_scale_factor_scaled_value*)a; +int grib_accessor_class_from_scale_factor_scaled_value_t::value_count(grib_accessor* a, long* len){ + grib_accessor_from_scale_factor_scaled_value_t* self = (grib_accessor_from_scale_factor_scaled_value_t*)a; int err = 0; grib_handle* hand = grib_handle_of_accessor(a); size_t vsize; diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h new file mode 100644 index 000000000..d8dc1bcb8 --- /dev/null +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_from_scale_factor_scaled_value_t : public grib_accessor_double_t +{ +public: + /* Members defined in from_scale_factor_scaled_value */ + const char* scaleFactor; + const char* scaledValue; +}; + +class grib_accessor_class_from_scale_factor_scaled_value_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_from_scale_factor_scaled_value_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_from_scale_factor_scaled_value_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc new file mode 100644 index 000000000..2f757addc --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.cc @@ -0,0 +1,60 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1_half_byte_codeflag.h" + +grib_accessor_class_g1_half_byte_codeflag_t _grib_accessor_class_g1_half_byte_codeflag{"g1_half_byte_codeflag"}; +grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag = &_grib_accessor_class_g1_half_byte_codeflag; + + +void grib_accessor_class_g1_half_byte_codeflag_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; +} + +void grib_accessor_class_g1_half_byte_codeflag_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_g1_half_byte_codeflag_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + unsigned char dat = 0; + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + dat = grib_handle_of_accessor(a)->buffer->data[a->offset] & 0x0f; + + *val = dat; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_g1_half_byte_codeflag_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int ret = 0; + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + /* printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]);*/ + grib_handle_of_accessor(a)->buffer->data[a->offset] = (a->parent->h->buffer->data[a->offset] & 0xf0) | (*val & 0x0f); + /* printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]);*/ + + *len = 1; + return ret; +} + +int grib_accessor_class_g1_half_byte_codeflag_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h new file mode 100644 index 000000000..662a75569 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_half_byte_codeflag.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_g1_half_byte_codeflag_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g1_half_byte_codeflag */ +}; + +class grib_accessor_class_g1_half_byte_codeflag_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g1_half_byte_codeflag_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_half_byte_codeflag_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_g1_message_length.cc b/src/accessor/grib_accessor_class_g1_message_length.cc similarity index 53% rename from src/grib_accessor_class_g1_message_length.cc rename to src/accessor/grib_accessor_class_g1_message_length.cc index 1d38e7ea4..89ce742c5 100644 --- a/src/grib_accessor_class_g1_message_length.cc +++ b/src/accessor/grib_accessor_class_g1_message_length.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,104 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_section_length - IMPLEMENTS = init;unpack_long;pack_long - MEMBERS = const char *sec4_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1_message_length -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in section_length */ - /* Members defined in g1_message_length */ - const char *sec4_length; -} grib_accessor_g1_message_length; - -extern grib_accessor_class* grib_accessor_class_section_length; - -static grib_accessor_class _grib_accessor_class_g1_message_length = { - &grib_accessor_class_section_length, /* super */ - "g1_message_length", /* name */ - sizeof(grib_accessor_g1_message_length), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g1_message_length.h" +grib_accessor_class_g1_message_length_t _grib_accessor_class_g1_message_length{"g1_message_length"}; grib_accessor_class* grib_accessor_class_g1_message_length = &_grib_accessor_class_g1_message_length; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_g1_message_length* self = (grib_accessor_g1_message_length*)a; +void grib_accessor_class_g1_message_length_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_section_length_t::init(a, len, args); + grib_accessor_g1_message_length_t* self = (grib_accessor_g1_message_length_t*)a; self->sec4_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); } @@ -148,9 +60,8 @@ int grib_get_g1_message_size(grib_handle* h, grib_accessor* tl, grib_accessor* s return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g1_message_length* self = (grib_accessor_g1_message_length*)a; +int grib_accessor_class_g1_message_length_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g1_message_length_t* self = (grib_accessor_g1_message_length_t*)a; /*grib_accessor_class* super = *(a->cclass->super);*/ /* Here we assume that the totalLength will be coded AFTER the section4 length, and @@ -182,7 +93,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) tlen = 0x800000 | t120; *len = 1; - if ((ret = grib_pack_long(s4, &slen, len)) != GRIB_SUCCESS) + if ((ret = s4->pack_long(&slen, len)) != GRIB_SUCCESS) return ret; *len = 1; @@ -211,9 +122,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1_message_length* self = (grib_accessor_g1_message_length*)a; +int grib_accessor_class_g1_message_length_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1_message_length_t* self = (grib_accessor_g1_message_length_t*)a; int ret; long total_length, sec4_length; diff --git a/src/accessor/grib_accessor_class_g1_message_length.h b/src/accessor/grib_accessor_class_g1_message_length.h new file mode 100644 index 000000000..9a24e3213 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_message_length.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_section_length.h" + +class grib_accessor_g1_message_length_t : public grib_accessor_section_length_t +{ +public: + /* Members defined in g1_message_length */ + const char *sec4_length; +}; + +class grib_accessor_class_g1_message_length_t : public grib_accessor_class_section_length_t +{ +public: + grib_accessor_class_g1_message_length_t(const char* name) : grib_accessor_class_section_length_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_message_length_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1_section4_length.cc b/src/accessor/grib_accessor_class_g1_section4_length.cc new file mode 100644 index 000000000..8eea656b0 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_section4_length.cc @@ -0,0 +1,53 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1_section4_length.h" + +grib_accessor_class_g1_section4_length_t _grib_accessor_class_g1_section4_length{"g1_section4_length"}; +grib_accessor_class* grib_accessor_class_g1_section4_length = &_grib_accessor_class_g1_section4_length; + + +void grib_accessor_class_g1_section4_length_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_section_length_t::init(a, len, args); + grib_accessor_g1_section4_length_t* self = (grib_accessor_g1_section4_length_t*)a; + self->total_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); +} + +int grib_accessor_class_g1_section4_length_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + // Old implementation: + // Here we assume that the totalLength will be coded AFTER the section4 length, and + // the section4 length will be overwritten by the totalLength accessor for large GRIBs + // grib_accessor_class* super = *(a->cclass->super); + // return super->pack_long(a,val,len); + + // Note: Do not directly call pack_long on base class + // because in this special case we want to skip the checks. + // So we call the helper function which has an extra argument + return pack_long_unsigned_helper(a, val, len, /*check=*/0); +} + +int grib_accessor_class_g1_section4_length_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1_section4_length_t* self = (grib_accessor_g1_section4_length_t*)a; + int ret = 0; + long total_length = 0, sec4_length = 0; + + if ((ret = grib_get_g1_message_size(grib_handle_of_accessor(a), + grib_find_accessor(grib_handle_of_accessor(a), self->total_length), + a, + &total_length, + &sec4_length)) != GRIB_SUCCESS) { + return ret; + } + + *val = sec4_length; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1_section4_length.h b/src/accessor/grib_accessor_class_g1_section4_length.h new file mode 100644 index 000000000..9e805985c --- /dev/null +++ b/src/accessor/grib_accessor_class_g1_section4_length.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_section_length.h" + +class grib_accessor_g1_section4_length_t : public grib_accessor_section_length_t +{ +public: + /* Members defined in g1_section4_length */ + const char* total_length; +}; + +class grib_accessor_class_g1_section4_length_t : public grib_accessor_class_section_length_t +{ +public: + grib_accessor_class_g1_section4_length_t(const char* name) : grib_accessor_class_section_length_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1_section4_length_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1bitmap.cc b/src/accessor/grib_accessor_class_g1bitmap.cc new file mode 100644 index 000000000..e8c0645ad --- /dev/null +++ b/src/accessor/grib_accessor_class_g1bitmap.cc @@ -0,0 +1,98 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1bitmap.h" +#include "shared_functions.h" + +grib_accessor_class_g1bitmap_t _grib_accessor_class_g1bitmap{"g1bitmap"}; +grib_accessor_class* grib_accessor_class_g1bitmap = &_grib_accessor_class_g1bitmap; + + +void grib_accessor_class_g1bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bitmap_t::init(a, len, arg); + grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; + self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); +} + +int grib_accessor_class_g1bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; + size_t tlen; + + unsigned char* buf = NULL; + size_t i; + int err = 0; + long pos = 0; + //long bmaplen = 0; + const int bit_padding = 16; + double miss_values = 0; + tlen = ((*len + bit_padding - 1) / bit_padding * bit_padding) / 8; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &miss_values)) != GRIB_SUCCESS) + return err; + + buf = (unsigned char*)grib_context_malloc_clear(a->context, tlen); + if (!buf) + return GRIB_OUT_OF_MEMORY; + pos = 0; + for (i = 0; i < *len; i++) { + if (val[i] == miss_values) + pos++; + else { + //bmaplen++; + grib_set_bit_on(buf, &pos); + } + } + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->unusedBits, tlen * 8 - *len)) != GRIB_SUCCESS) + return err; + + err = grib_buffer_replace(a, buf, tlen, 1, 1); + if (err) return err; + + grib_context_free(a->context, buf); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g1bitmap_t::value_count(grib_accessor* a, long* count){ + grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; + long tlen; + int err; + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &tlen)) != GRIB_SUCCESS) + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap.value_count : cannot get %s err=%d", self->unusedBits, err); + + *count = (a->length * 8) - tlen; + return err; +} + +int grib_accessor_class_g1bitmap_t::unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len){ + unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; + grib_accessor_g1bitmap_t* self = (grib_accessor_g1bitmap_t*)a; + long tlen; + int err; + long length = a->byte_count(); long offset = a->byte_offset(); + if (*len < (size_t)length) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %ld bytes long\n", a->name, length); + *len = length; + return GRIB_ARRAY_TOO_SMALL; + } + + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &tlen)) != GRIB_SUCCESS) + grib_context_log(a->context, GRIB_LOG_ERROR, + "grib_accessor_class_bitmap.unpack_bytes : cannot get %s err=%d", self->unusedBits, err); + + length -= tlen / 8; + memcpy(val, buf + offset, length); + *len = length; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1bitmap.h b/src/accessor/grib_accessor_class_g1bitmap.h new file mode 100644 index 000000000..28914c591 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1bitmap.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_bitmap.h" + +class grib_accessor_g1bitmap_t : public grib_accessor_bitmap_t +{ +public: + /* Members defined in g1bitmap */ + const char* unusedBits; +}; + +class grib_accessor_class_g1bitmap_t : public grib_accessor_class_bitmap_t +{ +public: + grib_accessor_class_g1bitmap_t(const char* name) : grib_accessor_class_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1date.cc b/src/accessor/grib_accessor_class_g1date.cc new file mode 100644 index 000000000..64631a1ea --- /dev/null +++ b/src/accessor/grib_accessor_class_g1date.cc @@ -0,0 +1,165 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1date.h" + +grib_accessor_class_g1date_t _grib_accessor_class_g1date{"g1date"}; +grib_accessor_class* grib_accessor_class_g1date = &_grib_accessor_class_g1date; + + +void grib_accessor_class_g1date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->century = grib_arguments_get_name(hand, c, n++); + self->year = grib_arguments_get_name(hand, c, n++); + self->month = grib_arguments_get_name(hand, c, n++); + self->day = grib_arguments_get_name(hand, c, n++); +} + +int grib_accessor_class_g1date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + int ret = 0; + long year = 0, century = 0, month = 0, day = 0; + + if ((ret = grib_get_long_internal(hand, self->century, ¢ury)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->day, &day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->month, &month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->year, &year)) != GRIB_SUCCESS) + return ret; + + if (*len < 1) + return GRIB_WRONG_ARRAY_SIZE; + + *val = ((century - 1) * 100 + year) * 10000 + month * 100 + day; + + if (year == 255 && day == 255 && month >= 1 && month <= 12) { + *val = month; + } + + if (year == 255 && day != 255 && month >= 1 && month <= 12) { + *val = month * 100 + day; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g1date_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + int ret = 0; + long v = val[0]; + long year = 0, century = 0, month = 0, day = 0; + + if (*len != 1) + return GRIB_WRONG_ARRAY_SIZE; + + long d = grib_julian_to_date(grib_date_to_julian(v)); + if (v != d) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g1date_t: pack_long invalid date %ld, changed to %ld", v, d); + return GRIB_ENCODING_ERROR; + } + + century = v / 1000000; + v %= 1000000; + year = v / 10000; + v %= 10000; + month = v / 100; + v %= 100; + day = v; + + if (year == 0) + year = 100; + else + century++; + + if ((ret = grib_set_long_internal(hand, self->century, century)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(hand, self->day, day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(hand, self->month, month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(hand, self->year, year)) != GRIB_SUCCESS) + return ret; + + return GRIB_SUCCESS; +} + +static const char* months[] = { + "jan", + "feb", + "mar", + "apr", + "may", + "jun", + "jul", + "aug", + "sep", + "oct", + "nov", + "dec", +}; + +int grib_accessor_class_g1date_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_g1date_t* self = (grib_accessor_g1date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + int ret = 0; + char tmp[1024]; + long year = 0, century = 0, month = 0, day = 0; + + if ((ret = grib_get_long_internal(hand, self->century, ¢ury)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->day, &day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->month, &month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->year, &year)) != GRIB_SUCCESS) + return ret; + + if (*len < 1) + return GRIB_WRONG_ARRAY_SIZE; + + if (year == 255 && day == 255 && month >= 1 && month <= 12) { + strcpy(tmp, months[month - 1]); + } + else if (year == 255 && month >= 1 && month <= 12) { + snprintf(tmp, sizeof(tmp), "%s-%02ld", months[month - 1], day); + } + else { + long x = ((century - 1) * 100 + year) * 10000 + month * 100 + day; + snprintf(tmp, sizeof(tmp), "%ld", x); + } + + size_t l = strlen(tmp) + 1; + if (*len < l) { + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + *len = l; + strcpy(val, tmp); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g1date_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_g1date.h b/src/accessor/grib_accessor_class_g1date.h new file mode 100644 index 000000000..1195ac01c --- /dev/null +++ b/src/accessor/grib_accessor_class_g1date.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g1date_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1date */ + const char* century; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_g1date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc b/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc new file mode 100644 index 000000000..83d23ea92 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.cc @@ -0,0 +1,60 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1day_of_the_year_date.h" + +grib_accessor_class_g1day_of_the_year_date_t _grib_accessor_class_g1day_of_the_year_date{"g1day_of_the_year_date"}; +grib_accessor_class* grib_accessor_class_g1day_of_the_year_date = &_grib_accessor_class_g1day_of_the_year_date; + + + +void grib_accessor_class_g1day_of_the_year_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_g1date_t::init(a, l, c); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_g1day_of_the_year_date_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_g1day_of_the_year_date_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + /* special clim case where each mont have 30 days.. to comply with mars*/ + grib_accessor_g1day_of_the_year_date_t* self = (grib_accessor_g1day_of_the_year_date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + char tmp[1024]; + + long year = 0; + long century = 0; + long month = 0; + long day = 0; + long fullyear = 0; + long fake_day_of_year = 0; + + grib_get_long_internal(hand, self->century, ¢ury); + grib_get_long_internal(hand, self->day, &day); + grib_get_long_internal(hand, self->month, &month); + grib_get_long_internal(hand, self->year, &year); + + fullyear = ((century - 1) * 100 + year); + fake_day_of_year = ((month - 1) * 30) + day; + snprintf(tmp, sizeof(tmp), "%04ld-%03ld", fullyear, fake_day_of_year); + + size_t l = strlen(tmp) + 1; + if (*len < l) { + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + *len = l; + strcpy(val, tmp); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1day_of_the_year_date.h b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h new file mode 100644 index 000000000..5e484686c --- /dev/null +++ b/src/accessor/grib_accessor_class_g1day_of_the_year_date.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_g1date.h" + +class grib_accessor_g1day_of_the_year_date_t : public grib_accessor_g1date_t +{ +public: + /* Members defined in g1day_of_the_year_date */ +}; + +class grib_accessor_class_g1day_of_the_year_date_t : public grib_accessor_class_g1date_t +{ +public: + grib_accessor_class_g1day_of_the_year_date_t(const char* name) : grib_accessor_class_g1date_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1day_of_the_year_date_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc new file mode 100644 index 000000000..ea48fc6cb --- /dev/null +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc @@ -0,0 +1,136 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1end_of_interval_monthly.h" + +grib_accessor_class_g1end_of_interval_monthly_t _grib_accessor_class_g1end_of_interval_monthly{"g1end_of_interval_monthly"}; +grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly = &_grib_accessor_class_g1end_of_interval_monthly; + + +void grib_accessor_class_g1end_of_interval_monthly_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_vector_t::init(a, l, c); + grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + int n = 0; + + self->verifyingMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + + self->number_of_elements = 6; + self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements); + + a->length = 0; + a->dirty = 1; +} + +int grib_accessor_class_g1end_of_interval_monthly_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + int ret = 0; + char verifyingMonth[7] = {0,}; + size_t slen = 7; + long year = 0, month = 0, date = 0; + const long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + long days = 0; + + if (!a->dirty) + return GRIB_SUCCESS; + + if (*len != (size_t)self->number_of_elements) + return GRIB_ARRAY_TOO_SMALL; + + if ((ret = grib_get_string(grib_handle_of_accessor(a), self->verifyingMonth, verifyingMonth, &slen)) != GRIB_SUCCESS) + return ret; + + date = atoi(verifyingMonth); + if (date < 0) { + return GRIB_INVALID_ARGUMENT; + } + year = date / 100; + month = date - year * 100; + if (month == 2) { + days = 28; + if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) + days = 29; + } + else { + if (month < 1 || month > 12) return GRIB_INVALID_ARGUMENT; + days = mdays[month - 1]; + } + self->v[0] = year; + self->v[1] = month; + + self->v[2] = days; + self->v[3] = 24; + self->v[4] = 00; + self->v[5] = 00; + + a->dirty = 0; + + val[0] = self->v[0]; + val[1] = self->v[1]; + val[2] = self->v[2]; + val[3] = self->v[3]; + val[4] = self->v[4]; + val[5] = self->v[5]; + + return ret; +} + +int grib_accessor_class_g1end_of_interval_monthly_t::value_count(grib_accessor* a, long* count){ + grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + *count = self->number_of_elements; + return 0; +} + +void grib_accessor_class_g1end_of_interval_monthly_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_g1end_of_interval_monthly_t* self = (grib_accessor_g1end_of_interval_monthly_t*)a; + grib_context_free(c, self->v); + grib_accessor_class_abstract_vector_t::destroy(c, a); +} + +int grib_accessor_class_g1end_of_interval_monthly_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = GRIB_SUCCESS; + double* aval = 0; + double* bval = 0; + + long count = 0; + size_t alen = 0; + size_t blen = 0; + int err = 0; + + err = a->value_count(&count); if (err) + return err; + alen = count; + + err = b->value_count(&count); if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + b->dirty = 1; + a->dirty = 1; + + err = a->unpack_double(aval, &alen); err = b->unpack_double(bval, &blen); + for(size_t i=0; icontext, aval); + grib_context_free(b->context, bval); + + return retval; +} diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h new file mode 100644 index 000000000..baaea5320 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_g1end_of_interval_monthly_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in g1end_of_interval_monthly */ + const char* verifyingMonth; +}; + +class grib_accessor_class_g1end_of_interval_monthly_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_g1end_of_interval_monthly_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1end_of_interval_monthly_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1fcperiod.cc b/src/accessor/grib_accessor_class_g1fcperiod.cc new file mode 100644 index 000000000..fcf98d78d --- /dev/null +++ b/src/accessor/grib_accessor_class_g1fcperiod.cc @@ -0,0 +1,41 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1fcperiod.h" + +grib_accessor_class_g1fcperiod_t _grib_accessor_class_g1fcperiod{"g1fcperiod"}; +grib_accessor_class* grib_accessor_class_g1fcperiod = &_grib_accessor_class_g1fcperiod; + + +int grib_accessor_class_g1fcperiod_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + long start = 0, theEnd = 0; + char tmp[1024]; + const size_t tmpLen = sizeof(tmp); + int err = grib_g1_step_get_steps(a, &start, &theEnd); + size_t l = 0; + + if (err) + return err; + + snprintf(tmp, tmpLen, "%ld-%ld", start / 24, theEnd / 24); + /*printf("---- FCPERIOD %s [start:%g, end:%g]",tmp,start,end);*/ + + l = strlen(tmp) + 1; + if (*len < l) { + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + *len = l; + strcpy(val, tmp); /* NOLINT: CWE-119 clang-analyzer-security.insecureAPI.strcpy */ + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1fcperiod.h b/src/accessor/grib_accessor_class_g1fcperiod.h new file mode 100644 index 000000000..1b5b8dc7e --- /dev/null +++ b/src/accessor/grib_accessor_class_g1fcperiod.h @@ -0,0 +1,28 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_g1step_range.h" + +class grib_accessor_g1fcperiod_t : public grib_accessor_g1step_range_t +{ +public: + /* Members defined in g1fcperiod */ +}; + +class grib_accessor_class_g1fcperiod_t : public grib_accessor_class_g1step_range_t +{ +public: + grib_accessor_class_g1fcperiod_t(const char* name) : grib_accessor_class_g1step_range_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1fcperiod_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; +}; diff --git a/src/grib_accessor_class_g1forecastmonth.cc b/src/accessor/grib_accessor_class_g1forecastmonth.cc similarity index 54% rename from src/grib_accessor_class_g1forecastmonth.cc rename to src/accessor/grib_accessor_class_g1forecastmonth.cc index e25db6930..7ec448cf6 100644 --- a/src/grib_accessor_class_g1forecastmonth.cc +++ b/src/accessor/grib_accessor_class_g1forecastmonth.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,113 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - MEMBERS=const char* verification_yearmonth - MEMBERS=const char* base_date - MEMBERS=const char* day - MEMBERS=const char* hour - MEMBERS=const char* fcmonth - MEMBERS=const char* check - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1forecastmonth -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1forecastmonth */ - const char* verification_yearmonth; - const char* base_date; - const char* day; - const char* hour; - const char* fcmonth; - const char* check; -} grib_accessor_g1forecastmonth; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1forecastmonth = { - &grib_accessor_class_long, /* super */ - "g1forecastmonth", /* name */ - sizeof(grib_accessor_g1forecastmonth), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g1forecastmonth.h" +grib_accessor_class_g1forecastmonth_t _grib_accessor_class_g1forecastmonth{ "g1forecastmonth" }; grib_accessor_class* grib_accessor_class_g1forecastmonth = &_grib_accessor_class_g1forecastmonth; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) +void grib_accessor_class_g1forecastmonth_t::init(grib_accessor* a, const long l, grib_arguments* c) { - grib_accessor_g1forecastmonth* self = (grib_accessor_g1forecastmonth*)a; + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; const int count = grib_arguments_get_count(c); @@ -128,7 +32,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) } } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_g1forecastmonth_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_long(dumper, a, NULL); } @@ -136,11 +40,11 @@ static void dump(grib_accessor* a, grib_dumper* dumper) static int calculate_fcmonth(grib_accessor* a, long verification_yearmonth, long base_date, long day, long hour, long* result) { long base_yearmonth = 0; - long vyear = 0; - long vmonth = 0; - long byear = 0; - long bmonth = 0; - long fcmonth = 0; + long vyear = 0; + long vmonth = 0; + long byear = 0; + long bmonth = 0; + long fcmonth = 0; base_yearmonth = base_date / 100; @@ -167,10 +71,10 @@ static int unpack_long_edition2(grib_accessor* a, long* val, size_t* len) long forecastTime, indicatorOfUnitOfTimeRange; double jul_base, jul2, dstep; - if ((err = grib_get_long(h, "year", &year)) != GRIB_SUCCESS) return err; + if ((err = grib_get_long(h, "year", &year)) != GRIB_SUCCESS) return err; if ((err = grib_get_long(h, "month", &month)) != GRIB_SUCCESS) return err; - if ((err = grib_get_long(h, "day", &day)) != GRIB_SUCCESS) return err; - if ((err = grib_get_long(h, "hour", &hour)) != GRIB_SUCCESS) return err; + if ((err = grib_get_long(h, "day", &day)) != GRIB_SUCCESS) return err; + if ((err = grib_get_long(h, "hour", &hour)) != GRIB_SUCCESS) return err; if ((err = grib_get_long(h, "minute", &minute)) != GRIB_SUCCESS) return err; if ((err = grib_get_long(h, "second", &second)) != GRIB_SUCCESS) return err; @@ -190,30 +94,30 @@ static int unpack_long_edition2(grib_accessor* a, long* val, size_t* len) return err; dstep = (((double)forecastTime) * 3600) / 86400; /* as a fraction of a day */ - jul2 = jul_base + dstep; + jul2 = jul_base + dstep; if ((err = grib_julian_to_datetime(jul2, &year2, &month2, &day2, &hour2, &minute2, &second2)) != GRIB_SUCCESS) return err; - verification_yearmonth = year2*100 + month2; + verification_yearmonth = year2 * 100 + month2; if ((err = calculate_fcmonth(a, verification_yearmonth, dataDate, day, hour, val)) != GRIB_SUCCESS) return err; return GRIB_SUCCESS; } -static int unpack_long_edition1(grib_accessor* a, long* val, size_t* len) +int unpack_long_edition1(grib_accessor* a, long* val, size_t* len) { int err = 0; - grib_accessor_g1forecastmonth* self = (grib_accessor_g1forecastmonth*)a; + grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; long verification_yearmonth = 0; long base_date = 0; long day = 0; long hour = 0; - long gribForecastMonth = 0; - long check = 0; - long fcmonth = 0; + long gribForecastMonth = 0; + long check = 0; + long fcmonth = 0; if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->verification_yearmonth, &verification_yearmonth)) != GRIB_SUCCESS) @@ -249,11 +153,11 @@ static int unpack_long_edition1(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_g1forecastmonth_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - int err = 0; + int err = 0; grib_handle* hand = grib_handle_of_accessor(a); - long edition = 0; + long edition = 0; if ((err = grib_get_long(hand, "edition", &edition)) != GRIB_SUCCESS) return err; @@ -267,8 +171,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } /* TODO: Check for a valid date */ -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_g1forecastmonth_t::pack_long(grib_accessor* a, const long* val, size_t* len) { - grib_accessor_g1forecastmonth* self = (grib_accessor_g1forecastmonth*)a; + grib_accessor_g1forecastmonth_t* self = (grib_accessor_g1forecastmonth_t*)a; return grib_set_long_internal(grib_handle_of_accessor(a), self->fcmonth, *val); } diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.h b/src/accessor/grib_accessor_class_g1forecastmonth.h new file mode 100644 index 000000000..cd3a6d5f6 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1forecastmonth.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g1forecastmonth_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1forecastmonth */ + const char* verification_yearmonth; + const char* base_date; + const char* day; + const char* hour; + const char* fcmonth; + const char* check; +}; + +class grib_accessor_class_g1forecastmonth_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1forecastmonth_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1forecastmonth_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1monthlydate.cc b/src/accessor/grib_accessor_class_g1monthlydate.cc new file mode 100644 index 000000000..420f96ef3 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1monthlydate.cc @@ -0,0 +1,41 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1monthlydate.h" + +grib_accessor_class_g1monthlydate_t _grib_accessor_class_g1monthlydate{"g1monthlydate"}; +grib_accessor_class* grib_accessor_class_g1monthlydate = &_grib_accessor_class_g1monthlydate; + + +void grib_accessor_class_g1monthlydate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_g1monthlydate_t* self = (grib_accessor_g1monthlydate_t*)a; + int n = 0; + + self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_g1monthlydate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1monthlydate_t* self = (grib_accessor_g1monthlydate_t*)a; + + long date = 0; + + grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date); + + date /= 100; + date *= 100; + date += 1; + + *val = date; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1monthlydate.h b/src/accessor/grib_accessor_class_g1monthlydate.h new file mode 100644 index 000000000..8503fa0af --- /dev/null +++ b/src/accessor/grib_accessor_class_g1monthlydate.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g1monthlydate_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1monthlydate */ + const char* date; +}; + +class grib_accessor_class_g1monthlydate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1monthlydate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1monthlydate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc new file mode 100644 index 000000000..9976ad812 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc @@ -0,0 +1,81 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1number_of_coded_values_sh_complex.h" + +grib_accessor_class_g1number_of_coded_values_sh_complex_t _grib_accessor_class_g1number_of_coded_values_sh_complex{"g1number_of_coded_values_sh_complex"}; +grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex = &_grib_accessor_class_g1number_of_coded_values_sh_complex; + + +void grib_accessor_class_g1number_of_coded_values_sh_complex_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + int n = 0; + grib_accessor_g1number_of_coded_values_sh_complex_t* self = (grib_accessor_g1number_of_coded_values_sh_complex_t*)a; + self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->JS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->KS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->MS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_g1number_of_coded_values_sh_complex_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = GRIB_SUCCESS; + long bpv = 0; + long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; + long JS = 0, KS = 0, MS = 0, NS = 0; + + grib_accessor_g1number_of_coded_values_sh_complex_t* self = (grib_accessor_g1number_of_coded_values_sh_complex_t*)a; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->JS, &JS)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->KS, &KS)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->MS, &MS)) != GRIB_SUCCESS) + return ret; + + if (JS != KS || KS != MS) + return GRIB_NOT_IMPLEMENTED; + + NS = (MS + 1) * (MS + 2); + + if (bpv != 0) { + DEBUG_ASSERT(offsetAfterData > offsetBeforeData); + *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits + NS * (bpv - 32)) / bpv; + } + else { + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) + return ret; + + *val = numberOfValues; + } + + return ret; +} diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h new file mode 100644 index 000000000..97379631d --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g1number_of_coded_values_sh_complex_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1number_of_coded_values_sh_complex */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; + const char* JS; + const char* KS; + const char* MS; +}; + +class grib_accessor_class_g1number_of_coded_values_sh_complex_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1number_of_coded_values_sh_complex_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1number_of_coded_values_sh_complex_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc new file mode 100644 index 000000000..802e6ceb7 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc @@ -0,0 +1,62 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1number_of_coded_values_sh_simple.h" + +grib_accessor_class_g1number_of_coded_values_sh_simple_t _grib_accessor_class_g1number_of_coded_values_sh_simple{"g1number_of_coded_values_sh_simple"}; +grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple = &_grib_accessor_class_g1number_of_coded_values_sh_simple; + + +void grib_accessor_class_g1number_of_coded_values_sh_simple_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + int n = 0; + grib_accessor_g1number_of_coded_values_sh_simple_t* self = (grib_accessor_g1number_of_coded_values_sh_simple_t*)a; + self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_g1number_of_coded_values_sh_simple_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = GRIB_SUCCESS; + long bpv = 0; + long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; + + grib_accessor_g1number_of_coded_values_sh_simple_t* self = (grib_accessor_g1number_of_coded_values_sh_simple_t*)a; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) + return ret; + + if (bpv != 0) { + DEBUG_ASSERT(offsetAfterData > offsetBeforeData); + *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv; + } + else { + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) + return ret; + + *val = numberOfValues; + } + return ret; +} diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h new file mode 100644 index 000000000..4dafe6b15 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g1number_of_coded_values_sh_simple_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1number_of_coded_values_sh_simple */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; +}; + +class grib_accessor_class_g1number_of_coded_values_sh_simple_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1number_of_coded_values_sh_simple_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1number_of_coded_values_sh_simple_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_g1step_range.cc b/src/accessor/grib_accessor_class_g1step_range.cc similarity index 78% rename from src/grib_accessor_class_g1step_range.cc rename to src/accessor/grib_accessor_class_g1step_range.cc index 46c7a3cc8..a2920a1cf 100644 --- a/src/grib_accessor_class_g1step_range.cc +++ b/src/accessor/grib_accessor_class_g1step_range.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,131 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/********************************************* - * Enrico Fucile - *******************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_long_vector - IMPLEMENTS = pack_string;unpack_string;value_count - IMPLEMENTS = pack_long;unpack_long;dump - IMPLEMENTS = get_native_type;string_length - IMPLEMENTS = init; destroy - MEMBERS = const char* p1 - MEMBERS = const char* p2 - MEMBERS = const char* timeRangeIndicator - MEMBERS = const char *unit - MEMBERS = const char *step_unit - MEMBERS = const char *stepType - MEMBERS = const char *patch_fp_precip - MEMBERS = int error_on_units - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1step_range -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; - /* Members defined in g1step_range */ - const char* p1; - const char* p2; - const char* timeRangeIndicator; - const char *unit; - const char *step_unit; - const char *stepType; - const char *patch_fp_precip; - int error_on_units; -} grib_accessor_g1step_range; - -extern grib_accessor_class* grib_accessor_class_abstract_long_vector; - -static grib_accessor_class _grib_accessor_class_g1step_range = { - &grib_accessor_class_abstract_long_vector, /* super */ - "g1step_range", /* name */ - sizeof(grib_accessor_g1step_range), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g1step_range.h" +grib_accessor_class_g1step_range_t _grib_accessor_class_g1step_range{"g1step_range"}; grib_accessor_class* grib_accessor_class_g1step_range = &_grib_accessor_class_g1step_range; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +void grib_accessor_class_g1step_range_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_long_vector_t::init(a, l, c); + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); int n = 0; self->p1 = grib_arguments_get_name(h, c, n++); @@ -153,8 +38,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_g1step_range_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_string(dumper, a, NULL); } @@ -203,7 +87,7 @@ static const int u2s[] = { int grib_g1_step_get_steps(grib_accessor* a, long* start, long* theEnd) { - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; int err = 0; long p1 = 0, p2 = 0, unit = 0, timeRangeIndicator = 0, timeRangeIndicatorFromStepRange = 0; long step_unit = 1; @@ -298,9 +182,8 @@ int grib_g1_step_get_steps(grib_accessor* a, long* start, long* theEnd) return 0; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +int grib_accessor_class_g1step_range_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; char buf[100]; size_t size = 0; long start = 0, theEnd = 0; @@ -450,9 +333,8 @@ static int grib_g1_step_apply_units( return GRIB_WRONG_STEP; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +int grib_accessor_class_g1step_range_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; grib_handle* h = grib_handle_of_accessor(a); long timeRangeIndicator = 0, P1 = 0, P2 = 0; long start = 0, theEnd = -1, unit = 0, ounit = 0, step_unit = 1; @@ -631,25 +513,22 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return 0; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g1step_range_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static size_t string_length(grib_accessor* a) -{ +size_t grib_accessor_class_g1step_range_t::string_length(grib_accessor* a){ return 255; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ +int grib_accessor_class_g1step_range_t::pack_long(grib_accessor* a, const long* val, size_t* len){ char buff[256]; size_t bufflen = 100; char sval[100] = { 0 }; char* p = sval; size_t svallen = 100; - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; char stepType[20] = {0,}; size_t stepTypeLen = 20; long step_unit = 0; @@ -718,9 +597,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_INTERNAL_ERROR; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +int grib_accessor_class_g1step_range_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; char buff[100]; size_t bufflen = 100; long start, theEnd; @@ -749,13 +627,12 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return 0; } -static int get_native_type(grib_accessor* a) -{ +int grib_accessor_class_g1step_range_t::get_native_type(grib_accessor* a){ return GRIB_TYPE_STRING; } -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a; +void grib_accessor_class_g1step_range_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_g1step_range_t* self = (grib_accessor_g1step_range_t*)a; grib_context_free(c, self->v); + grib_accessor_class_abstract_long_vector_t::destroy(c, a); } diff --git a/src/accessor/grib_accessor_class_g1step_range.h b/src/accessor/grib_accessor_class_g1step_range.h new file mode 100644 index 000000000..7ca19cb08 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1step_range.h @@ -0,0 +1,45 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_abstract_long_vector.h" + +class grib_accessor_g1step_range_t : public grib_accessor_abstract_long_vector_t +{ +public: + /* Members defined in g1step_range */ + const char* p1; + const char* p2; + const char* timeRangeIndicator; + const char *unit; + const char *step_unit; + const char *stepType; + const char *patch_fp_precip; + int error_on_units; +}; + +class grib_accessor_class_g1step_range_t : public grib_accessor_class_abstract_long_vector_t +{ +public: + grib_accessor_class_g1step_range_t(const char* name) : grib_accessor_class_abstract_long_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1step_range_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g1verificationdate.cc b/src/accessor/grib_accessor_class_g1verificationdate.cc new file mode 100644 index 000000000..63a1f1356 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1verificationdate.cc @@ -0,0 +1,64 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g1verificationdate.h" + +grib_accessor_class_g1verificationdate_t _grib_accessor_class_g1verificationdate{"g1verificationdate"}; +grib_accessor_class* grib_accessor_class_g1verificationdate = &_grib_accessor_class_g1verificationdate; + + +void grib_accessor_class_g1verificationdate_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_g1verificationdate_t* self = (grib_accessor_g1verificationdate_t*)a; + int n = 0; + + self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->time = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_g1verificationdate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g1verificationdate_t* self = (grib_accessor_g1verificationdate_t*)a; + int ret = 0; + long date = 0; + long time = 0; + long cdate = 0; + long step = 0; + long vtime = 0; + long vdate = 0; + long vd = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->time, &time)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->step, &step)) != GRIB_SUCCESS) + return ret; + + time /= 100; + + cdate = (long)grib_date_to_julian(date); + vtime = cdate * 24 + time + step; + vd = vtime / 24; + vdate = grib_julian_to_date(vd); + + /* printf("\n********\n date %d, time %d, step %d, vdate: %d, cdate %d, vd %d\n********\n", date, time, step, vdate, cdate, vd); */ + + if (*len < 1) + return GRIB_ARRAY_TOO_SMALL; + + *val = vdate; + + /* fprintf(stdout,"\n********\n %d cdate %d vd %d\n********\n", vdate, cdate, step); */ + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g1verificationdate.h b/src/accessor/grib_accessor_class_g1verificationdate.h new file mode 100644 index 000000000..0e0469926 --- /dev/null +++ b/src/accessor/grib_accessor_class_g1verificationdate.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g1verificationdate_t : public grib_accessor_long_t +{ +public: + /* Members defined in g1verificationdate */ + const char* date; + const char* time; + const char* step; +}; + +class grib_accessor_class_g1verificationdate_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g1verificationdate_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g1verificationdate_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g2_aerosol.cc b/src/accessor/grib_accessor_class_g2_aerosol.cc new file mode 100644 index 000000000..464563187 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_aerosol.cc @@ -0,0 +1,114 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g2_aerosol.h" + +grib_accessor_class_g2_aerosol_t _grib_accessor_class_g2_aerosol{"g2_aerosol"}; +grib_accessor_class* grib_accessor_class_g2_aerosol = &_grib_accessor_class_g2_aerosol; + + +void grib_accessor_class_g2_aerosol_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); + grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->productDefinitionTemplateNumber = grib_arguments_get_name(hand, c, n++); + self->stepType = grib_arguments_get_name(hand, c, n++); + self->optical = grib_arguments_get_long(hand, c, n++); +} + +int grib_accessor_class_g2_aerosol_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a; + long productDefinitionTemplateNumber = 0; + grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber); + + if (self->optical) + *val = grib2_is_PDTN_AerosolOptical(productDefinitionTemplateNumber); + else + *val = grib2_is_PDTN_Aerosol(productDefinitionTemplateNumber); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2_aerosol_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + long productDefinitionTemplateNumber = -1; + long productDefinitionTemplateNumberNew = -1; + /*long type=-1; + long stream=-1;*/ + long eps = -1; + char stepType[15] = {0,}; + size_t slen = 15; + /*int aerosol = *val;*/ + int isInstant = 0; + /*long derivedForecast=-1;*/ + int ret = 0; + + if (grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber) != GRIB_SUCCESS) + return GRIB_SUCCESS; + + /* + grib_get_long(hand, self->type,&type); + grib_get_long(hand, self->stream,&stream); + */ + ret = grib_get_string(hand, self->stepType, stepType, &slen); + Assert(ret == GRIB_SUCCESS); + + //eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber); + eps = grib_is_defined(hand, "perturbationNumber"); + + if (!strcmp(stepType, "instant")) + isInstant = 1; + + if (eps == 1) { + if (isInstant) { + productDefinitionTemplateNumberNew = 45; + } + else { + /*productDefinitionTemplateNumberNew = 47; PDT deprecated*/ + productDefinitionTemplateNumberNew = 85; + } + } + else { + if (isInstant) { + productDefinitionTemplateNumberNew = 48; /*44 is deprecated*/ + } + else { + productDefinitionTemplateNumberNew = 46; + } + } + + if (self->optical) { + /* Note: There is no interval based template for optical properties of aerosol! */ + if (eps) + productDefinitionTemplateNumberNew = 49; + else + productDefinitionTemplateNumberNew = 48; + if (!isInstant) { + grib_context_log(hand->context, GRIB_LOG_ERROR, + "The product definition templates for optical properties of aerosol are for a point-in-time only"); + } + } + + if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) { + grib_set_long(hand, self->productDefinitionTemplateNumber, productDefinitionTemplateNumberNew); + /*if (derivedForecast>=0) grib_set_long(hand, self->derivedForecast,derivedForecast);*/ + } + + return 0; +} + +int grib_accessor_class_g2_aerosol_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_g2_aerosol.h b/src/accessor/grib_accessor_class_g2_aerosol.h new file mode 100644 index 000000000..9fbd0c79b --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_aerosol.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_aerosol_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_aerosol */ + const char* productDefinitionTemplateNumber; + const char* stepType; + int optical; +}; + +class grib_accessor_class_g2_aerosol_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_aerosol_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_aerosol_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_g2_chemical.cc b/src/accessor/grib_accessor_class_g2_chemical.cc similarity index 53% rename from src/grib_accessor_class_g2_chemical.cc rename to src/accessor/grib_accessor_class_g2_chemical.cc index 16d8e6f33..3d05886a5 100644 --- a/src/grib_accessor_class_g2_chemical.cc +++ b/src/accessor/grib_accessor_class_g2_chemical.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,109 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* stepType - MEMBERS=int chemical_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2_chemical -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in g2_chemical */ - const char* productDefinitionTemplateNumber; - const char* stepType; - int chemical_type; -} grib_accessor_g2_chemical; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_g2_chemical = { - &grib_accessor_class_unsigned, /* super */ - "g2_chemical", /* name */ - sizeof(grib_accessor_g2_chemical), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g2_chemical.h" +grib_accessor_class_g2_chemical_t _grib_accessor_class_g2_chemical{"g2_chemical"}; grib_accessor_class* grib_accessor_class_g2_chemical = &_grib_accessor_class_g2_chemical; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2_chemical* self = (grib_accessor_g2_chemical*)a; +void grib_accessor_class_g2_chemical_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); + grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -119,9 +26,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->chemical_type = grib_arguments_get_long(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2_chemical* self = (grib_accessor_g2_chemical*)a; +int grib_accessor_class_g2_chemical_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a; long productDefinitionTemplateNumber = 0; grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber); @@ -141,9 +47,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2_chemical* self = (grib_accessor_g2_chemical*)a; +int grib_accessor_class_g2_chemical_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long productDefinitionTemplateNumber = -1; long productDefinitionTemplateNumberNew = -1; @@ -214,8 +119,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return 0; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g2_chemical_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_g2_chemical.h b/src/accessor/grib_accessor_class_g2_chemical.h new file mode 100644 index 000000000..66bf945aa --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_chemical.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_chemical_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_chemical */ + const char* productDefinitionTemplateNumber; + const char* stepType; + int chemical_type; +}; + +class grib_accessor_class_g2_chemical_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_chemical_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_chemical_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_g2_eps.cc b/src/accessor/grib_accessor_class_g2_eps.cc similarity index 57% rename from src/grib_accessor_class_g2_eps.cc rename to src/accessor/grib_accessor_class_g2_eps.cc index fc202a572..6b6c42fd7 100644 --- a/src/grib_accessor_class_g2_eps.cc +++ b/src/accessor/grib_accessor_class_g2_eps.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,114 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* stream - MEMBERS=const char* type - MEMBERS=const char* stepType - MEMBERS=const char* derivedForecast - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2_eps -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in g2_eps */ - const char* productDefinitionTemplateNumber; - const char* stream; - const char* type; - const char* stepType; - const char* derivedForecast; -} grib_accessor_g2_eps; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_g2_eps = { - &grib_accessor_class_unsigned, /* super */ - "g2_eps", /* name */ - sizeof(grib_accessor_g2_eps), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g2_eps.h" +grib_accessor_class_g2_eps_t _grib_accessor_class_g2_eps{"g2_eps"}; grib_accessor_class* grib_accessor_class_g2_eps = &_grib_accessor_class_g2_eps; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2_eps* self = (grib_accessor_g2_eps*)a; +void grib_accessor_class_g2_eps_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); + grib_accessor_g2_eps_t* self = (grib_accessor_g2_eps_t*)a; int n = 0; self->productDefinitionTemplateNumber = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -125,9 +27,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->derivedForecast = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2_eps* self = (grib_accessor_g2_eps*)a; +int grib_accessor_class_g2_eps_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_g2_eps_t* self = (grib_accessor_g2_eps_t*)a; long productDefinitionTemplateNumber = 0; int err = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -145,9 +46,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2_eps* self = (grib_accessor_g2_eps*)a; +int grib_accessor_class_g2_eps_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2_eps_t* self = (grib_accessor_g2_eps_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long productDefinitionTemplateNumber = -1; long productDefinitionTemplateNumberNew = -1; @@ -266,8 +166,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return 0; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_g2_eps_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_g2_eps.h b/src/accessor/grib_accessor_class_g2_eps.h new file mode 100644 index 000000000..8453387fa --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_eps.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_g2_eps_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in g2_eps */ + const char* productDefinitionTemplateNumber; + const char* stream; + const char* type; + const char* stepType; + const char* derivedForecast; +}; + +class grib_accessor_class_g2_eps_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_g2_eps_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_eps_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/grib_accessor_class_g2_mars_labeling.cc similarity index 71% rename from src/grib_accessor_class_g2_mars_labeling.cc rename to src/accessor/grib_accessor_class_g2_mars_labeling.cc index f6437c279..b9059220f 100644 --- a/src/grib_accessor_class_g2_mars_labeling.cc +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,131 +9,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = init; get_native_type - MEMBERS=int index - MEMBERS=const char* the_class - MEMBERS=const char* stream - MEMBERS=const char* type - MEMBERS=const char* expver - MEMBERS=const char* typeOfProcessedData - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* stepType - MEMBERS=const char* derivedForecast - MEMBERS=const char* typeOfGeneratingProcess - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2_mars_labeling -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in g2_mars_labeling */ - int index; - const char* the_class; - const char* stream; - const char* type; - const char* expver; - const char* typeOfProcessedData; - const char* productDefinitionTemplateNumber; - const char* stepType; - const char* derivedForecast; - const char* typeOfGeneratingProcess; -} grib_accessor_g2_mars_labeling; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_g2_mars_labeling = { - &grib_accessor_class_gen, /* super */ - "g2_mars_labeling", /* name */ - sizeof(grib_accessor_g2_mars_labeling), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g2_mars_labeling.h" +grib_accessor_class_g2_mars_labeling_t _grib_accessor_class_g2_mars_labeling{ "g2_mars_labeling" }; grib_accessor_class* grib_accessor_class_g2_mars_labeling = &_grib_accessor_class_g2_mars_labeling; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) +void grib_accessor_class_g2_mars_labeling_t::init(grib_accessor* a, const long l, grib_arguments* c) { - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); + grib_accessor_class_gen_t::init(a, l, c); + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); self->index = grib_arguments_get_long(hand, c, n++); self->the_class = grib_arguments_get_name(hand, c, n++); @@ -146,10 +34,10 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->typeOfGeneratingProcess = grib_arguments_get_name(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_g2_mars_labeling_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; - char* key = NULL; + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; + char* key = NULL; switch (self->index) { case 0: @@ -165,16 +53,15 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } return grib_get_long(grib_handle_of_accessor(a), key, val); } -static int unpack_string(grib_accessor* a, char* val, size_t* len) +int grib_accessor_class_g2_mars_labeling_t::unpack_string(grib_accessor* a, char* val, size_t* len) { - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; - char* key = NULL; + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; + char* key = NULL; switch (self->index) { case 0: @@ -190,7 +77,6 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } return grib_get_string(grib_handle_of_accessor(a), key, val, len); @@ -198,10 +84,10 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) static int extra_set(grib_accessor* a, long val) { - int ret = 0; - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; - grib_handle* hand = grib_handle_of_accessor(a); - char stepType[30] = {0,}; + int ret = 0; + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + char stepType[30] = {0,}; size_t stepTypelen = 30; long derivedForecast = -1; long productDefinitionTemplateNumberNew = -1; @@ -226,7 +112,6 @@ static int extra_set(grib_accessor* a, long val) case 0: /* class */ return ret; - break; case 1: /* type */ switch (val) { @@ -400,7 +285,6 @@ static int extra_set(grib_accessor* a, long val) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } if (productDefinitionTemplateNumberNew >= 0) { @@ -421,12 +305,12 @@ static int extra_set(grib_accessor* a, long val) return ret; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) +int grib_accessor_class_g2_mars_labeling_t::pack_string(grib_accessor* a, const char* val, size_t* len) { - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; - char* key = NULL; - int ret = 0; - long lval = 0; + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; + char* key = NULL; + int ret = 0; + long lval = 0; switch (self->index) { case 0: @@ -442,7 +326,6 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } ret = grib_set_string(grib_handle_of_accessor(a), key, val, len); @@ -456,11 +339,11 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return extra_set(a, lval); } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_g2_mars_labeling_t::pack_long(grib_accessor* a, const long* val, size_t* len) { - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; - char* key = NULL; - int ret = 0; + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; + char* key = NULL; + int ret = 0; switch (self->index) { case 0: @@ -476,7 +359,6 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } ret = grib_set_long(grib_handle_of_accessor(a), key, *val); @@ -486,18 +368,18 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return extra_set(a, *val); } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_g2_mars_labeling_t::value_count(grib_accessor* a, long* count) { *count = 1; return 0; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_g2_mars_labeling_t::get_native_type(grib_accessor* a) { - grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a; - char* key = NULL; - int ret = 0; - int type = 0; + grib_accessor_g2_mars_labeling_t* self = (grib_accessor_g2_mars_labeling_t*)a; + char* key = NULL; + int ret = 0; + int type = 0; switch (self->index) { case 0: @@ -513,7 +395,6 @@ static int get_native_type(grib_accessor* a) grib_context_log(a->context, GRIB_LOG_ERROR, "invalid first argument of g2_mars_labeling in %s", a->name); return GRIB_INTERNAL_ERROR; - break; } ret = grib_get_native_type(grib_handle_of_accessor(a), key, &type); diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.h b/src/accessor/grib_accessor_class_g2_mars_labeling.h new file mode 100644 index 000000000..d47848565 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.h @@ -0,0 +1,44 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_g2_mars_labeling_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g2_mars_labeling */ + int index; + const char* the_class; + const char* stream; + const char* type; + const char* expver; + const char* typeOfProcessedData; + const char* productDefinitionTemplateNumber; + const char* stepType; + const char* derivedForecast; + const char* typeOfGeneratingProcess; +}; + +class grib_accessor_class_g2_mars_labeling_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g2_mars_labeling_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2_mars_labeling_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g2bitmap.cc b/src/accessor/grib_accessor_class_g2bitmap.cc new file mode 100644 index 000000000..d5af880b3 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap.cc @@ -0,0 +1,75 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g2bitmap.h" +#include "shared_functions.h" + +grib_accessor_class_g2bitmap_t _grib_accessor_class_g2bitmap{"g2bitmap"}; +grib_accessor_class* grib_accessor_class_g2bitmap = &_grib_accessor_class_g2bitmap; + + +void grib_accessor_class_g2bitmap_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bitmap_t::init(a, len, arg); + grib_accessor_g2bitmap_t* self = (grib_accessor_g2bitmap_t*)a; + + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); +} + +int grib_accessor_class_g2bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_g2bitmap_t* self = (grib_accessor_g2bitmap_t*)a; + + size_t tlen; + + unsigned char* buf = NULL; + size_t i; + int err = 0; + long pos = 0; + // long bmaplen = 0; + double miss_values = 0; + tlen = (*len + 7) / 8; + + if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &miss_values)) != GRIB_SUCCESS) + return err; + + buf = (unsigned char*)grib_context_malloc_clear(a->context, tlen); + if (!buf) + return GRIB_OUT_OF_MEMORY; + pos = 0; + for (i = 0; i < *len; i++) { + if (val[i] == miss_values) + pos++; + else { + // bmaplen++; + grib_set_bit_on(buf, &pos); + } + } + + if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, *len)) != GRIB_SUCCESS) { + grib_context_free(a->context, buf); + return err; + } + + grib_buffer_replace(a, buf, tlen, 1, 1); + + grib_context_free(a->context, buf); + + return GRIB_SUCCESS; +} + + +int grib_accessor_class_g2bitmap_t::value_count(grib_accessor* a, long* tlen){ + grib_accessor_g2bitmap_t* self = (grib_accessor_g2bitmap_t*)a; + int err; + *tlen = 0; + + err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, tlen); + return err; +} diff --git a/src/accessor/grib_accessor_class_g2bitmap.h b/src/accessor/grib_accessor_class_g2bitmap.h new file mode 100644 index 000000000..2276b702c --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_bitmap.h" + +class grib_accessor_g2bitmap_t : public grib_accessor_bitmap_t +{ +public: + /* Members defined in g2bitmap */ + const char* numberOfValues; +}; + +class grib_accessor_class_g2bitmap_t : public grib_accessor_class_bitmap_t +{ +public: + grib_accessor_class_g2bitmap_t(const char* name) : grib_accessor_class_bitmap_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2bitmap_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.cc b/src/accessor/grib_accessor_class_g2bitmap_present.cc new file mode 100644 index 000000000..1444783fe --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap_present.cc @@ -0,0 +1,59 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g2bitmap_present.h" + +grib_accessor_class_g2bitmap_present_t _grib_accessor_class_g2bitmap_present{"g2bitmap_present"}; +grib_accessor_class* grib_accessor_class_g2bitmap_present = &_grib_accessor_class_g2bitmap_present; + + +void grib_accessor_class_g2bitmap_present_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + int n = 0; + grib_accessor_g2bitmap_present_t* self = (grib_accessor_g2bitmap_present_t*)a; + self->bitmapIndicator = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->length = 0; +} + +int grib_accessor_class_g2bitmap_present_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = GRIB_SUCCESS; + long bitmapIndicator = 0; + + grib_accessor_g2bitmap_present_t* self = (grib_accessor_g2bitmap_present_t*)a; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitmapIndicator, &bitmapIndicator); + if (ret) { + if (ret == GRIB_NOT_FOUND) { + *val = 0; + return 0; + } + else + return ret; + } + + *val = 1; + if (bitmapIndicator == 255) + *val = 0; + + *len = 1; + return ret; +} + +int grib_accessor_class_g2bitmap_present_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_g2bitmap_present_t* self = (grib_accessor_g2bitmap_present_t*)a; + long bitmapIndicator = 0; + + if (*val == 0) + bitmapIndicator = 255; + + return grib_set_long(grib_handle_of_accessor(a), self->bitmapIndicator, bitmapIndicator); +} diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.h b/src/accessor/grib_accessor_class_g2bitmap_present.h new file mode 100644 index 000000000..87d603f54 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2bitmap_present.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g2bitmap_present_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2bitmap_present */ + const char* bitmapIndicator; +}; + +class grib_accessor_class_g2bitmap_present_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2bitmap_present_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2bitmap_present_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g2date.cc b/src/accessor/grib_accessor_class_g2date.cc new file mode 100644 index 000000000..238da76f7 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2date.cc @@ -0,0 +1,82 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g2date.h" + +grib_accessor_class_g2date_t _grib_accessor_class_g2date{"g2date"}; +grib_accessor_class* grib_accessor_class_g2date = &_grib_accessor_class_g2date; + +void grib_accessor_class_g2date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; + int n = 0; + + self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_g2date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + const grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; + + int ret = 0; + long year = 0; + long month = 0; + long day = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->day, &day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->month, &month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->year, &year)) != GRIB_SUCCESS) + return ret; + + if (*len < 1) + return GRIB_WRONG_ARRAY_SIZE; + + val[0] = year * 10000 + month * 100 + day; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2date_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + const grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; + + int ret = GRIB_SUCCESS; + long v = val[0]; + long year = 0; + long month = 0; + long day = 0; + + if (*len != 1) + return GRIB_WRONG_ARRAY_SIZE; + + year = v / 10000; + v %= 10000; + month = v / 100; + v %= 100; + day = v; + + if (!is_date_valid(year, month, day, 0, 0, 0)) { + // ECC-1777: For now just a warning. Will later change to an error + fprintf(stderr, "ECCODES WARNING : %s:%s: Date is not valid! year=%ld month=%ld day=%ld\n", + a->cclass->name, __func__, year, month, day); + } + + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->year, year)) != GRIB_SUCCESS) + return ret; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_g2date.h b/src/accessor/grib_accessor_class_g2date.h new file mode 100644 index 000000000..e6981665c --- /dev/null +++ b/src/accessor/grib_accessor_class_g2date.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g2date_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2date */ + const char* century; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_g2date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_g2end_step.cc b/src/accessor/grib_accessor_class_g2end_step.cc similarity index 65% rename from src/grib_accessor_class_g2end_step.cc rename to src/accessor/grib_accessor_class_g2end_step.cc index ed47e5133..6e8cfcda3 100644 --- a/src/grib_accessor_class_g2end_step.cc +++ b/src/accessor/grib_accessor_class_g2end_step.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,153 +9,21 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" +#include "grib_accessor_class_g2end_step.h" #include "step.h" #include "step_utilities.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = init;dump - IMPLEMENTS = get_native_type - MEMBERS = const char* start_step_value - MEMBERS = const char* step_units - - MEMBERS = const char* year - MEMBERS = const char* month - MEMBERS = const char* day - MEMBERS = const char* hour - MEMBERS = const char* minute - MEMBERS = const char* second - - MEMBERS = const char* year_of_end_of_interval - MEMBERS = const char* month_of_end_of_interval - MEMBERS = const char* day_of_end_of_interval - MEMBERS = const char* hour_of_end_of_interval - MEMBERS = const char* minute_of_end_of_interval - MEMBERS = const char* second_of_end_of_interval - - MEMBERS = const char* time_range_unit - MEMBERS = const char* time_range_value - MEMBERS = const char* typeOfTimeIncrement - MEMBERS = const char* numberOfTimeRange - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2end_step -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g2end_step */ - const char* start_step_value; - const char* step_units; - const char* year; - const char* month; - const char* day; - const char* hour; - const char* minute; - const char* second; - const char* year_of_end_of_interval; - const char* month_of_end_of_interval; - const char* day_of_end_of_interval; - const char* hour_of_end_of_interval; - const char* minute_of_end_of_interval; - const char* second_of_end_of_interval; - const char* time_range_unit; - const char* time_range_value; - const char* typeOfTimeIncrement; - const char* numberOfTimeRange; -} grib_accessor_g2end_step; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g2end_step = { - &grib_accessor_class_long, /* super */ - "g2end_step", /* name */ - sizeof(grib_accessor_g2end_step), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_g2end_step_t _grib_accessor_class_g2end_step{ "g2end_step" }; grib_accessor_class* grib_accessor_class_g2end_step = &_grib_accessor_class_g2end_step; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) +void grib_accessor_class_g2end_step_t::init(grib_accessor* a, const long l, grib_arguments* c) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; - int n = 0; - grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); self->start_step_value = grib_arguments_get_name(h, c, n++); self->step_units = grib_arguments_get_name(h, c, n++); @@ -173,31 +42,31 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->minute_of_end_of_interval = grib_arguments_get_name(h, c, n++); self->second_of_end_of_interval = grib_arguments_get_name(h, c, n++); - self->time_range_unit = grib_arguments_get_name(h, c, n++); + self->time_range_unit = grib_arguments_get_name(h, c, n++); self->time_range_value = grib_arguments_get_name(h, c, n++); self->typeOfTimeIncrement = grib_arguments_get_name(h, c, n++); self->numberOfTimeRange = grib_arguments_get_name(h, c, n++); } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_g2end_step_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_double(dumper, a, NULL); } // See GRIB-488 -static bool is_special_expver(const grib_handle* h) +bool is_special_expver(const grib_handle* h) { - int ret = 0; + int ret = 0; char strMarsExpVer[50] = {0,}; char strMarsClass[50] = {0,}; size_t slen = 50; - ret = grib_get_string(h, "mars.class", strMarsClass, &slen); + ret = grib_get_string(h, "mars.class", strMarsClass, &slen); if (ret == GRIB_SUCCESS && STR_EQUAL(strMarsClass, "em")) { // em = ERA-CLIM model integration for the 20th-century (ERA-20CM) slen = 50; - ret = grib_get_string(h, "experimentVersionNumber", strMarsExpVer, &slen); + ret = grib_get_string(h, "experimentVersionNumber", strMarsExpVer, &slen); if (ret == GRIB_SUCCESS && STR_EQUAL(strMarsExpVer, "1605")) { - return true; // Special case of expVer 1605 in class "em" + return true; // Special case of expVer 1605 in class "em" } } @@ -214,8 +83,8 @@ static int convert_time_range_long_( Assert(lengthOfTimeRange != NULL); if (indicatorOfUnitForTimeRange != stepUnits) { - eccodes::Step time_range{*lengthOfTimeRange, indicatorOfUnitForTimeRange}; - time_range.set_unit(eccodes::Unit{stepUnits}); + eccodes::Step time_range{ *lengthOfTimeRange, indicatorOfUnitForTimeRange }; + time_range.set_unit(eccodes::Unit{ stepUnits }); if (time_range.value() != time_range.value()) { return GRIB_DECODING_ERROR; } @@ -227,8 +96,8 @@ static int convert_time_range_long_( static int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; - int err = 0; + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; + int err = 0; long start_step_value; long step_units; long time_range_unit; @@ -262,18 +131,22 @@ static int unpack_one_time_range_long_(grib_accessor* a, long* val, size_t* len) } if (add_time_range) { *val = start_step_value + time_range_value; + if ((err = grib_set_long_internal(h, "endStepUnit", step_units)) != GRIB_SUCCESS) + return err; } else { *val = start_step_value; + if ((err = grib_set_long_internal(h, "endStepUnit", step_units)) != GRIB_SUCCESS) + return err; } return GRIB_SUCCESS; } -static int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* len) +static int unpack_one_time_range_double_(grib_accessor* a, double* val, size_t* len) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; - int err = 0; + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; + int err = 0; double start_step_value; long start_step_unit; long step_units; @@ -297,8 +170,8 @@ static int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* if ((err = grib_get_long_internal(h, self->typeOfTimeIncrement, &typeOfTimeIncrement))) return err; - eccodes::Step start_step{start_step_value, start_step_unit}; - eccodes::Step time_range{time_range_value, time_range_unit}; + eccodes::Step start_step{ start_step_value, start_step_unit }; + eccodes::Step time_range{ time_range_value, time_range_unit }; if (typeOfTimeIncrement == 1) { /* See GRIB-488 */ @@ -310,9 +183,13 @@ static int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* } if (add_time_range) { *val = (start_step + time_range).value(eccodes::Unit(step_units)); + if ((err = grib_set_long_internal(h, "endStepUnit", step_units)) != GRIB_SUCCESS) + return err; } else { *val = start_step.value(eccodes::Unit(start_step_unit)); + if ((err = grib_set_long_internal(h, "endStepUnit", start_step_unit)) != GRIB_SUCCESS) + return err; } return GRIB_SUCCESS; @@ -321,15 +198,21 @@ static int unpack_one_time_range_double_(grib_accessor* a, double *val , size_t* #define MAX_NUM_TIME_RANGES 16 /* maximum number of time range specifications */ static int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t* len) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int i = 0, err = 0; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); long numberOfTimeRange = 0, step_units = 0, start_step_value = 0; - size_t count = 0; - long arr_typeOfTimeIncrement[MAX_NUM_TIME_RANGES] = {0,}; - long arr_coded_unit[MAX_NUM_TIME_RANGES] = {0,}; - long arr_coded_time_range[MAX_NUM_TIME_RANGES] = {0,}; + size_t count = 0; + long arr_typeOfTimeIncrement[MAX_NUM_TIME_RANGES] = { + 0, + }; + long arr_coded_unit[MAX_NUM_TIME_RANGES] = { + 0, + }; + long arr_coded_time_range[MAX_NUM_TIME_RANGES] = { + 0, + }; if ((err = grib_get_long_internal(h, self->start_step_value, &start_step_value))) return err; @@ -374,29 +257,35 @@ static int unpack_multiple_time_ranges_long_(grib_accessor* a, long* val, size_t static int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, size_t* len) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; int i = 0, err = 0; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); long numberOfTimeRange = 0; - long step_units = 0; - long start_step_value = 0; - long start_step_unit = 0; + long step_units = 0; + long start_step_value = 0; + long start_step_unit = 0; - size_t count = 0; - long arr_typeOfTimeIncrement[MAX_NUM_TIME_RANGES] = {0, }; - long arr_coded_unit[MAX_NUM_TIME_RANGES] = {0, }; - long arr_coded_time_range[MAX_NUM_TIME_RANGES] = {0, }; + size_t count = 0; + long arr_typeOfTimeIncrement[MAX_NUM_TIME_RANGES] = { + 0, + }; + long arr_coded_unit[MAX_NUM_TIME_RANGES] = { + 0, + }; + long arr_coded_time_range[MAX_NUM_TIME_RANGES] = { + 0, + }; if ((err = grib_get_long_internal(h, self->start_step_value, &start_step_value))) return err; if ((err = grib_get_long_internal(h, "startStepUnit", &start_step_unit))) return err; - eccodes::Step start_step{start_step_value, start_step_unit}; + eccodes::Step start_step{ start_step_value, start_step_unit }; if ((err = grib_get_long_internal(h, self->step_units, &step_units))) return err; - + if ((err = grib_get_long_internal(h, self->numberOfTimeRange, &numberOfTimeRange))) return err; if (numberOfTimeRange > MAX_NUM_TIME_RANGES) { @@ -420,7 +309,7 @@ static int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, si long the_coded_unit = arr_coded_unit[i]; long the_coded_time_range = arr_coded_time_range[i]; - eccodes::Step time_range{the_coded_unit, the_coded_time_range}; + eccodes::Step time_range{ the_coded_unit, the_coded_time_range }; *val = (start_step + time_range).value(eccodes::Unit(step_units)); return GRIB_SUCCESS; @@ -435,20 +324,25 @@ static int unpack_multiple_time_ranges_double_(grib_accessor* a, double* val, si // For the old implementation of unpack_long, see // src/deprecated/grib_accessor_class_g2end_step.unpack_long.cc // -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_g2end_step_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; long start_step_value; + long start_step_unit; long numberOfTimeRange; if ((ret = grib_get_long_internal(h, self->start_step_value, &start_step_value))) return ret; + if ((ret = grib_get_long_internal(h, "startStepUnit", &start_step_unit))) + return ret; /* point in time */ if (self->year == NULL) { *val = start_step_value; + if ((ret = grib_set_long_internal(h, "endStepUnit", start_step_unit))) + return ret; return 0; } @@ -459,36 +353,39 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) try { if (numberOfTimeRange == 1) { - ret = unpack_one_time_range_long_(a, val, len); - return ret; + ret = unpack_one_time_range_long_(a, val, len); } else { ret = unpack_multiple_time_ranges_long_(a, val, len); - return ret; } } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::unpack_long: %s", e.what()); - return GRIB_DECODING_ERROR; + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::unpack_long: %s", e.what()); + ret = GRIB_DECODING_ERROR; } - return GRIB_SUCCESS; + return ret; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_g2end_step_t::unpack_double(grib_accessor* a, double* val, size_t* len) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; long start_step_value; + long start_step_unit; long numberOfTimeRange; if ((ret = grib_get_long_internal(h, self->start_step_value, &start_step_value))) return ret; + if ((ret = grib_get_long_internal(h, "startStepUnit", &start_step_unit))) + return ret; /* point in time */ if (self->year == NULL) { *val = start_step_value; + if ((ret = grib_set_long_internal(h, "endStepUnit", start_step_unit))) + return ret; return 0; } @@ -499,27 +396,25 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) try { if (numberOfTimeRange == 1) { - ret = unpack_one_time_range_double_(a, val, len); - return ret; + ret = unpack_one_time_range_double_(a, val, len); } else { ret = unpack_multiple_time_ranges_double_(a, val, len); - return ret; } } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::unpack_double: %s", e.what()); - return GRIB_DECODING_ERROR; + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::unpack_double: %s", e.what()); + ret = GRIB_DECODING_ERROR; } - return GRIB_SUCCESS; + return ret; } static int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_unit) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; - grib_handle* h = grib_handle_of_accessor(a); - int err = 0; + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int err = 0; long year; long month; @@ -542,11 +437,12 @@ static int pack_long_(grib_accessor* a, const long end_step_value, const long en double dend, dstep; const int show_units_for_hours = a->context->grib_hourly_steps_with_units; - eccodes::Step end_step{end_step_value, end_step_unit}; + eccodes::Step end_step{ end_step_value, end_step_unit }; /*point in time */ if (self->year == NULL) { - err = grib_set_long_internal(h, "startStepUnit", end_step.unit().value()); + if ((err = grib_set_long_internal(h, "startStepUnit", end_step.unit().value())) != GRIB_SUCCESS) + return err; err = grib_set_long_internal(h, self->start_step_value, end_step.value()); return err; } @@ -572,10 +468,10 @@ static int pack_long_(grib_accessor* a, const long end_step_value, const long en return err; long force_step_units; - if ((err= grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) + if ((err = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) return err; - if (eccodes::Unit{start_step_unit} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ start_step_unit } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { grib_context_log(h->context, GRIB_LOG_ERROR, "missing start step unit"); return GRIB_WRONG_STEP_UNIT; @@ -584,7 +480,7 @@ static int pack_long_(grib_accessor* a, const long end_step_value, const long en if ((err = grib_get_long_internal(h, self->typeOfTimeIncrement, &typeOfTimeIncrement))) return err; - eccodes::Step start_step{start_step_value, start_step_unit}; + eccodes::Step start_step{ start_step_value, start_step_unit }; eccodes::Step time_range = end_step - start_step; if (time_range.value() < 0) { @@ -599,7 +495,7 @@ static int pack_long_(grib_accessor* a, const long end_step_value, const long en if (err != GRIB_SUCCESS) return err; - dstep = end_step.value(eccodes::Unit{eccodes::Unit::Value::DAY}); + dstep = end_step.value(eccodes::Unit{ eccodes::Unit::Value::DAY }); dend += dstep; err = grib_julian_to_datetime(dend, &year_of_end_of_interval, &month_of_end_of_interval, @@ -622,15 +518,15 @@ static int pack_long_(grib_accessor* a, const long end_step_value, const long en return err; const char* forecast_time_value_key = "forecastTime"; - const char* forecast_time_unit_key = "indicatorOfUnitOfTimeRange"; + const char* forecast_time_unit_key = "indicatorOfUnitOfTimeRange"; eccodes::Step forecast_time_opt; eccodes::Step time_range_opt; - if (eccodes::Unit{force_step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ force_step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { std::tie(forecast_time_opt, time_range_opt) = find_common_units(start_step.optimize_unit(), time_range.optimize_unit()); } else { - forecast_time_opt = eccodes::Step{start_step.value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; - time_range_opt = eccodes::Step{time_range.value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; + forecast_time_opt = eccodes::Step{ start_step.value(eccodes::Unit{ force_step_units }), eccodes::Unit{ force_step_units } }; + time_range_opt = eccodes::Step{ time_range.value(eccodes::Unit{ force_step_units }), eccodes::Unit{ force_step_units } }; } if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->time_range_value, time_range_opt.value())) != GRIB_SUCCESS) @@ -645,14 +541,14 @@ static int pack_long_(grib_accessor* a, const long end_step_value, const long en return GRIB_SUCCESS; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) +int grib_accessor_class_g2end_step_t::unpack_string(grib_accessor* a, char* val, size_t* len) { - grib_accessor_g2end_step* self = (grib_accessor_g2end_step*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - char fp_format[128] = "%g"; - size_t fp_format_len = sizeof(fp_format); - size_t step_len = 0; + grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + char fp_format[128] = "%g"; + size_t fp_format_len = sizeof(fp_format); + size_t step_len = 0; long step_value; long step_units; const int show_units_for_hours = a->context->grib_hourly_steps_with_units; @@ -682,14 +578,14 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) memcpy(val, ss.str().c_str(), size); } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::unpack_string: %s", e.what()); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::unpack_string: %s", e.what()); return GRIB_DECODING_ERROR; } return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_g2end_step_t::pack_long(grib_accessor* a, const long* val, size_t* len) { grib_handle* h = grib_handle_of_accessor(a); int ret; @@ -700,12 +596,12 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) try { long end_step_unit; - if (eccodes::Unit{force_step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { + if (eccodes::Unit{ force_step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { if ((ret = grib_get_long_internal(h, "endStepUnit", &end_step_unit)) != GRIB_SUCCESS) return ret; - if (eccodes::Unit{end_step_unit} == eccodes::Unit{eccodes::Unit::Value::MISSING}) - end_step_unit = eccodes::Unit{eccodes::Unit::Value::HOUR}.value(); + if (eccodes::Unit{ end_step_unit } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) + end_step_unit = eccodes::Unit{ eccodes::Unit::Value::HOUR }.value(); } else { end_step_unit = force_step_units; @@ -713,22 +609,22 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) ret = pack_long_(a, *val, end_step_unit); } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::pack_long: %s", e.what()); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::pack_long: %s", e.what()); return GRIB_DECODING_ERROR; } return ret; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) +int grib_accessor_class_g2end_step_t::pack_string(grib_accessor* a, const char* val, size_t* len) { grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; + int ret = 0; long force_step_units; if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) return ret; try { - eccodes::Step end_step = step_from_string(val, eccodes::Unit{force_step_units}); + eccodes::Step end_step = step_from_string(val, eccodes::Unit{ force_step_units }); end_step.optimize_unit(); if ((ret = grib_set_long_internal(h, "endStepUnit", end_step.unit().value())) != GRIB_SUCCESS) @@ -738,22 +634,22 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return ret; } catch (std::exception& e) { - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step::pack_string: %s", e.what()); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_accessor_g2end_step_t::pack_string: %s", e.what()); return GRIB_DECODING_ERROR; } return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_g2end_step_t::get_native_type(grib_accessor* a) { - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); const int show_units_for_hours = a->context->grib_hourly_steps_with_units; if (!show_units_for_hours) { long step_units = 0; if (grib_get_long_internal(h, "stepUnits", &step_units) == GRIB_SUCCESS) { - if (eccodes::Unit{step_units} == eccodes::Unit::Value::HOUR) { - return GRIB_TYPE_LONG; // For backward compatibility + if (eccodes::Unit{ step_units } == eccodes::Unit::Value::HOUR) { + return GRIB_TYPE_LONG; // For backward compatibility } } } diff --git a/src/accessor/grib_accessor_class_g2end_step.h b/src/accessor/grib_accessor_class_g2end_step.h new file mode 100644 index 000000000..d3a3b1433 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2end_step.h @@ -0,0 +1,53 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g2end_step_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2end_step */ + const char* start_step_value; + const char* step_units; + const char* year; + const char* month; + const char* day; + const char* hour; + const char* minute; + const char* second; + const char* year_of_end_of_interval; + const char* month_of_end_of_interval; + const char* day_of_end_of_interval; + const char* hour_of_end_of_interval; + const char* minute_of_end_of_interval; + const char* second_of_end_of_interval; + const char* time_range_unit; + const char* time_range_value; + const char* typeOfTimeIncrement; + const char* numberOfTimeRange; +}; + +class grib_accessor_class_g2end_step_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2end_step_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2end_step_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_g2grid.cc b/src/accessor/grib_accessor_class_g2grid.cc similarity index 57% rename from src/grib_accessor_class_g2grid.cc rename to src/accessor/grib_accessor_class_g2grid.cc index 40aaca628..3bc0a9a22 100644 --- a/src/grib_accessor_class_g2grid.cc +++ b/src/accessor/grib_accessor_class_g2grid.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,119 +9,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double;value_count - IMPLEMENTS = init - MEMBERS=const char* latitude_first - MEMBERS=const char* longitude_first - MEMBERS=const char* latitude_last - MEMBERS=const char* longitude_last - MEMBERS=const char* i_increment - MEMBERS=const char* j_increment - MEMBERS=const char* basic_angle - MEMBERS=const char* sub_division - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2grid -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in g2grid */ - const char* latitude_first; - const char* longitude_first; - const char* latitude_last; - const char* longitude_last; - const char* i_increment; - const char* j_increment; - const char* basic_angle; - const char* sub_division; -} grib_accessor_g2grid; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_g2grid = { - &grib_accessor_class_double, /* super */ - "g2grid", /* name */ - sizeof(grib_accessor_g2grid), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g2grid.h" +grib_accessor_class_g2grid_t _grib_accessor_class_g2grid{ "g2grid" }; grib_accessor_class* grib_accessor_class_g2grid = &_grib_accessor_class_g2grid; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) +void grib_accessor_class_g2grid_t::init(grib_accessor* a, const long l, grib_arguments* c) { - grib_accessor_g2grid* self = (grib_accessor_g2grid*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->latitude_first = grib_arguments_get_name(hand, c, n++); self->longitude_first = grib_arguments_get_name(hand, c, n++); @@ -136,7 +36,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_g2grid_t::value_count(grib_accessor* a, long* count) { *count = 6; return 0; @@ -145,17 +45,16 @@ static int value_count(grib_accessor* a, long* count) // GRIB edition 2 uses microdegrees #define ANGLE_SUBDIVISIONS (1000 * 1000) -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_g2grid_t::unpack_double(grib_accessor* a, double* val, size_t* len) { - grib_accessor_g2grid* self = (grib_accessor_g2grid*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; + grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; long basic_angle = 0; long sub_division = 0; - int n = 0; + int n = 0; long v[6]; - int i; if (*len < 6) { ret = GRIB_ARRAY_TOO_SMALL; @@ -195,11 +94,12 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) if (!self->j_increment) { v[n++] = GRIB_MISSING_LONG; - } else { + } + else { if ((ret = grib_get_long_internal(hand, self->j_increment, &v[n++])) != GRIB_SUCCESS) return ret; } - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) if (v[i] == GRIB_MISSING_LONG) val[i] = GRIB_MISSING_DOUBLE; else @@ -278,10 +178,10 @@ static int trial(const double* val, long v[6], long* basic_angle, long* sub_divi return is_ok(val, v, *basic_angle, *sub_division); } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_g2grid_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_g2grid* self = (grib_accessor_g2grid*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_accessor_g2grid_t* self = (grib_accessor_g2grid_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); int ret; long v[6]; int n; @@ -289,8 +189,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) long sub_division; if (*len < 6) { - ret = GRIB_ARRAY_TOO_SMALL; - return ret; + return GRIB_ARRAY_TOO_SMALL; } /* printf("pack_double %g %g %g %g %g %g\n",val[0],val[1],val[2],val[3],val[4],val[5]);*/ diff --git a/src/accessor/grib_accessor_class_g2grid.h b/src/accessor/grib_accessor_class_g2grid.h new file mode 100644 index 000000000..07c9f9862 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2grid.h @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_g2grid_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2grid */ + const char* latitude_first; + const char* longitude_first; + const char* latitude_last; + const char* longitude_last; + const char* i_increment; + const char* j_increment; + const char* basic_angle; + const char* sub_division; +}; + +class grib_accessor_class_g2grid_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2grid_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2grid_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g2latlon.cc b/src/accessor/grib_accessor_class_g2latlon.cc new file mode 100644 index 000000000..afb3a2f7a --- /dev/null +++ b/src/accessor/grib_accessor_class_g2latlon.cc @@ -0,0 +1,120 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g2latlon.h" + +grib_accessor_class_g2latlon_t _grib_accessor_class_g2latlon{ "g2latlon" }; +grib_accessor_class* grib_accessor_class_g2latlon = &_grib_accessor_class_g2latlon; + + +void grib_accessor_class_g2latlon_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + int n = 0; + + self->grid = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + self->given = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_g2latlon_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + int ret = 0; + + long given = 1; + double grid[6]; + size_t size = 6; + + if (*len < 1) { + ret = GRIB_ARRAY_TOO_SMALL; + return ret; + } + + if (self->given) + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given)) != GRIB_SUCCESS) + return ret; + + if (!given) { + *val = GRIB_MISSING_DOUBLE; + return GRIB_SUCCESS; + } + + if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->grid, grid, &size)) != GRIB_SUCCESS) + return ret; + + *val = grid[self->index]; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2latlon_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + int ret = 0; + double grid[6]; + size_t size = 6; + double new_val = *val; + grib_handle* hand = grib_handle_of_accessor(a); + + if (*len < 1) { + ret = GRIB_ARRAY_TOO_SMALL; + return ret; + } + + if (self->given) { + long given = *val != GRIB_MISSING_DOUBLE; + if ((ret = grib_set_long_internal(hand, self->given, given)) != GRIB_SUCCESS) + return ret; + } + + if ((ret = grib_get_double_array_internal(hand, self->grid, grid, &size)) != GRIB_SUCCESS) + return ret; + + /* index 1 is longitudeOfFirstGridPointInDegrees + * index 3 is longitudeOfLastGridPointInDegrees + */ + if ((self->index == 1 || self->index == 3)) { + /* WMO regulation for GRIB edition 2: + * The longitude values shall be limited to the range 0 to 360 degrees inclusive */ + new_val = normalise_longitude_in_degrees(*val); + if (hand->context->debug && new_val != *val) { + fprintf(stderr, "ECCODES DEBUG pack_double g2latlon: normalise longitude %g -> %g\n", *val, new_val); + } + } + grid[self->index] = new_val; + + return grib_set_double_array_internal(hand, self->grid, grid, size); +} + +int grib_accessor_class_g2latlon_t::pack_missing(grib_accessor* a) +{ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + double missing = GRIB_MISSING_DOUBLE; + size_t size = 1; + + if (!self->given) + return GRIB_NOT_IMPLEMENTED; + + return pack_double(a, &missing, &size); +} + +int grib_accessor_class_g2latlon_t::is_missing(grib_accessor* a) +{ + grib_accessor_g2latlon_t* self = (grib_accessor_g2latlon_t*)a; + long given = 1; + + if (self->given) + grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given); + + return !given; +} diff --git a/src/accessor/grib_accessor_class_g2latlon.h b/src/accessor/grib_accessor_class_g2latlon.h new file mode 100644 index 000000000..f4733757e --- /dev/null +++ b/src/accessor/grib_accessor_class_g2latlon.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_g2latlon_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2latlon */ + const char* grid; + int index; + const char* given; +}; + +class grib_accessor_class_g2latlon_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2latlon_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2latlon_t{}; } + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_g2level.cc b/src/accessor/grib_accessor_class_g2level.cc similarity index 52% rename from src/grib_accessor_class_g2level.cc rename to src/accessor/grib_accessor_class_g2level.cc index e1d8aaa38..8da0be27f 100644 --- a/src/grib_accessor_class_g2level.cc +++ b/src/accessor/grib_accessor_class_g2level.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,114 +9,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_long;pack_long;init;dump;is_missing - MEMBERS=const char* type_first - MEMBERS=const char* scale_first - MEMBERS=const char* value_first - MEMBERS=const char* pressure_units - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2level -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g2level */ - const char* type_first; - const char* scale_first; - const char* value_first; - const char* pressure_units; -} grib_accessor_g2level; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g2level = { - &grib_accessor_class_long, /* super */ - "g2level", /* name */ - sizeof(grib_accessor_g2level), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_g2level.h" +grib_accessor_class_g2level_t _grib_accessor_class_g2level{ "g2level" }; grib_accessor_class* grib_accessor_class_g2level = &_grib_accessor_class_g2level; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) +void grib_accessor_class_g2level_t::init(grib_accessor* a, const long l, grib_arguments* c) { - grib_accessor_g2level* self = (grib_accessor_g2level*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->type_first = grib_arguments_get_name(hand, c, n++); self->scale_first = grib_arguments_get_name(hand, c, n++); @@ -126,31 +31,26 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->flags |= GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static bool is_tigge(grib_handle* h) +bool is_tigge(grib_handle* h) { long productionStatus = 0; - int err = grib_get_long(h, "productionStatusOfProcessedData", &productionStatus); + int err = grib_get_long(h, "productionStatusOfProcessedData", &productionStatus); if (err) return false; return (productionStatus == 4 || productionStatus == 5); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) +int grib_accessor_class_g2level_t::unpack_double(grib_accessor* a, double* val, size_t* len) { - int ret = 0; - grib_accessor_g2level* self = (grib_accessor_g2level*)a; - grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); long type_first = 0; long scale_first = 0; long value_first = 0; char pressure_units[10] = {0,}; size_t pressure_units_len = 10; - bool tigge = is_tigge(hand); + bool tigge = is_tigge(hand); double v; @@ -178,8 +78,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) // GRIB-637, ECC-1081: Potential vorticity surface if (type_first == 109) { if (tigge) { - scale_first -= 6; // TIGGE data follows different rules - } else { + scale_first -= 6; // TIGGE data follows different rules + } + else { scale_first -= 9; } } @@ -195,9 +96,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) } switch (type_first) { - case 100: // Isobaric surface (Pa) + case 100: // Isobaric surface (Pa) if (!strcmp(pressure_units, "hPa")) { - long x = v / 100.0; // 1 hPa = 100 Pa + long x = v / 100.0; // 1 hPa = 100 Pa if (scale_first == 0 && x == 0) { // Switch to Pa instead of hPa as the value is less than a hectoPascal char pa[] = "Pa"; @@ -217,29 +118,29 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_g2level_t::unpack_long(grib_accessor* a, long* val, size_t* len) { double dval = 0; int ret = unpack_double(a, &dval, len); if (ret == GRIB_SUCCESS) { - *val = (long)(dval + 0.5); // round up + *val = (long)(dval + 0.5); // round up } return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) +int grib_accessor_class_g2level_t::pack_double(grib_accessor* a, const double* val, size_t* len) { - grib_accessor_g2level* self = (grib_accessor_g2level*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - double value_first = *val; - //long scale_first = 0; - long type_first = 0; - char pressure_units[10] = {0,}; - size_t pressure_units_len = 10; - const long lval = (long)value_first; + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + double value_first = *val; + // long scale_first = 0; + long type_first = 0; + char pressure_units[10] = {0,}; + size_t pressure_units_len = 10; + const long lval = (long)value_first; - if (value_first == lval) { // input is a whole number; process it as an integer + if (value_first == lval) { // input is a whole number; process it as an integer return pack_long(a, &lval, len); } @@ -253,7 +154,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return ret; switch (type_first) { - case 100: // Pa + case 100: // Pa if (!strcmp(pressure_units, "hPa")) value_first *= 100; break; @@ -264,14 +165,14 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) // final = scaled_value * 10 ^ -scale_factor - //scale_first = 2; - //value_first *= 100; - //value_first = value_first + 0.5; //round up + // scale_first = 2; + // value_first *= 100; + // value_first = value_first + 0.5; //round up // TODO(masn): These maxima should come from the respective accessors - const int64_t scaled_value_max = (1ULL << 32) - 1; // scaledValueOf*FixedSurface is 4 octets - const int64_t scale_factor_max = (1ULL << 8) - 1; // scaleFactorOf*FixedSurface is 1 octet - int64_t lscaled_value=0, lscale_factor=0; + const int64_t scaled_value_max = (1ULL << 32) - 1; // scaledValueOf*FixedSurface is 4 octets + const int64_t scale_factor_max = (1ULL << 8) - 1; // scaleFactorOf*FixedSurface is 1 octet + int64_t lscaled_value = 0, lscale_factor = 0; ret = compute_scaled_value_and_scale_factor(value_first, scaled_value_max, scale_factor_max, &lscaled_value, &lscale_factor); if (ret) { @@ -290,7 +191,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_g2level_t::pack_long(grib_accessor* a, const long* val, size_t* len) { int ret = 0; long value_first = *val; @@ -299,10 +200,10 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) char pressure_units[10] = {0,}; size_t pressure_units_len = 10; - grib_accessor_g2level* self = (grib_accessor_g2level*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int change_scale_and_value = 1; - bool tigge = is_tigge(hand); + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int change_scale_and_value = 1; + bool tigge = is_tigge(hand); if (*len != 1) return GRIB_WRONG_ARRAY_SIZE; @@ -323,16 +224,17 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return ret; switch (type_first) { - case 100: // Pa + case 100: // Pa scale_first = 0; if (!strcmp(pressure_units, "hPa")) value_first *= 100; break; - case 109: // Potential vorticity surface (See ECC-1081) + case 109: // Potential vorticity surface (See ECC-1081) if (!tigge) { scale_first = 9; - } else { - scale_first = 6; // TIGGE data follows different rules + } + else { + scale_first = 6; // TIGGE data follows different rules } break; @@ -365,14 +267,13 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int is_missing(grib_accessor* a) +int grib_accessor_class_g2level_t::is_missing(grib_accessor* a) { - grib_accessor_g2level* self = (grib_accessor_g2level*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int err = 0; - int ret = 0; + grib_accessor_g2level_t* self = (grib_accessor_g2level_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int err = 0; - ret = grib_is_missing(hand, self->scale_first, &err) + + int ret = grib_is_missing(hand, self->scale_first, &err) + grib_is_missing(hand, self->value_first, &err); return ret; } diff --git a/src/accessor/grib_accessor_class_g2level.h b/src/accessor/grib_accessor_class_g2level.h new file mode 100644 index 000000000..55511b8f0 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2level.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_g2level_t : public grib_accessor_long_t +{ +public: + /* Members defined in g2level */ + const char* type_first; + const char* scale_first; + const char* value_first; + const char* pressure_units; +}; + +class grib_accessor_class_g2level_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_g2level_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2level_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g2lon.cc b/src/accessor/grib_accessor_class_g2lon.cc new file mode 100644 index 000000000..b7cb43d03 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2lon.cc @@ -0,0 +1,61 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g2lon.h" + +grib_accessor_class_g2lon_t _grib_accessor_class_g2lon{ "g2lon" }; +grib_accessor_class* grib_accessor_class_g2lon = &_grib_accessor_class_g2lon; + + +void grib_accessor_class_g2lon_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; + int n = 0; + + self->longitude = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_g2lon_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; + int ret = 0; + long longitude; + + if ((ret = grib_get_long(grib_handle_of_accessor(a), self->longitude, &longitude)) != GRIB_SUCCESS) + return ret; + + if (longitude == GRIB_MISSING_LONG) { + *val = GRIB_MISSING_DOUBLE; + return GRIB_SUCCESS; + } + + *val = ((double)longitude) / 1000000.0; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2lon_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + grib_accessor_g2lon_t* self = (grib_accessor_g2lon_t*)a; + long longitude; + double value = *val; + + if (value == GRIB_MISSING_DOUBLE) { + longitude = GRIB_MISSING_LONG; + } + else { + if (value < 0) + value += 360; + longitude = (long)(value * 1000000); + } + return grib_set_long(grib_handle_of_accessor(a), self->longitude, longitude); +} diff --git a/src/accessor/grib_accessor_class_g2lon.h b/src/accessor/grib_accessor_class_g2lon.h new file mode 100644 index 000000000..d3f5bd8ff --- /dev/null +++ b/src/accessor/grib_accessor_class_g2lon.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_g2lon_t : public grib_accessor_double_t +{ +public: + /* Members defined in g2lon */ + const char* longitude; +}; + +class grib_accessor_class_g2lon_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_g2lon_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2lon_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_g2step_range.cc b/src/accessor/grib_accessor_class_g2step_range.cc new file mode 100644 index 000000000..0c1b49e21 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2step_range.cc @@ -0,0 +1,275 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_g2step_range.h" +#include "step.h" +#include "step_utilities.h" +#include + + +grib_accessor_class_g2step_range_t _grib_accessor_class_g2step_range{ "g2step_range" }; +grib_accessor_class* grib_accessor_class_g2step_range = &_grib_accessor_class_g2step_range; + + +void grib_accessor_class_g2step_range_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_gen_t::init(a, l, c); + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; + + int n = 0; + + self->start_step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->end_step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->length = 0; +} + +// static void dump(grib_accessor* a, grib_dumper* dumper) +//{ +// grib_dump_string(dumper, a, NULL); +//} + +int grib_accessor_class_g2step_range_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + size_t size = 0; + double start_step_value = 0; + double end_step_value = 0; + long step_units; + + int show_hours = a->context->grib_hourly_steps_with_units; + + if ((ret = grib_get_double_internal(h, self->start_step, &start_step_value)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) + return ret; + try { + if (eccodes::Unit{ step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { + if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) + return ret; + } + + char fp_format[128] = "%g"; + size_t fp_format_len = sizeof(fp_format); + if ((ret = grib_get_string_internal(h, "formatForDoubles", fp_format, &fp_format_len)) != GRIB_SUCCESS) + return ret; + std::stringstream ss; + + eccodes::Step start_step{ start_step_value, step_units }; + if (self->end_step == NULL) { + ss << start_step.value(fp_format, show_hours); + } + else { + if ((ret = grib_get_double_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) + return ret; + + eccodes::Step end_step{ end_step_value, step_units }; + + if (start_step_value == end_step_value) { + ss << end_step.value(fp_format, show_hours); + } + else { + ss << start_step.value(fp_format, show_hours) << "-" << end_step.value(fp_format, show_hours); + } + } + + size = ss.str().size() + 1; + + if (*len < size) + return GRIB_ARRAY_TOO_SMALL; + + *len = size; + + memcpy(val, ss.str().c_str(), size); + } + catch (std::exception& e) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g2step_range_t::unpack_string: %s", e.what()); + return GRIB_DECODING_ERROR; + } + + return GRIB_SUCCESS; +} + +// Step range format: [-] +// and can be in different units +// stepRange="X" in instantaneous field is equivalent to set step=X +// stepRange="X" in accumulated field is equivalent to startStep=X, endStep=startStep +int grib_accessor_class_g2step_range_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + + long force_step_units; + if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) + return ret; + + // Note: + // forceStepUnits is a special key that is used to identify the origin of the defined units + // i.e., whether they have been defined by the user. + // If this key is defined (!= 255), it indicates that the stepUnits have been defined by the user. + // Once this key is set, it has the highest priority: it automatically overrides certain units and the default value in stepUnits + + if (h->loader) { // h->loader is set only when rebuilding or reparsing + force_step_units = 255; // See ECC-1768 and ECC-1800 + } + + try { + std::vector steps = parse_range(val, eccodes::Unit{ force_step_units }); + if (steps.size() == 0) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Could not parse step range: %s", val); + return GRIB_INVALID_ARGUMENT; + } + + eccodes::Step step_0; + eccodes::Step step_1; + if (eccodes::Unit{ force_step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { + if (steps.size() > 1) + std::tie(step_0, step_1) = find_common_units(steps[0].optimize_unit(), steps[1].optimize_unit()); + else + step_0 = steps[0].optimize_unit(); + } + else { + step_0 = eccodes::Step{ steps[0].value(eccodes::Unit{ force_step_units }), eccodes::Unit{ force_step_units } }; + if (steps.size() > 1) { + step_1 = eccodes::Step{ steps[1].value(eccodes::Unit{ force_step_units }), eccodes::Unit{ force_step_units } }; + } + } + + if ((ret = grib_set_long_internal(h, "startStepUnit", step_0.unit().value()))) + return ret; + if ((ret = set_step(h, "forecastTime", "indicatorOfUnitOfTimeRange", step_0)) != GRIB_SUCCESS) + return ret; + + if (self->end_step != NULL) { + if (steps.size() > 1) { + if ((ret = grib_set_long_internal(h, "endStepUnit", step_1.unit().value()))) + return ret; + if ((ret = grib_set_long_internal(h, self->end_step, step_1.value()))) + return ret; + } + else { + if ((ret = grib_set_long_internal(h, "endStepUnit", step_0.unit().value()))) + return ret; + if ((ret = grib_set_long_internal(h, self->end_step, step_0.value()))) + return ret; + } + } + } + catch (std::exception& e) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_g2step_range::pack_string: %s", e.what()); + return GRIB_INVALID_ARGUMENT; + } + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2step_range_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +size_t grib_accessor_class_g2step_range_t::string_length(grib_accessor* a) +{ + return 255; +} + +int grib_accessor_class_g2step_range_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + char buff[100]; + size_t bufflen = 100; + + snprintf(buff, sizeof(buff), "%ld", *val); + return pack_string(a, buff, &bufflen); +} + +int grib_accessor_class_g2step_range_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + long end_start_value = 0; + long end_step_value = 0; + long step_units = 0; + + if ((ret = grib_get_long_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS) + return ret; + try { + if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) + throw std::runtime_error("Failed to get stepUnits"); + if (eccodes::Unit{ step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { + if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) + return ret; + } + + eccodes::Step start_step{ end_start_value, step_units }; + if (self->end_step == NULL) { + *val = start_step.value(); + } + else { + if ((ret = grib_get_long_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) + return ret; + eccodes::Step end_step{ end_step_value, step_units }; + *val = end_step.value(); + } + } + catch (std::exception& e) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Failed to unpack step range: %s", e.what()); + return GRIB_DECODING_ERROR; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2step_range_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_accessor_g2step_range_t* self = (grib_accessor_g2step_range_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = 0; + double end_start_value = 0; + double end_step_value = 0; + long step_units = 0; + + if ((ret = grib_get_double_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) + throw std::runtime_error("Failed to get stepUnits"); + + try { + if (eccodes::Unit{ step_units } == eccodes::Unit{ eccodes::Unit::Value::MISSING }) { + if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) + return ret; + } + + eccodes::Step start_step{ end_start_value, step_units }; + if (self->end_step == NULL) { + *val = start_step.value(); + } + else { + if ((ret = grib_get_double_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) + return ret; + eccodes::Step end_step{ end_step_value, step_units }; + *val = end_step.value(); + } + } + catch (std::exception& e) { + grib_context_log(a->context, GRIB_LOG_ERROR, "grid_accessor_g2step_range::unpack_double: %s", e.what()); + return GRIB_DECODING_ERROR; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_g2step_range_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_STRING; +} diff --git a/src/accessor/grib_accessor_class_g2step_range.h b/src/accessor/grib_accessor_class_g2step_range.h new file mode 100644 index 000000000..ec44546b3 --- /dev/null +++ b/src/accessor/grib_accessor_class_g2step_range.h @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_g2step_range_t : public grib_accessor_gen_t +{ +public: + /* Members defined in g2step_range */ + const char* start_step; + const char* end_step; +}; + +class grib_accessor_class_g2step_range_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_g2step_range_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_g2step_range_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.cc b/src/accessor/grib_accessor_class_gaussian_grid_name.cc new file mode 100644 index 000000000..f6b79e794 --- /dev/null +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.cc @@ -0,0 +1,88 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_gaussian_grid_name.h" + +grib_accessor_class_gaussian_grid_name_t _grib_accessor_class_gaussian_grid_name{ "gaussian_grid_name" }; +grib_accessor_class* grib_accessor_class_gaussian_grid_name = &_grib_accessor_class_gaussian_grid_name; + + +void grib_accessor_class_gaussian_grid_name_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_gen_t::init(a, len, arg); + grib_accessor_gaussian_grid_name_t* self = (grib_accessor_gaussian_grid_name_t*)a; + int n = 0; + + self->N = grib_arguments_get_name(a->parent->h, arg, n++); + self->Ni = grib_arguments_get_name(a->parent->h, arg, n++); + self->isOctahedral = grib_arguments_get_name(a->parent->h, arg, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; +} + +int grib_accessor_class_gaussian_grid_name_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_STRING; +} + +#define MAX_GRIDNAME_LEN 16 + +int grib_accessor_class_gaussian_grid_name_t::unpack_string(grib_accessor* a, char* v, size_t* len) +{ + grib_accessor_gaussian_grid_name_t* self = (grib_accessor_gaussian_grid_name_t*)a; + + long N = 0, Ni = 0; + char tmp[MAX_GRIDNAME_LEN] = {0,}; + size_t length = 0; + int ret = GRIB_SUCCESS; + + if ((ret = grib_get_long_internal(a->parent->h, self->N, &N)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(a->parent->h, self->Ni, &Ni)) != GRIB_SUCCESS) + return ret; + + if (Ni == GRIB_MISSING_LONG) { + /* Reduced gaussian grid */ + long isOctahedral = 0; + if ((ret = grib_get_long_internal(a->parent->h, self->isOctahedral, &isOctahedral)) != GRIB_SUCCESS) + return ret; + if (isOctahedral == 1) { + snprintf(tmp, sizeof(tmp), "O%ld", N); + } + else { + snprintf(tmp, sizeof(tmp), "N%ld", N); /* Classic */ + } + } + else { + /* Regular gaussian grid */ + snprintf(tmp, sizeof(tmp), "F%ld", N); + } + length = strlen(tmp) + 1; + + if (*len < length) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, length, *len); + *len = length; + return GRIB_BUFFER_TOO_SMALL; + } + + strcpy(v, tmp); + *len = length; + return GRIB_SUCCESS; +} + +size_t grib_accessor_class_gaussian_grid_name_t::string_length(grib_accessor* a) +{ + return MAX_GRIDNAME_LEN; +} diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.h b/src/accessor/grib_accessor_class_gaussian_grid_name.h new file mode 100644 index 000000000..d67f80aa5 --- /dev/null +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_gaussian_grid_name_t : public grib_accessor_gen_t +{ +public: + /* Members defined in gaussian_grid_name */ + const char* N; + const char* Ni; + const char* isOctahedral; +}; + +class grib_accessor_class_gaussian_grid_name_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_gaussian_grid_name_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gaussian_grid_name_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_gds_is_present.cc b/src/accessor/grib_accessor_class_gds_is_present.cc new file mode 100644 index 000000000..b568b9bdd --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_is_present.cc @@ -0,0 +1,89 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_gds_is_present.h" + +grib_accessor_class_gds_is_present_t _grib_accessor_class_gds_is_present{ "gds_is_present" }; +grib_accessor_class* grib_accessor_class_gds_is_present = &_grib_accessor_class_gds_is_present; + + +void grib_accessor_class_gds_is_present_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + int n = 0; + grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + self->gds_present = grib_arguments_get_name(h, c, n++); + self->grid_definition = grib_arguments_get_name(h, c, n++); + self->bitmap_present = grib_arguments_get_name(h, c, n++); + self->values = grib_arguments_get_name(h, c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->length = 0; +} + +int grib_accessor_class_gds_is_present_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; + long missing = 255; + int ret = 0; + size_t size = 0; + double* values = NULL; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (*val != 1) + return GRIB_NOT_IMPLEMENTED; + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + if ((ret = grib_set_long_internal(h, self->gds_present, *val)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_set_long_internal(h, self->bitmap_present, *val)) != GRIB_SUCCESS) + return ret; + + + if ((ret = grib_set_long_internal(h, self->grid_definition, missing)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) + return ret; + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gds_is_present_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + int ret = 0; + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_gds_is_present_t* self = (grib_accessor_gds_is_present_t*)a; + + if ((ret = grib_get_long_internal(h, self->gds_present, val)) != GRIB_SUCCESS) + return ret; + + *len = 1; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_gds_is_present.h b/src/accessor/grib_accessor_class_gds_is_present.h new file mode 100644 index 000000000..d69619d44 --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_is_present.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_gds_is_present_t : public grib_accessor_long_t +{ +public: + /* Members defined in gds_is_present */ + const char* gds_present; + const char* grid_definition; + const char* bitmap_present; + const char* values; +}; + +class grib_accessor_class_gds_is_present_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_gds_is_present_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gds_is_present_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc new file mode 100644 index 000000000..6691e2fea --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc @@ -0,0 +1,109 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_gds_not_present_bitmap.h" + +grib_accessor_class_gds_not_present_bitmap_t _grib_accessor_class_gds_not_present_bitmap{"gds_not_present_bitmap"}; +grib_accessor_class* grib_accessor_class_gds_not_present_bitmap = &_grib_accessor_class_gds_not_present_bitmap; + + +void grib_accessor_class_gds_not_present_bitmap_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); + int n = 0; + grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + self->missing_value = grib_arguments_get_name(hand, args, n++); + self->number_of_values = grib_arguments_get_name(hand, args, n++); + self->number_of_points = grib_arguments_get_name(hand, args, n++); + self->latitude_of_first_point = grib_arguments_get_name(hand, args, n++); + self->ni = grib_arguments_get_name(hand, args, n++); + a->length = 0; +} + +int grib_accessor_class_gds_not_present_bitmap_t::value_count(grib_accessor* a, long* number_of_points){ + grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + *number_of_points = 0; + return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_points, number_of_points); +} + +int grib_accessor_class_gds_not_present_bitmap_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_gds_not_present_bitmap_t* self = (grib_accessor_gds_not_present_bitmap_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + long number_of_points = 0, number_of_values = 0, ni = 0; + long latitude_of_first_point = 0; + size_t i = 0; + size_t n_vals = 0; + long nn = 0; + long missing_value; + + double* coded_vals = NULL; + int err = a->value_count(&nn); + n_vals = nn; + if (err) + return err; + + if ((err = grib_get_long(hand, self->number_of_points, &number_of_points)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long(hand, self->number_of_values, &number_of_values)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long(hand, self->latitude_of_first_point, &latitude_of_first_point)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long(hand, self->missing_value, &missing_value)) != GRIB_SUCCESS) + return err; + + if ((err = grib_get_long(hand, self->ni, &ni)) != GRIB_SUCCESS) + return err; + + if (*len < number_of_points) { + *len = n_vals; + return GRIB_ARRAY_TOO_SMALL; + } + + if (number_of_values > 0) { + coded_vals = (double*)grib_context_malloc(a->context, number_of_values * sizeof(double)); + + if (coded_vals == NULL) + return GRIB_OUT_OF_MEMORY; + } + + if (latitude_of_first_point == 0) { + for (i = 0; i < number_of_values; i++) + val[i] = 1; + for (i = number_of_values; i < number_of_points; i++) + val[i] = 0; + } + else { + for (i = 0; i < ni - 1; i++) + val[i] = 0; + for (i = ni - 1; i < number_of_points; i++) + val[i] = 1; + } + + *len = number_of_points; + + grib_context_free(a->context, coded_vals); + return err; +} + +int grib_accessor_class_gds_not_present_bitmap_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + // See deprecated/grib_accessor_class_gds_not_present_bitmap.cc for + // a possible implementation + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gds_not_present_bitmap_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.h b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h new file mode 100644 index 000000000..bf9c0c012 --- /dev/null +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_gds_not_present_bitmap_t : public grib_accessor_gen_t +{ +public: + /* Members defined in gds_not_present_bitmap */ + const char* missing_value; + const char* number_of_values; + const char* number_of_points; + const char* latitude_of_first_point; + const char* ni; +}; + +class grib_accessor_class_gds_not_present_bitmap_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_gds_not_present_bitmap_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gds_not_present_bitmap_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc new file mode 100644 index 000000000..7223f39a9 --- /dev/null +++ b/src/accessor/grib_accessor_class_gen.cc @@ -0,0 +1,751 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor.h" +#include "grib_accessor_class_gen.h" +#include + +// ======================== grib_accessor_gen ======================== +void grib_accessor_gen_t::dump(grib_dumper* f) +{ + return cclass->dump(this, f); +} +int grib_accessor_gen_t::pack_missing() +{ + // grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); + return cclass->pack_missing(this); +} +// int grib_accessor_gen_t::pack_zero(grib_accessor* a) +// { +// return cclass->clear(a); +// } + +int grib_accessor_gen_t::is_missing_internal() +{ + return cclass->is_missing(this); +} + +int grib_accessor_gen_t::pack_double(const double* v, size_t* len) +{ + return cclass->pack_double(this, v, len); +} + +int grib_accessor_gen_t::pack_float(const float* v, size_t* len) +{ + return cclass->pack_float(this, v, len); +} + +int grib_accessor_gen_t::pack_expression(grib_expression* e) +{ + return cclass->pack_expression(this, e); +} + +int grib_accessor_gen_t::pack_string(const char* v, size_t* len) +{ + return cclass->pack_string(this, v, len); +} + +int grib_accessor_gen_t::pack_string_array(const char** v, size_t* len) +{ + return cclass->pack_string_array(this, v, len); +} + +int grib_accessor_gen_t::pack_long(const long* v, size_t* len) +{ + return cclass->pack_long(this, v, len); +} + +int grib_accessor_gen_t::pack_bytes(const unsigned char* v, size_t* len) +{ + return cclass->pack_bytes(this, v, len); +} + +int grib_accessor_gen_t::unpack_bytes(unsigned char* v, size_t* len) +{ + return cclass->unpack_bytes(this, v, len); +} + +int grib_accessor_gen_t::unpack_double_subarray(double* v, size_t start, size_t len) +{ + return cclass->unpack_double_subarray(this, v, start, len); +} + +int grib_accessor_gen_t::unpack_double(double* v, size_t* len) +{ + return cclass->unpack_double(this, v, len); +} + +int grib_accessor_gen_t::unpack_float(float* v, size_t* len) +{ + return cclass->unpack_float(this, v, len); +} + +int grib_accessor_gen_t::unpack_double_element(size_t i, double* v) +{ + return cclass->unpack_double_element(this, i, v); +} + +int grib_accessor_gen_t::unpack_float_element(size_t i, float* v) +{ + // return cclass->unpack_float_element(this, i, v); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_gen_t::unpack_long(long* v, size_t* len) +{ + return cclass->unpack_long(this, v, len); +} + +long grib_accessor_gen_t::get_native_type() +{ + return cclass->get_native_type(this); +} + +long grib_accessor_gen_t::get_next_position_offset() +{ + return cclass->next_offset(this); +} + +long grib_accessor_gen_t::string_length() +{ + return cclass->string_length(this); +} + +long grib_accessor_gen_t::byte_offset() +{ + return cclass->byte_offset(this); +} + +long grib_accessor_gen_t::byte_count() +{ + return cclass->byte_count(this); +} + +int grib_accessor_gen_t::value_count(long* count) +{ + return cclass->value_count(this, count); +} + +int grib_accessor_gen_t::notify_change(grib_accessor* changed) +{ + return cclass->notify_change(this, changed); +} + +// Get the values for the indices passed in. +// The length of the 'index_array' argument should be 'len' and 'val_array' should also contain at least 'len' elements +int grib_accessor_gen_t::unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) +{ + return cclass->unpack_double_element_set(this, index_array, len, val_array); +} +int grib_accessor_gen_t::unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) +{ + throw std::runtime_error("grib_unpack_float_element_set not implemented"); +} +int grib_accessor_gen_t::unpack_string(char* v, size_t* len) +{ + return cclass->unpack_string(this, v, len); +} +int grib_accessor_gen_t::unpack_string_array(char** v, size_t* len) +{ + return cclass->unpack_string_array(this, v, len); +} + +void grib_accessor_gen_t::init_accessor(const long len, grib_arguments* args) +{ + this->cclass->init(this, len, args); +} + +grib_accessor* grib_accessor_gen_t::clone(grib_section* s, int* err) +{ + grib_context* ct = this->context; + grib_context_log(ct, GRIB_LOG_DEBUG, "clone %s ==> %s", cclass->name, this->name); + return cclass->make_clone(this, s, err); +} + +void grib_accessor_gen_t::update_size(size_t len) +{ + cclass->update_size(this, len); +} + +int grib_accessor_gen_t::nearest_smaller_value(double val, double* nearest) +{ + return cclass->nearest_smaller_value(this, val, nearest); +} + +size_t grib_accessor_gen_t::preferred_size(int from_handle) +{ + return cclass->preferred_size(this, from_handle); +} + +grib_accessor* grib_accessor_gen_t::next_accessor() +{ + return cclass->next(this, 1); +} + +void grib_accessor_gen_t::resize(size_t new_size) +{ + cclass->resize(this, new_size); +} + +// For this one, ALL destroy are called +void grib_accessor_gen_t::destroy(grib_context* ct) +{ + cclass->destroy(ct, this); + delete this; +} + + + + +// ======================== grib_accessor_class_gen ======================== + + +grib_accessor_class_gen_t _grib_accessor_class_gen = grib_accessor_class_gen_t("gen"); +grib_accessor_class* grib_accessor_class_gen = &_grib_accessor_class_gen; + +void grib_accessor_class_gen_t::init(grib_accessor* a, const long len, grib_arguments* param) +{ + grib_action* act = (grib_action*)(a->creator); + if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { + a->length = 0; + if (!a->vvalue) + a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->context, sizeof(grib_virtual_value)); + a->vvalue->type = a->get_native_type(); + a->vvalue->length = len; + if (act->default_value != NULL) { + const char* p = 0; + size_t s_len = 1; + long l; + int ret = 0; + double d; + char tmp[1024]; + grib_expression* expression = grib_arguments_get_expression(grib_handle_of_accessor(a), act->default_value, 0); + int type = grib_expression_native_type(grib_handle_of_accessor(a), expression); + switch (type) { + // TODO(maee): add single-precision case + + case GRIB_TYPE_DOUBLE: + grib_expression_evaluate_double(grib_handle_of_accessor(a), expression, &d); + a->pack_double(&d, &s_len); + break; + + case GRIB_TYPE_LONG: + grib_expression_evaluate_long(grib_handle_of_accessor(a), expression, &l); + a->pack_long(&l, &s_len); + break; + + default: + s_len = sizeof(tmp); + p = grib_expression_evaluate_string(grib_handle_of_accessor(a), expression, tmp, &s_len, &ret); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to evaluate %s as string", a->name); + Assert(0); + } + s_len = strlen(p) + 1; + a->pack_string(p, &s_len); + break; + } + } + } + else { + a->length = len; + } +} + +void grib_accessor_class_gen_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + const int type = a->get_native_type(); + switch (type) { + case GRIB_TYPE_STRING: + grib_dump_string(dumper, a, NULL); + break; + case GRIB_TYPE_DOUBLE: + grib_dump_double(dumper, a, NULL); + break; + case GRIB_TYPE_LONG: + grib_dump_long(dumper, a, NULL); + break; + default: + grib_dump_bytes(dumper, a, NULL); + } +} + +long grib_accessor_class_gen_t::next_offset(grib_accessor* a) +{ + return a->offset + a->length; +} + +int grib_accessor_class_gen_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +size_t grib_accessor_class_gen_t::string_length(grib_accessor* a) +{ + return 1024; +} + +long grib_accessor_class_gen_t::byte_count(grib_accessor* a) +{ + return a->length; +} + +int grib_accessor_class_gen_t::get_native_type(grib_accessor* a) +{ + grib_context_log(a->context, GRIB_LOG_ERROR, + "Accessor %s [%s] must implement 'get_native_type'", a->name, a->cclass->name); + return GRIB_TYPE_UNDEFINED; +} + +long grib_accessor_class_gen_t::byte_offset(grib_accessor* a) +{ + return a->offset; +} + +int grib_accessor_class_gen_t::unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len) +{ + unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; + const long length = a->byte_count(); + const long offset = a->byte_offset(); + + if (*len < length) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it is %ld bytes long", a->name, length); + *len = length; + return GRIB_ARRAY_TOO_SMALL; + } + + memcpy(val, buf + offset, length); + *len = length; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gen_t::clear(grib_accessor* a) +{ + unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; + const long length = a->byte_count(); + const long offset = a->byte_offset(); + + memset(buf + offset, 0, length); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gen_t::unpack_long(grib_accessor* a, long* v, size_t* len) +{ + is_overridden_[UNPACK_LONG] = 0; + int type = GRIB_TYPE_UNDEFINED; + if (is_overridden_[UNPACK_DOUBLE] == 1) { + double val = 0.0; + size_t l = 1; + a->unpack_double(&val, &l); + if (is_overridden_[UNPACK_DOUBLE] == 1) { + if (val == GRIB_MISSING_DOUBLE) + *v = GRIB_MISSING_LONG; + else + *v = (long)val; + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to long", a->name); + return GRIB_SUCCESS; + } + } + + if (is_overridden_[UNPACK_STRING] == 1) { + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + + if (is_overridden_[UNPACK_STRING] == 1) { + *v = strtol(val, &last, 10); + + if (*last == 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to long", a->name); + return GRIB_SUCCESS; + } + } + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as long", a->name); + if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); + } + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::unpack_double(grib_accessor* a, double* v, size_t* len) +{ + return unpack_helper(a, v, len); +} + +int grib_accessor_class_gen_t::unpack_float(grib_accessor* a, float* v, size_t* len) +{ + return unpack_helper(a, v, len); +} + +int grib_accessor_class_gen_t::unpack_string(grib_accessor* a, char* v, size_t* len) +{ + is_overridden_[UNPACK_STRING] = 0; + + int err = 0; + if (is_overridden_[UNPACK_DOUBLE] == 1) { + double val = 0.0; + size_t l = 1; + err = a->unpack_double(&val, &l); + if (is_overridden_[UNPACK_DOUBLE] == 1) { + if (err) return err; + snprintf(v, 64, "%g", val); + *len = strlen(v); + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to string", a->name); + return GRIB_SUCCESS; + } + } + + if (is_overridden_[UNPACK_LONG] == 1) { + long val = 0; + size_t l = 1; + err = a->unpack_long(&val, &l); + if (is_overridden_[UNPACK_LONG] == 1) { + if (err) return err; + snprintf(v, 64, "%ld", val); + *len = strlen(v); + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to string\n", a->name); + return GRIB_SUCCESS; + } + } + + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::unpack_string_array(grib_accessor* a, char** v, size_t* len) +{ + size_t length = 0; + + int err = grib_get_string_length_acc(a, &length); + if (err) + return err; + v[0] = (char*)grib_context_malloc_clear(a->context, length); + a->unpack_string(v[0], &length); // TODO(masn): check return value + *len = 1; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gen_t::pack_expression(grib_accessor* a, grib_expression* e) +{ + size_t len = 1; + long lval = 0; + double dval = 0; + const char* cval = NULL; + int ret = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + // Use the native type of the expression not the accessor + switch (grib_expression_native_type(hand, e)) { + case GRIB_TYPE_LONG: { + len = 1; + ret = grib_expression_evaluate_long(hand, e, &lval); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as long (from %s)", + a->name, e->cclass->name); + return ret; + } + /*if (hand->context->debug) + printf("ECCODES DEBUG grib_accessor_class_gen_t::pack_expression %s %ld\n", a->name,lval);*/ + return a->pack_long(&lval, &len); + } + + case GRIB_TYPE_DOUBLE: { + len = 1; + ret = grib_expression_evaluate_double(hand, e, &dval); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as double (from %s)", + a->name, e->cclass->name); + return ret; + } + /*if (hand->context->debug) + printf("ECCODES DEBUG grib_accessor_class_gen_t::pack_expression %s %g\n", a->name, dval);*/ + return a->pack_double(&dval, &len); + } + + case GRIB_TYPE_STRING: { + char tmp[1024]; + len = sizeof(tmp); + cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as string (from %s)", + a->name, e->cclass->name); + return ret; + } + len = strlen(cval); + /*if (hand->context->debug) + printf("ECCODES DEBUG grib_accessor_class_gen_t::pack_expression %s %s\n", a->name, cval);*/ + return a->pack_string(cval, &len); + } + } + + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::pack_long(grib_accessor* a, const long* v, size_t* len) +{ + is_overridden_[PACK_LONG] = 0; + grib_context* c = a->context; + if (is_overridden_[PACK_DOUBLE]) { + double* val = (double*)grib_context_malloc(c, *len * (sizeof(double))); + if (!val) { + grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", *len * (sizeof(double))); + return GRIB_OUT_OF_MEMORY; + } + for (size_t i = 0; i < *len; i++) + val[i] = v[i]; + int ret = a->pack_double(val, len); + grib_context_free(c, val); + if (is_overridden_[PACK_DOUBLE]) { + return ret; + } + } + + grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as an integer", a->name); + if (is_overridden_[PACK_STRING]) { + grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); + } + + return GRIB_NOT_IMPLEMENTED; +} + +int pack_double_array_as_long(grib_accessor* a, const double* v, size_t* len) +{ + grib_context* c = a->context; + int ret = GRIB_SUCCESS; + size_t numBytes = *len * (sizeof(long)); + long* lValues = (long*)grib_context_malloc(c, numBytes); + if (!lValues) { + grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes); + return GRIB_OUT_OF_MEMORY; + } + for (size_t i = 0; i < *len; i++) + lValues[i] = (long)v[i]; /* convert from double to long */ + ret = a->pack_long(lValues, len); + grib_context_free(c, lValues); + return ret; +} + +int grib_accessor_class_gen_t::pack_double(grib_accessor* a, const double* v, size_t* len) +{ + is_overridden_[PACK_DOUBLE] = 0; + grib_context* c = a->context; + + if (is_overridden_[PACK_LONG] || strcmp(a->cclass->name, "codetable") == 0) { + /* ECC-648: Special case of codetable */ + return pack_double_array_as_long(a, v, len); + } + + grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", a->name); + if (is_overridden_[PACK_STRING]) { + grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); + } + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::pack_string_array(grib_accessor* a, const char** v, size_t* len) +{ + int err = 0; + size_t length = 0; + grib_accessor* as = 0; + + as = a; + long i = (long)*len - 1; + while (as && i >= 0) { + length = strlen(v[i]); + err = as->pack_string(v[i], &length); + if (err) + return err; + --i; + as = as->same; + } + return GRIB_SUCCESS; +} + +int grib_accessor_class_gen_t::pack_string(grib_accessor* a, const char* v, size_t* len) +{ + is_overridden_[PACK_STRING] = 0; + if (is_overridden_[PACK_DOUBLE]) { + size_t l = 1; + char* endPtr = NULL; /* for error handling */ + double val = strtod(v, &endPtr); + if (*endPtr) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Invalid value (%s) for key '%s'. String cannot be converted to a double", + __func__, v, a->name); + return GRIB_WRONG_TYPE; + } + return a->pack_double(&val, &l); + } + + if (is_overridden_[PACK_LONG]) { + size_t l = 1; + long val = atol(v); + int err = a->pack_long(&val, &l); + if (is_overridden_[PACK_LONG]) { + return err; + } + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack '%s' as string", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) +{ + const size_t length = *len; + if (length != a->length) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "pack_bytes: Wrong size (%zu) for %s. It is %ld bytes long", + length, a->name, a->length); + return GRIB_BUFFER_TOO_SMALL; + } + grib_buffer_replace(a, val, length, 1, 1); + return GRIB_SUCCESS; +} + +void grib_accessor_class_gen_t::destroy(grib_context* ct, grib_accessor* a) +{ + grib_dependency_remove_observed(a); + grib_dependency_remove_observer(a); + if (a->vvalue != NULL) { + grib_context_free(ct, a->vvalue); + a->vvalue = NULL; + } + /*grib_context_log(ct,GRIB_LOG_DEBUG,"address=%p",a);*/ +} + +grib_section* grib_accessor_class_gen_t::sub_section(grib_accessor* a) +{ + return NULL; +} + +int grib_accessor_class_gen_t::notify_change(grib_accessor* self, grib_accessor* observed) +{ + /* Default behaviour is to notify creator */ + return grib_action_notify_change(self->creator, self, observed); +} + +void grib_accessor_class_gen_t::update_size(grib_accessor* a, size_t s) +{ + grib_context_log(a->context, GRIB_LOG_FATAL, + "Accessor %s [%s] must implement 'update_size'", a->name, a->cclass->name); +} + +grib_accessor* grib_accessor_class_gen_t::next(grib_accessor* a, int mod) +{ + grib_accessor* next = NULL; + if (a->next_) { + next = a->next_; + } + else { + if (a->parent->owner) + next = a->parent->owner->cclass->next(a->parent->owner, 0); + } + return next; +} + +int grib_accessor_class_gen_t::compare(grib_accessor* a, grib_accessor* b) +{ + return GRIB_NOT_IMPLEMENTED; +} + +/* Redefined in all padding */ + +size_t grib_accessor_class_gen_t::preferred_size(grib_accessor* a, int from_handle) +{ + return a->length; +} + +int grib_accessor_class_gen_t::is_missing(grib_accessor* a) +{ + int i = 0; + int is_missing = 1; + unsigned char ones = 0xff; + unsigned char* v = NULL; + + if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { + if (a->vvalue == NULL) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s internal error (flags=0x%lX)", a->name, a->flags); + Assert(!"grib_accessor_class_gen_t::is_missing(): a->vvalue == NULL"); + return 0; + } + return a->vvalue->missing; + } + Assert(a->length >= 0); + + v = grib_handle_of_accessor(a)->buffer->data + a->offset; + + for (i = 0; i < a->length; i++) { + if (*v != ones) { + is_missing = 0; + break; + } + v++; + } + + return is_missing; +} + +int grib_accessor_class_gen_t::unpack_double_element(grib_accessor* a, size_t i, double* val) +{ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) +{ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_gen_t::unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len) +{ + return GRIB_NOT_IMPLEMENTED; +} + +grib_accessor* grib_accessor_class_gen_t::make_clone(grib_accessor* a, grib_section* s, int* err) +{ + *err = GRIB_NOT_IMPLEMENTED; + return NULL; +} + + + + +grib_accessor_class_gen_t::~grib_accessor_class_gen_t(){}; + +void grib_accessor_class_gen_t::post_init(grib_accessor*){ + return; +}; +int grib_accessor_class_gen_t::pack_missing(grib_accessor*) { + throw std::runtime_error("grib_accessor_class_gen_t::pack_missing not implemented"); +}; +int grib_accessor_class_gen_t::pack_float(grib_accessor*, const float*, size_t* len) { + throw std::runtime_error("grib_accessor_class_gen_t::pack_float not implemented"); +}; +void grib_accessor_class_gen_t::resize(grib_accessor*, size_t) { + throw std::runtime_error("grib_accessor_class_gen_t::resize not implemented"); +}; +int grib_accessor_class_gen_t::nearest_smaller_value(grib_accessor*, double, double*) { + throw std::runtime_error("grib_accessor_class_gen_t::nearest_smaller_value not implemented"); +}; +int grib_accessor_class_gen_t::unpack_float_element(grib_accessor*, size_t, float*) { + throw std::runtime_error("grib_accessor_class_gen_t::unpack_float_element not implemented"); +}; +int unpack_element_set(grib_accessor*, const size_t*, size_t, double*) { + throw std::runtime_error("grib_accessor_class_gen_t::unpack_element_set not implemented"); +}; +int grib_accessor_class_gen_t::unpack_float_element_set(grib_accessor*, const size_t*, size_t, float*) { + throw std::runtime_error("grib_accessor_class_gen_t::unpack_float_element_set not implemented"); +}; diff --git a/src/accessor/grib_accessor_class_gen.h b/src/accessor/grib_accessor_class_gen.h new file mode 100644 index 000000000..deba6cad2 --- /dev/null +++ b/src/accessor/grib_accessor_class_gen.h @@ -0,0 +1,168 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_api_internal.h" +#include "grib_accessor.h" +#include + +class grib_accessor_gen_t : public grib_accessor { + void init_accessor(const long, grib_arguments*) override; + void dump(grib_dumper* f) override; + int pack_missing() override; + //int grib_pack_zero(grib_accessor* a) override; + int is_missing_internal() override; + int pack_double(const double* v, size_t* len) override; + int pack_float(const float* v, size_t* len) override; + int pack_expression(grib_expression* e) override; + int pack_string(const char* v, size_t* len) override; + int pack_string_array(const char** v, size_t* len) override; + int pack_long(const long* v, size_t* len) override; + int pack_bytes(const unsigned char* v, size_t* len) override; + int unpack_bytes(unsigned char* v, size_t* len) override; + int unpack_double_subarray(double* v, size_t start, size_t len) override; + int unpack_double(double* v, size_t* len) override; + int unpack_float(float* v, size_t* len) override; + int unpack_double_element(size_t i, double* v) override; + int unpack_float_element(size_t i, float* v) override; + int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) override; + int unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) override; + int unpack_string(char* v, size_t* len) override; + int unpack_string_array(char** v, size_t* len) override; + int unpack_long(long* v, size_t* len) override; + long get_native_type() override; + long get_next_position_offset() override; + long string_length() override; + long byte_offset() override; + long byte_count() override; + int value_count(long* count) override; + int notify_change(grib_accessor* changed) override; + grib_accessor* clone(grib_section* s, int* err) override; + void update_size(size_t len) override; + int nearest_smaller_value(double val, double* nearest) override; + size_t preferred_size(int from_handle) override; + grib_accessor* next_accessor() override; + void resize(size_t new_size) override; + void destroy(grib_context* ct) override; +}; + +class grib_accessor_class_gen_t : public grib_accessor_class +{ +public: + grib_accessor_class_gen_t(const char* name) : grib_accessor_class{name} {} + ~grib_accessor_class_gen_t(); + + grib_accessor* create_empty_accessor() override{ return new grib_accessor_gen_t(); } + grib_section* sub_section(grib_accessor* a) override; + int get_native_type(grib_accessor*) override; + int pack_missing(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_float(grib_accessor*, const float* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_string_array(grib_accessor*, const char**, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void post_init(grib_accessor*) override; + int notify_change(grib_accessor*, grib_accessor*) override; + void update_size(grib_accessor*, size_t) override; + size_t preferred_size(grib_accessor*, int) override; + void resize(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor*, double, double*) override; + grib_accessor* next(grib_accessor*, int) override; + int compare(grib_accessor*, grib_accessor*) override; + int unpack_double_element(grib_accessor*, size_t i, double* val) override; + int unpack_float_element(grib_accessor*, size_t i, float* val) override; + int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array) override; + int unpack_float_element_set(grib_accessor*, const size_t* index_array, size_t len, float* val_array) override; + int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len) override; + int clear(grib_accessor*) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; + + template + int unpack_helper(grib_accessor* a, T* v, size_t* len); + +private: + enum { + PACK_DOUBLE, + PACK_FLOAT, + PACK_LONG, + PACK_STRING, + UNPACK_DOUBLE, + UNPACK_FLOAT, + UNPACK_LONG, + UNPACK_STRING, + }; + std::bitset<8> is_overridden_ = 0b11111111; +}; + + +template +int grib_accessor_class_gen_t::unpack_helper(grib_accessor* a, T* v, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + int type = GRIB_TYPE_UNDEFINED; + const char* Tname = type_to_string(*v); + + if constexpr (std::is_same_v) { + is_overridden_[UNPACK_FLOAT] = 0; + } + else if constexpr (std::is_same_v) { + is_overridden_[UNPACK_DOUBLE] = 0; + } + + if (is_overridden_[UNPACK_LONG]) { + long val = 0; + size_t l = 1; + a->unpack_long(&val, &l); + if (is_overridden_[UNPACK_LONG]) { + *v = val; + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + } + + if (is_overridden_[UNPACK_STRING]) { + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + if (is_overridden_[UNPACK_STRING]) { + *v = strtod(val, &last); + if (*last == 0) { /* conversion of string to double worked */ + grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); + return GRIB_SUCCESS; + } + } + } + + grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); + if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); + } + + return GRIB_NOT_IMPLEMENTED; +} diff --git a/src/accessor/grib_accessor_class_getenv.cc b/src/accessor/grib_accessor_class_getenv.cc new file mode 100644 index 000000000..d812cc276 --- /dev/null +++ b/src/accessor/grib_accessor_class_getenv.cc @@ -0,0 +1,62 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_getenv.h" + +grib_accessor_class_getenv_t _grib_accessor_class_getenv{"getenv"}; +grib_accessor_class* grib_accessor_class_getenv = &_grib_accessor_class_getenv; + + +void grib_accessor_class_getenv_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_ascii_t::init(a, l, args); + grib_accessor_getenv_t* self = (grib_accessor_getenv_t*)a; + static char undefined[] = "undefined"; + + self->name = grib_arguments_get_string(grib_handle_of_accessor(a), args, 0); + self->default_value = grib_arguments_get_string(grib_handle_of_accessor(a), args, 1); + if (!self->default_value) + self->default_value = undefined; + self->value = 0; +} + +int grib_accessor_class_getenv_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_getenv_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_getenv_t* self = (grib_accessor_getenv_t*)a; + char* v = 0; + size_t l = 0; + + if (!self->value) { + v = getenv(self->name); + if (!v) + v = (char*)self->default_value; + self->value = v; + } + + l = strlen(self->value); + if (*len < l) + return GRIB_BUFFER_TOO_SMALL; + snprintf(val, 1024, "%s", self->value); + *len = strlen(self->value); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_getenv_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_getenv_t::string_length(grib_accessor* a){ + return 1024; +} diff --git a/src/accessor/grib_accessor_class_getenv.h b/src/accessor/grib_accessor_class_getenv.h new file mode 100644 index 000000000..b04c58a4d --- /dev/null +++ b/src/accessor/grib_accessor_class_getenv.h @@ -0,0 +1,34 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_getenv_t : public grib_accessor_ascii_t +{ +public: + const char* name; + char* value; + const char* default_value; +}; + +class grib_accessor_class_getenv_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_getenv_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_getenv_t{}; } + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; + diff --git a/src/grib_accessor_class_global_gaussian.cc b/src/accessor/grib_accessor_class_global_gaussian.cc similarity index 64% rename from src/grib_accessor_class_global_gaussian.cc rename to src/accessor/grib_accessor_class_global_gaussian.cc index b39677da2..34ac67881 100644 --- a/src/grib_accessor_class_global_gaussian.cc +++ b/src/accessor/grib_accessor_class_global_gaussian.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,122 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - MEMBERS=const char* N - MEMBERS=const char* Ni - MEMBERS=const char* di - MEMBERS=const char* latfirst - MEMBERS=const char* lonfirst - MEMBERS=const char* latlast - MEMBERS=const char* lonlast - MEMBERS=const char* plpresent - MEMBERS=const char* pl - MEMBERS=const char* basic_angle - MEMBERS=const char* subdivision - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_global_gaussian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in global_gaussian */ - const char* N; - const char* Ni; - const char* di; - const char* latfirst; - const char* lonfirst; - const char* latlast; - const char* lonlast; - const char* plpresent; - const char* pl; - const char* basic_angle; - const char* subdivision; -} grib_accessor_global_gaussian; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_global_gaussian = { - &grib_accessor_class_long, /* super */ - "global_gaussian", /* name */ - sizeof(grib_accessor_global_gaussian), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_global_gaussian.h" +grib_accessor_class_global_gaussian_t _grib_accessor_class_global_gaussian{"global_gaussian"}; grib_accessor_class* grib_accessor_class_global_gaussian = &_grib_accessor_class_global_gaussian; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_global_gaussian* self = (grib_accessor_global_gaussian*)a; +void grib_accessor_class_global_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_global_gaussian_t* self = (grib_accessor_global_gaussian_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); @@ -140,9 +34,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->subdivision = grib_arguments_get_name(h, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_global_gaussian* self = (grib_accessor_global_gaussian*)a; +int grib_accessor_class_global_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_global_gaussian_t* self = (grib_accessor_global_gaussian_t*)a; int ret = GRIB_SUCCESS; long latfirst, latlast, lonfirst, lonlast, basic_angle, subdivision, N, Ni; double dlatfirst, dlatlast, dlonfirst, dlonlast; @@ -247,9 +140,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return ret; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_global_gaussian* self = (grib_accessor_global_gaussian*)a; +int grib_accessor_class_global_gaussian_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_global_gaussian_t* self = (grib_accessor_global_gaussian_t*)a; int ret = GRIB_SUCCESS; long latfirst, latlast, lonfirst, lonlast, di, diold, basic_angle = 0, N, Ni; long factor; diff --git a/src/accessor/grib_accessor_class_global_gaussian.h b/src/accessor/grib_accessor_class_global_gaussian.h new file mode 100644 index 000000000..1d49c0c32 --- /dev/null +++ b/src/accessor/grib_accessor_class_global_gaussian.h @@ -0,0 +1,41 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_global_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in global_gaussian */ + const char* N; + const char* Ni; + const char* di; + const char* latfirst; + const char* lonfirst; + const char* latlast; + const char* lonlast; + const char* plpresent; + const char* pl; + const char* basic_angle; + const char* subdivision; +}; + +class grib_accessor_class_global_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_global_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_global_gaussian_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_group.cc b/src/accessor/grib_accessor_class_group.cc new file mode 100644 index 000000000..aef185022 --- /dev/null +++ b/src/accessor/grib_accessor_class_group.cc @@ -0,0 +1,160 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_group.h" + +grib_accessor_class_group_t _grib_accessor_class_group{"group"}; +grib_accessor_class* grib_accessor_class_group = &_grib_accessor_class_group; + + +void grib_accessor_class_group_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; + grib_accessor_group_t* self = (grib_accessor_group_t*)a; + + size_t i = 0; + unsigned char* v; + const char* s = grib_arguments_get_string(grib_handle_of_accessor(a), arg, 0); + + if (s && strlen(s) > 1) { + grib_context_log(a->context, GRIB_LOG_WARNING, + "Using only first character as group end of %s not the string %s", a->name, s); + } + + self->endCharacter = s ? s[0] : 0; + + v = buffer->data + a->offset; + i = 0; + if (s) { + while (*v != self->endCharacter && i <= buffer->ulength) { + if (*v > 126) + *v = 32; + v++; + i++; + } + } + else { + while (*v > 32 && *v != 61 && *v < 127 && i <= buffer->ulength) { + v++; + i++; + } + } + a->length = i; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_group_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_group_t::string_length(grib_accessor* a){ + return a->length; +} + +void grib_accessor_class_group_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_group_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_group_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + long i = 0; + size_t l = a->length + 1; + grib_handle* h = grib_handle_of_accessor(a); + + if (*len < l) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + a->cclass->name, a->name, l, *len); + *len = l; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < a->length; i++) + val[i] = h->buffer->data[a->offset + i]; + val[i] = 0; + *len = i; + return GRIB_SUCCESS; +} + +int grib_accessor_class_group_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + size_t i = 0; + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + i = 0; + while (i < l - 1 && val[i] == ' ') + i++; + + if (val[i] == 0) { + *v = 0; + return 0; + } + if (val[i + 1] == ' ' && i < l - 2) + val[i + 1] = 0; + + *v = strtol(val, &last, 10); + + grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); + return GRIB_SUCCESS; +} + +int grib_accessor_class_group_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + *v = strtod(val, &last); + + if (*last == 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); + return GRIB_SUCCESS; + } + + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_group_t::compare(grib_accessor* a, grib_accessor* b){ + grib_context_log(a->context, GRIB_LOG_ERROR, "%s:%s not implemented", __func__, a->name); + return GRIB_NOT_IMPLEMENTED; + + // int retval = 0; + // char* aval = 0; + // char* bval = 0; + // int err = 0; + // size_t alen = 0; + // size_t blen = 0; + // long count = 0; + // err = a->value_count(&count); // if (err) return err; + // alen = count; + // err = b->value_count(&count); // if (err) return err; + // blen = count; + // if (alen != blen) return GRIB_COUNT_MISMATCH; + // aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); + // bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); + // a->unpack_string(aval, &alen); // b->unpack_string(bval, &blen); // retval = GRIB_SUCCESS; + // if (strcmp(aval, bval)) retval = GRIB_STRING_VALUE_MISMATCH; + // grib_context_free(a->context, aval); + // grib_context_free(b->context, bval); + // return retval; +} + +long grib_accessor_class_group_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_group.h b/src/accessor/grib_accessor_class_group.h new file mode 100644 index 000000000..9f1c31a81 --- /dev/null +++ b/src/accessor/grib_accessor_class_group.h @@ -0,0 +1,38 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_group_t : public grib_accessor_gen_t +{ +public: + /* Members defined in group */ + char endCharacter; +}; + +class grib_accessor_class_group_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_group_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_group_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_gts_header.cc b/src/accessor/grib_accessor_class_gts_header.cc new file mode 100644 index 000000000..62a63bb8f --- /dev/null +++ b/src/accessor/grib_accessor_class_gts_header.cc @@ -0,0 +1,61 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_gts_header.h" + +grib_accessor_class_gts_header_t _grib_accessor_class_gts_header{"gts_header"}; +grib_accessor_class* grib_accessor_class_gts_header = &_grib_accessor_class_gts_header; + + +void grib_accessor_class_gts_header_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_ascii_t::init(a, l, c); + grib_accessor_gts_header_t* self = (grib_accessor_gts_header_t*)a; + self->gts_offset = -1; + self->gts_length = -1; + self->gts_offset = grib_arguments_get_long(grib_handle_of_accessor(a), c, 0); + self->gts_length = grib_arguments_get_long(grib_handle_of_accessor(a), c, 1); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_gts_header_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_gts_header_t* self = (grib_accessor_gts_header_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int offset = 0; + size_t length = 0; + + if (h->gts_header == NULL || h->gts_header_len < 8) { + if (*len < 8) + return GRIB_BUFFER_TOO_SMALL; + snprintf(val, 1024, "missing"); + return GRIB_SUCCESS; + } + if (*len < h->gts_header_len) + return GRIB_BUFFER_TOO_SMALL; + + offset = self->gts_offset > 0 ? self->gts_offset : 0; + length = self->gts_length > 0 ? self->gts_length : h->gts_header_len; + + memcpy(val, h->gts_header + offset, length); + + *len = length; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_gts_header_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_gts_header_t::string_length(grib_accessor* a){ + grib_handle* h = grib_handle_of_accessor(a); + return h->gts_header_len; +} diff --git a/src/accessor/grib_accessor_class_gts_header.h b/src/accessor/grib_accessor_class_gts_header.h new file mode 100644 index 000000000..8072986a7 --- /dev/null +++ b/src/accessor/grib_accessor_class_gts_header.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_gts_header_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in gts_header */ + int gts_offset; + int gts_length; +}; + +class grib_accessor_class_gts_header_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_gts_header_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_gts_header_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_hash_array.cc b/src/accessor/grib_accessor_class_hash_array.cc new file mode 100644 index 000000000..1955dc07f --- /dev/null +++ b/src/accessor/grib_accessor_class_hash_array.cc @@ -0,0 +1,177 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_hash_array.h" + +grib_accessor_class_hash_array_t _grib_accessor_class_hash_array{"hash_array"}; +grib_accessor_class* grib_accessor_class_hash_array = &_grib_accessor_class_hash_array; + + +#define MAX_HASH_ARRAY_STRING_LENGTH 255 + +void grib_accessor_class_hash_array_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, len, args); + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + a->length = 0; + self->key = 0; + self->ha = NULL; +} + +void grib_accessor_class_hash_array_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_hash_array_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + char s[200] = {0,}; + snprintf(s, sizeof(s), "%g", *val); + self->key = grib_context_strdup(a->context, s); + self->ha = 0; + return GRIB_SUCCESS; +} + +int grib_accessor_class_hash_array_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + char s[200] = {0,}; + snprintf(s, sizeof(s), "%ld", *val); + if (self->key) + grib_context_free(a->context, self->key); + self->key = grib_context_strdup(a->context, s); + self->ha = 0; + return GRIB_SUCCESS; +} + +int grib_accessor_class_hash_array_t::pack_string(grib_accessor* a, const char* v, size_t* len){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + self->key = grib_context_strdup(a->context, v); + self->ha = 0; + return GRIB_SUCCESS; +} + +int grib_accessor_class_hash_array_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +static grib_hash_array_value* find_hash_value(grib_accessor* a, int* err) +{ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + grib_hash_array_value* ha_ret = 0; + grib_hash_array_value* ha = NULL; + + ha = get_hash_array(grib_handle_of_accessor(a), a->creator); + if (!ha) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "unable to get hash value for %s", a->creator->name); + *err = GRIB_HASH_ARRAY_NO_MATCH; + return NULL; + } + + *err = GRIB_SUCCESS; + + Assert(ha != NULL); + if (!self->key) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "unable to get hash value for %s, set before getting", a->creator->name); + *err = GRIB_HASH_ARRAY_NO_MATCH; + return NULL; + } + + ha_ret = (grib_hash_array_value*)grib_trie_get(ha->index, self->key); + if (!ha_ret) + ha_ret = (grib_hash_array_value*)grib_trie_get(ha->index, "default"); + + if (!ha_ret) { + *err = GRIB_HASH_ARRAY_NO_MATCH; + grib_context_log(a->context, GRIB_LOG_ERROR, + "hash_array: no match for %s=%s", + a->creator->name, self->key); + const char* full_path = get_hash_array_full_path(a->creator); + if (full_path) { + grib_context_log(a->context, GRIB_LOG_ERROR, "hash_array: file path = %s", full_path); + } + grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Check the key 'masterTablesVersionNumber'"); + return NULL; + } + return ha_ret; +} + +int grib_accessor_class_hash_array_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_hash_array_value* ha = 0; + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + int err = 0; + size_t i = 0; + + if (!self->ha) { + ha = find_hash_value(a, &err); + if (err) + return err; + self->ha = ha; + } + + switch (self->ha->type) { + case GRIB_HASH_ARRAY_TYPE_INTEGER: + if (*len < self->ha->iarray->n) { + return GRIB_ARRAY_TOO_SMALL; + } + *len = self->ha->iarray->n; + for (i = 0; i < *len; i++) + val[i] = self->ha->iarray->v[i]; + break; + + default: + return GRIB_NOT_IMPLEMENTED; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_hash_array_t::get_native_type(grib_accessor* a){ + int type = GRIB_TYPE_STRING; + if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) + type = GRIB_TYPE_LONG; + + return type; +} + +void grib_accessor_class_hash_array_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + if (self->key) + grib_context_free(c, self->key); + grib_accessor_class_gen_t::destroy(c, a); +} + +int grib_accessor_class_hash_array_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +size_t grib_accessor_class_hash_array_t::string_length(grib_accessor* a){ + return MAX_HASH_ARRAY_STRING_LENGTH; +} + +int grib_accessor_class_hash_array_t::value_count(grib_accessor* a, long* count){ + int err = 0; + grib_accessor_hash_array_t* self = (grib_accessor_hash_array_t*)a; + grib_hash_array_value* ha = 0; + + if (!self->ha) { + ha = find_hash_value(a, &err); + if (err) + return err; + self->ha = ha; + } + + *count = self->ha->iarray->n; + return err; +} + +int grib_accessor_class_hash_array_t::compare(grib_accessor* a, grib_accessor* b){ + return GRIB_NOT_IMPLEMENTED; +} diff --git a/src/accessor/grib_accessor_class_hash_array.h b/src/accessor/grib_accessor_class_hash_array.h new file mode 100644 index 000000000..fa2732cac --- /dev/null +++ b/src/accessor/grib_accessor_class_hash_array.h @@ -0,0 +1,42 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_hash_array_t : public grib_accessor_gen_t +{ +public: + /* Members defined in hash_array */ + char* key; + grib_hash_array_value* ha; +}; + +class grib_accessor_class_hash_array_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_hash_array_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_hash_array_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_headers_only.cc b/src/accessor/grib_accessor_class_headers_only.cc new file mode 100644 index 000000000..9b053112d --- /dev/null +++ b/src/accessor/grib_accessor_class_headers_only.cc @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_headers_only.h" + +grib_accessor_class_headers_only_t _grib_accessor_class_headers_only{"headers_only"}; +grib_accessor_class* grib_accessor_class_headers_only = &_grib_accessor_class_headers_only; + + +void grib_accessor_class_headers_only_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->length = 0; +} + +int grib_accessor_class_headers_only_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + *val = grib_handle_of_accessor(a)->partial; + *len = 1; + return 0; +} + +int grib_accessor_class_headers_only_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_headers_only.h b/src/accessor/grib_accessor_class_headers_only.h new file mode 100644 index 000000000..a7dc81891 --- /dev/null +++ b/src/accessor/grib_accessor_class_headers_only.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_headers_only_t : public grib_accessor_gen_t +{ +public: + /* Members defined in headers_only */ +}; + +class grib_accessor_class_headers_only_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_headers_only_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_headers_only_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc new file mode 100644 index 000000000..c5766db01 --- /dev/null +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -0,0 +1,165 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_ibmfloat.h" + +grib_accessor_class_ibmfloat_t _grib_accessor_class_ibmfloat{ "ibmfloat" }; +grib_accessor_class* grib_accessor_class_ibmfloat = &_grib_accessor_class_ibmfloat; + + +void grib_accessor_class_ibmfloat_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_double_t::init(a, len, arg); + grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; + long count = 0; + + self->arg = arg; + a->value_count(&count); + a->length = 4 * count; + Assert(a->length >= 0); +} + + +template +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + unsigned long rlen = 0; + long count = 0; + int err = 0; + unsigned long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&count); + if (err) + return err; + rlen = count; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ibmfloat_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + return unpack(a, val, len); +} + +int grib_accessor_class_ibmfloat_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ + return unpack(a, val, len); +} + +int grib_accessor_class_ibmfloat_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; + + int ret = 0; + unsigned long i = 0; + unsigned long rlen = *len; + size_t buflen = 0; + unsigned char* buf = NULL; + long off = 0; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + if (rlen == 1) { + // double x = 0; + // grib_nearest_smaller_ibm_float(val[0],&x); + // double y = grib_long_to_ibm(grib_ibm_to_long(val[0])); + // printf("IBMFLOAT val=%.20f nearest_smaller_ibm_float=%.20f long_to_ibm=%.20f\n",val[0],x ,y); + + off = a->byte_offset() * 8; + ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ibm_to_long(val[0]), &off, 32); + if (*len > 1) + grib_context_log(a->context, GRIB_LOG_WARNING, "ibmfloat: Trying to pack %zu values in a scalar %s, packing first value", + *len, a->name); + if (ret == GRIB_SUCCESS) + len[0] = 1; + return ret; + } + + buflen = rlen * 4; + + buf = (unsigned char*)grib_context_malloc(a->context, buflen); + + for (i = 0; i < rlen; i++) { + grib_encode_unsigned_longb(buf, grib_ibm_to_long(val[i]), &off, 32); + } + ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), rlen); + + if (ret == GRIB_SUCCESS) + grib_buffer_replace(a, buf, buflen, 1, 1); + else + *len = 0; + + grib_context_free(a->context, buf); + + a->length = a->byte_count(); + + return ret; +} + +long grib_accessor_class_ibmfloat_t::byte_count(grib_accessor* a) +{ + return a->length; +} + +int grib_accessor_class_ibmfloat_t::value_count(grib_accessor* a, long* len) +{ + grib_accessor_ibmfloat_t* self = (grib_accessor_ibmfloat_t*)a; + *len = 0; + if (!self->arg) { + *len = 1; + return 0; + } + return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); +} + +long grib_accessor_class_ibmfloat_t::byte_offset(grib_accessor* a) +{ + return a->offset; +} + +void grib_accessor_class_ibmfloat_t::update_size(grib_accessor* a, size_t s) +{ + a->length = (long)s; + Assert(a->length >= 0); +} + +long grib_accessor_class_ibmfloat_t::next_offset(grib_accessor* a) +{ + return a->byte_offset() + a->byte_count(); +} + +int grib_accessor_class_ibmfloat_t::nearest_smaller_value(grib_accessor* a, double val, double* nearest) +{ + int ret = 0; + if (grib_nearest_smaller_ibm_float(val, nearest) == GRIB_INTERNAL_ERROR) { + grib_context_log(a->context, GRIB_LOG_ERROR, "ibm_float:nearest_smaller_value overflow value=%g", val); + grib_dump_content(grib_handle_of_accessor(a), stderr, "wmo", GRIB_DUMP_FLAG_HEXADECIMAL, 0); + ret = GRIB_INTERNAL_ERROR; + } + return ret; +} diff --git a/src/accessor/grib_accessor_class_ibmfloat.h b/src/accessor/grib_accessor_class_ibmfloat.h new file mode 100644 index 000000000..66bd01132 --- /dev/null +++ b/src/accessor/grib_accessor_class_ibmfloat.h @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_ibmfloat_t : public grib_accessor_double_t +{ +public: + /* Members defined in ibmfloat */ + grib_arguments* arg; +}; + +class grib_accessor_class_ibmfloat_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_ibmfloat_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ibmfloat_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor*, double, double*) override; +}; diff --git a/src/accessor/grib_accessor_class_ieeefloat.cc b/src/accessor/grib_accessor_class_ieeefloat.cc new file mode 100644 index 000000000..64b08fe50 --- /dev/null +++ b/src/accessor/grib_accessor_class_ieeefloat.cc @@ -0,0 +1,136 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_ieeefloat.h" + +grib_accessor_class_ieeefloat_t _grib_accessor_class_ieeefloat{ "ieeefloat" }; +grib_accessor_class* grib_accessor_class_ieeefloat = &_grib_accessor_class_ieeefloat; + + +void grib_accessor_class_ieeefloat_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_double_t::init(a, len, arg); + grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; + long count = 0; + self->arg = arg; + a->value_count(&count); + a->length = 4 * count; + Assert(a->length >= 0); +} + +int grib_accessor_class_ieeefloat_t::value_count(grib_accessor* a, long* len) +{ + grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; + *len = 0; + + if (!self->arg) { + *len = 1; + return 0; + } + return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); +} + +int grib_accessor_class_ieeefloat_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + grib_accessor_ieeefloat_t* self = (grib_accessor_ieeefloat_t*)a; + + int ret = 0; + unsigned long i = 0; + unsigned long rlen = (unsigned long)*len; + size_t buflen = 0; + unsigned char* buf = NULL; + long off = 0; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + if (rlen == 1) { + off = a->offset * 8; + ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ieee_to_long(val[0]), &off, 32); + if (*len > 1) + grib_context_log(a->context, GRIB_LOG_WARNING, "ieeefloat: Trying to pack %zu values in a scalar %s, packing first value", + *len, a->name); + if (ret == GRIB_SUCCESS) + len[0] = 1; + return ret; + } + + buflen = rlen * 4; + + buf = (unsigned char*)grib_context_malloc(a->context, buflen); + + for (i = 0; i < rlen; i++) { + grib_encode_unsigned_longb(buf, grib_ieee_to_long(val[i]), &off, 32); + } + ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), rlen); + + if (ret == GRIB_SUCCESS) + grib_buffer_replace(a, buf, buflen, 1, 1); + else + *len = 0; + + grib_context_free(a->context, buf); + + return ret; +} + + +template +static int unpack(grib_accessor* a, T* val, size_t* len) +{ + static_assert(std::is_floating_point::value, "Requires floating point numbers"); + + long rlen = 0; + int err = 0; + long i = 0; + long bitp = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); + + err = a->value_count(&rlen); + if (err) + return err; + + if (*len < (size_t)rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) + val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); + + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ieeefloat_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + return unpack(a, val, len); +} + +int grib_accessor_class_ieeefloat_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ + return unpack(a, val, len); +} + +void grib_accessor_class_ieeefloat_t::update_size(grib_accessor* a, size_t s) +{ + a->length = (long)s; + Assert(a->length >= 0); +} + +int grib_accessor_class_ieeefloat_t::nearest_smaller_value(grib_accessor* a, double val, double* nearest) +{ + return grib_nearest_smaller_ieee_float(val, nearest); +} diff --git a/src/accessor/grib_accessor_class_ieeefloat.h b/src/accessor/grib_accessor_class_ieeefloat.h new file mode 100644 index 000000000..27536169f --- /dev/null +++ b/src/accessor/grib_accessor_class_ieeefloat.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_ieeefloat_t : public grib_accessor_double_t +{ +public: + grib_arguments* arg; +}; + +class grib_accessor_class_ieeefloat_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_ieeefloat_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ieeefloat_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int nearest_smaller_value(grib_accessor* a, double val, double* nearest) override; +}; diff --git a/src/accessor/grib_accessor_class_ifs_param.cc b/src/accessor/grib_accessor_class_ifs_param.cc new file mode 100644 index 000000000..32a972c7c --- /dev/null +++ b/src/accessor/grib_accessor_class_ifs_param.cc @@ -0,0 +1,93 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_ifs_param.h" + +grib_accessor_class_ifs_param_t _grib_accessor_class_ifs_param{"ifs_param"}; +grib_accessor_class* grib_accessor_class_ifs_param = &_grib_accessor_class_ifs_param; + + +void grib_accessor_class_ifs_param_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); + grib_accessor_ifs_param_t* self = (grib_accessor_ifs_param_t*)a; + int n = 0; + + self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->type = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_ifs_param_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_ifs_param_t* self = (grib_accessor_ifs_param_t*)a; + int ret = 0; + long paramId = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->paramId, ¶mId)) != GRIB_SUCCESS) + return ret; + + if (paramId > 129000 && paramId < 129999) + *val = paramId - 129000; + else if (paramId > 200000 && paramId < 200999) + *val = paramId - 200000; + else if (paramId > 211000 && paramId < 211999) + *val = paramId - 1000; + else + *val = paramId; + + return ret; +} + +int grib_accessor_class_ifs_param_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_ifs_param_t* self = (grib_accessor_ifs_param_t*)a; + long type = 0; + long table = 128; + long paramId = *val; + long param; + + grib_get_long(grib_handle_of_accessor(a), self->type, &type); + + if (type == 33 || type == 35) { + if (paramId > 1000) { + table = paramId / 1000; + param = paramId - table * 1000; + paramId = param; + } + switch (table) { + case 210: + paramId += 211000; + break; + case 128: + paramId += 200000; + break; + default: + break; + } + } + if (type == 50 || type == 52) { + if (paramId > 1000) { + table = paramId / 1000; + param = paramId - table * 1000; + paramId = param; + } + switch (table) { + case 128: + paramId += 129000; + break; + default: + break; + } + } + + return grib_set_long_internal(grib_handle_of_accessor(a), self->paramId, paramId); +} + +int grib_accessor_class_ifs_param_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_ifs_param.h b/src/accessor/grib_accessor_class_ifs_param.h new file mode 100644 index 000000000..2beb90925 --- /dev/null +++ b/src/accessor/grib_accessor_class_ifs_param.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_ifs_param_t : public grib_accessor_gen_t +{ +public: + /* Members defined in ifs_param */ + const char* paramId; + const char* type; +}; + +class grib_accessor_class_ifs_param_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_ifs_param_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ifs_param_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_iterator.cc b/src/accessor/grib_accessor_class_iterator.cc new file mode 100644 index 000000000..4cdfd6670 --- /dev/null +++ b/src/accessor/grib_accessor_class_iterator.cc @@ -0,0 +1,48 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_iterator.h" + +grib_accessor_class_iterator_t _grib_accessor_class_iterator{"iterator"}; +grib_accessor_class* grib_accessor_class_iterator = &_grib_accessor_class_iterator; + +void grib_accessor_class_iterator_t::init(grib_accessor* a, const long l, grib_arguments* args) +{ + grib_accessor_class_gen_t::init(a, l, args); + grib_accessor_iterator_t* self = (grib_accessor_iterator_t*)a; + self->args = args; +} + +void grib_accessor_class_iterator_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + /* TODO: pass args */ + grib_dump_label(dumper, a, NULL); +} + +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_t* ita = NULL; + grib_iterator* iter = NULL; + *error = GRIB_NOT_IMPLEMENTED; + a = grib_find_accessor(h, "ITERATOR"); + ita = (grib_accessor_iterator_t*)a; + + if (!a) + return NULL; + + iter = grib_iterator_factory(h, ita->args, flags, error); + + if (iter) + *error = GRIB_SUCCESS; + + return iter; +} diff --git a/src/accessor/grib_accessor_class_iterator.h b/src/accessor/grib_accessor_class_iterator.h new file mode 100644 index 000000000..03fbdf5b6 --- /dev/null +++ b/src/accessor/grib_accessor_class_iterator.h @@ -0,0 +1,30 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_iterator_t : public grib_accessor_gen_t +{ +public: + grib_arguments* args; +}; + +class grib_accessor_class_iterator_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_iterator_t(const char* name) : grib_accessor_class_gen_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_iterator_t{}; } + void init(grib_accessor* a, const long l, grib_arguments* args) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; +}; + +//grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error) diff --git a/src/grib_accessor_class_julian_date.cc b/src/accessor/grib_accessor_class_julian_date.cc similarity index 66% rename from src/grib_accessor_class_julian_date.cc rename to src/accessor/grib_accessor_class_julian_date.cc index 61fd6959c..e633b42e4 100644 --- a/src/grib_accessor_class_julian_date.cc +++ b/src/accessor/grib_accessor_class_julian_date.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,129 +9,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; pack_double - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = unpack_string; pack_string - IMPLEMENTS = dump - IMPLEMENTS = init - IMPLEMENTS = pack_expression - MEMBERS = const char *year - MEMBERS = const char *month - MEMBERS = const char *day - MEMBERS = const char *hour - MEMBERS = const char *minute - MEMBERS = const char *second - MEMBERS = const char *ymd - MEMBERS = const char *hms - MEMBERS = char sep[5] - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_expression(grib_accessor*, grib_expression*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_julian_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in julian_date */ - const char *year; - const char *month; - const char *day; - const char *hour; - const char *minute; - const char *second; - const char *ymd; - const char *hms; - char sep[5]; -} grib_accessor_julian_date; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_julian_date = { - &grib_accessor_class_double, /* super */ - "julian_date", /* name */ - sizeof(grib_accessor_julian_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - &pack_expression, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_julian_date.h" +grib_accessor_class_julian_date_t _grib_accessor_class_julian_date{"julian_date"}; grib_accessor_class* grib_accessor_class_julian_date = &_grib_accessor_class_julian_date; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; +void grib_accessor_class_julian_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; int n = 0; grib_handle* h = grib_handle_of_accessor(a); @@ -163,18 +51,16 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static void dump(grib_accessor* a, grib_dumper* dumper) -{ +void grib_accessor_class_julian_date_t::dump(grib_accessor* a, grib_dumper* dumper){ grib_dump_string(dumper, a, NULL); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_julian_date_t::unpack_double(grib_accessor* a, double* val, size_t* len){ int ret = 0; long hour, minute, second; long year, month, day, ymd, hms; grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; if (self->ymd == NULL) { ret = grib_get_long(h, self->year, &year); @@ -222,9 +108,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; +int grib_accessor_class_julian_date_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; int ret = 0; long hour = 0; long minute = 0; @@ -272,12 +157,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return ret; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ +int grib_accessor_class_julian_date_t::unpack_string(grib_accessor* a, char* val, size_t* len){ int ret = 0; long hour, minute, second; long year, month, day, ymd, hms; - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; char* sep = self->sep; grib_handle* h = grib_handle_of_accessor(a); @@ -338,12 +222,11 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return ret; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ +int grib_accessor_class_julian_date_t::pack_string(grib_accessor* a, const char* val, size_t* len){ int ret = 0; long hour, minute, second; long year, month, day, ymd, hms; - grib_accessor_julian_date* self = (grib_accessor_julian_date*)a; + grib_accessor_julian_date_t* self = (grib_accessor_julian_date_t*)a; char* sep = self->sep; grib_handle* h = grib_handle_of_accessor(a); @@ -409,19 +292,16 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_julian_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ grib_context_log(a->context, GRIB_LOG_ERROR, " Cannot unpack %s as long", a->name); return GRIB_NOT_IMPLEMENTED; } -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ +int grib_accessor_class_julian_date_t::pack_long(grib_accessor* a, const long* v, size_t* len){ grib_context_log(a->context, GRIB_LOG_ERROR, " Cannot pack %s as long", a->name); return GRIB_NOT_IMPLEMENTED; } -static int pack_expression(grib_accessor* a, grib_expression* e) -{ +int grib_accessor_class_julian_date_t::pack_expression(grib_accessor* a, grib_expression* e){ size_t len = 1; long lval = 0; double dval = 0; @@ -439,16 +319,14 @@ static int pack_expression(grib_accessor* a, grib_expression* e) } /*if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %ld\n", a->name,lval);*/ - return grib_pack_long(a, &lval, &len); - } + return a->pack_long(&lval, &len); } case GRIB_TYPE_DOUBLE: { len = 1; ret = grib_expression_evaluate_double(hand, e, &dval); /*if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %g\n", a->name, dval);*/ - return grib_pack_double(a, &dval, &len); - } + return a->pack_double(&dval, &len); } case GRIB_TYPE_STRING: { char tmp[1024]; @@ -461,8 +339,7 @@ static int pack_expression(grib_accessor* a, grib_expression* e) len = strlen(cval); /*if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %s\n", a->name, cval);*/ - return grib_pack_string(a, cval, &len); - } + return a->pack_string(cval, &len); } } return GRIB_NOT_IMPLEMENTED; diff --git a/src/accessor/grib_accessor_class_julian_date.h b/src/accessor/grib_accessor_class_julian_date.h new file mode 100644 index 000000000..c52380e10 --- /dev/null +++ b/src/accessor/grib_accessor_class_julian_date.h @@ -0,0 +1,45 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_julian_date_t : public grib_accessor_double_t +{ +public: + /* Members defined in julian_date */ + const char *year; + const char *month; + const char *day; + const char *hour; + const char *minute; + const char *second; + const char *ymd; + const char *hms; + char sep[5]; +}; + +class grib_accessor_class_julian_date_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_julian_date_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_julian_date_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_julian_day.cc b/src/accessor/grib_accessor_class_julian_day.cc new file mode 100644 index 000000000..e46751181 --- /dev/null +++ b/src/accessor/grib_accessor_class_julian_day.cc @@ -0,0 +1,107 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_julian_day.h" + +grib_accessor_class_julian_day_t _grib_accessor_class_julian_day{"julian_day"}; +grib_accessor_class* grib_accessor_class_julian_day = &_grib_accessor_class_julian_day; + + +void grib_accessor_class_julian_day_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_julian_day_t* self = (grib_accessor_julian_day_t*)a; + int n = 0; + + self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->hour = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->minute = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->second = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->length = 0; +} + +void grib_accessor_class_julian_day_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_julian_day_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + const double v = *val; + return pack_double(a, &v, len); +} + +int grib_accessor_class_julian_day_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_julian_day_t* self = (grib_accessor_julian_day_t*)a; + int ret = 0; + long hour = 0; + long minute = 0; + long second = 0; + long date = 0; + long year, month, day; + + ret = grib_julian_to_datetime(*val, &year, &month, &day, &hour, &minute, &second); + if (ret != 0) + return ret; + + date = year * 10000 + month * 100 + day; + + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->date, date); + if (ret != 0) + return ret; + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->hour, hour); + if (ret != 0) + return ret; + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->minute, minute); + if (ret != 0) + return ret; + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->second, second); + + return ret; +} + +int grib_accessor_class_julian_day_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = 0; + double v = 0; + + ret = unpack_double(a, &v, len); + *val = (long)v; + + return ret; +} + +int grib_accessor_class_julian_day_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + int ret = 0; + long date, hour, minute, second; + long year, month, day; + grib_accessor_julian_day_t* self = (grib_accessor_julian_day_t*)a; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date); + if (ret != GRIB_SUCCESS) + return ret; + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->hour, &hour); + if (ret != GRIB_SUCCESS) + return ret; + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->minute, &minute); + if (ret != GRIB_SUCCESS) + return ret; + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->second, &second); + if (ret != GRIB_SUCCESS) + return ret; + + year = date / 10000; + date %= 10000; + month = date / 100; + date %= 100; + day = date; + + ret = grib_datetime_to_julian(year, month, day, hour, minute, second, val); + + return ret; +} diff --git a/src/accessor/grib_accessor_class_julian_day.h b/src/accessor/grib_accessor_class_julian_day.h new file mode 100644 index 000000000..5d06753b0 --- /dev/null +++ b/src/accessor/grib_accessor_class_julian_day.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_julian_day_t : public grib_accessor_double_t +{ +public: + /* Members defined in julian_day */ + const char *date; + const char *hour; + const char *minute; + const char *second; +}; + +class grib_accessor_class_julian_day_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_julian_day_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_julian_day_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_ksec1expver.cc b/src/accessor/grib_accessor_class_ksec1expver.cc new file mode 100644 index 000000000..0eb0af2c1 --- /dev/null +++ b/src/accessor/grib_accessor_class_ksec1expver.cc @@ -0,0 +1,95 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_ksec1expver.h" + +grib_accessor_class_ksec1expver_t _grib_accessor_class_ksec1expver{"ksec1expver"}; +grib_accessor_class* grib_accessor_class_ksec1expver = &_grib_accessor_class_ksec1expver; + + +void grib_accessor_class_ksec1expver_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_ascii_t::init(a, len, arg); + a->length = len; + Assert(a->length >= 0); +} + +int grib_accessor_class_ksec1expver_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + long pos = a->offset * 8; + char* intc = NULL; + char* pTemp = NULL; + char expver[5]; + char refexpver[5]; + size_t llen = a->length + 1; + Assert(a->length == 4); + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + value = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, a->length * 8); + + a->unpack_string(refexpver, &llen); + /* test for endian */ + intc = (char*)&value; + pTemp = intc; + + expver[0] = *pTemp++; + expver[1] = *pTemp++; + expver[2] = *pTemp++; + expver[3] = *pTemp++; + expver[4] = 0; + +// expver[0] = intc[0]; +// expver[1] = intc[1]; +// expver[2] = intc[2]; +// expver[3] = intc[3]; +// expver[4] = 0; + + /* if there is a difference, have to reverse*/ + if (strcmp(refexpver, expver)) { + intc[0] = expver[3]; + intc[1] = expver[2]; + intc[2] = expver[1]; + intc[3] = expver[0]; + } + + *val = value; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_ksec1expver_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + int i = 0; + if (len[0] != 4) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong length for %s. It has to be 4", a->name); + return GRIB_INVALID_KEY_VALUE; + } + if (len[0] > (a->length) + 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%lu) for %s, it contains %ld values", + len[0], a->name, a->length + 1); + len[0] = 0; + return GRIB_BUFFER_TOO_SMALL; + } + + for (i = 0; i < a->length; i++) + grib_handle_of_accessor(a)->buffer->data[a->offset + i] = val[i]; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_ksec1expver_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + char sval[5] = {0,}; + size_t slen = 4; + snprintf(sval, sizeof(sval), "%04d", (int)(*val)); + return pack_string(a, sval, &slen); +} diff --git a/src/accessor/grib_accessor_class_ksec1expver.h b/src/accessor/grib_accessor_class_ksec1expver.h new file mode 100644 index 000000000..098a40a14 --- /dev/null +++ b/src/accessor/grib_accessor_class_ksec1expver.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_ksec1expver_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in ksec1expver */ +}; + +class grib_accessor_class_ksec1expver_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_ksec1expver_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_ksec1expver_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_label.cc b/src/accessor/grib_accessor_class_label.cc new file mode 100644 index 000000000..5b9448399 --- /dev/null +++ b/src/accessor/grib_accessor_class_label.cc @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_label.h" + +grib_accessor_class_label_t _grib_accessor_class_label{"label"}; +grib_accessor_class* grib_accessor_class_label = &_grib_accessor_class_label; + + +void grib_accessor_class_label_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + a->length = 0; +} + +void grib_accessor_class_label_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_label(dumper, a, NULL); +} + +int grib_accessor_class_label_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LABEL; +} + +int grib_accessor_class_label_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + size_t vlen = strlen(a->name); + if (vlen > *len) + return GRIB_BUFFER_TOO_SMALL; + *len = vlen; + strcpy(val, a->name); + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_label.h b/src/accessor/grib_accessor_class_label.h new file mode 100644 index 000000000..59590e77c --- /dev/null +++ b/src/accessor/grib_accessor_class_label.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_label_t : public grib_accessor_gen_t +{ +public: + /* Members defined in label */ +}; + +class grib_accessor_class_label_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_label_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_label_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_latitudes.cc b/src/accessor/grib_accessor_class_latitudes.cc new file mode 100644 index 000000000..1c69d39e9 --- /dev/null +++ b/src/accessor/grib_accessor_class_latitudes.cc @@ -0,0 +1,217 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_latitudes.h" + +grib_accessor_class_latitudes_t _grib_accessor_class_latitudes{ "latitudes" }; +grib_accessor_class* grib_accessor_class_latitudes = &_grib_accessor_class_latitudes; + +static int get_distinct(grib_accessor* a, double** val, long* len); +int compare_doubles(const void* a, const void* b, int ascending) +{ + // ascending is a boolean: 0 or 1 + double* arg1 = (double*)a; + double* arg2 = (double*)b; + if (ascending) { + if (*arg1 < *arg2) + return -1; // Smaller values come before larger ones + } + else { + if (*arg1 > *arg2) + return -1; // Larger values come before smaller ones + } + if (*arg1 == *arg2) + return 0; + else + return 1; +} +int compare_doubles_ascending(const void* a, const void* b) +{ + return compare_doubles(a, b, 1); +} +int compare_doubles_descending(const void* a, const void* b) +{ + return compare_doubles(a, b, 0); +} + +void grib_accessor_class_latitudes_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; + int n = 0; + + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->distinct = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + self->save = 0; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_latitudes_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_context* c = a->context; + grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; + int ret = 0; + double* v = val; + double dummyLon = 0; + size_t size = 0; + long count = 0; + grib_iterator* iter = NULL; + + self->save = 1; + ret = value_count(a, &count); + if (ret) return ret; + size = count; + if (*len < size) { + // self->lats are computed in value_count so must free + if (self->lats) { + grib_context_free(c, self->lats); + self->lats = NULL; + } + return GRIB_ARRAY_TOO_SMALL; + } + self->save = 0; + + // self->lats are computed in value_count + if (self->lats) { + int i; + *len = self->size; + for (i = 0; i < size; i++) + val[i] = self->lats[i]; + grib_context_free(c, self->lats); + self->lats = NULL; + self->size = 0; + return GRIB_SUCCESS; + } + + // ECC-1525 Performance: We do not need the values to be decoded + iter = grib_iterator_new(grib_handle_of_accessor(a), GRIB_GEOITERATOR_NO_VALUES, &ret); + if (ret != GRIB_SUCCESS) { + if (iter) + grib_iterator_delete(iter); + grib_context_log(c, GRIB_LOG_ERROR, "latitudes: Unable to create iterator"); + return ret; + } + + while (grib_iterator_next(iter, v++, &dummyLon, NULL)) {} + grib_iterator_delete(iter); + + *len = size; + + return ret; +} + +int grib_accessor_class_latitudes_t::value_count(grib_accessor* a, long* len) +{ + grib_accessor_latitudes_t* self = (grib_accessor_latitudes_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = a->context; + double* val = NULL; + int ret; + size_t size; + + *len = 0; + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) { + grib_context_log(h->context, GRIB_LOG_ERROR, "latitudes: Unable to get size of %s", self->values); + return ret; + } + *len = size; + + // See ECC-1792 + // Give priority to the Grid Section (rather than the Data Section) + long numberOfDataPoints = 0; + if (grib_get_long(h, "numberOfDataPoints", &numberOfDataPoints) == GRIB_SUCCESS) { + *len = numberOfDataPoints; + } + + if (self->distinct) { + ret = get_distinct(a, &val, len); + if (ret != GRIB_SUCCESS) + return ret; + if (self->save) { + self->lats = val; + self->size = *len; + } + else { + grib_context_free(c, val); + } + } + + return ret; +} + +static int get_distinct(grib_accessor* a, double** val, long* len) +{ + long count = 0; + double prev; + double* v = NULL; + double* v1 = NULL; + double dummyLon = 0; + int ret = GRIB_SUCCESS; + int i; + long jScansPositively = 0; // default: north to south + size_t size = *len; + grib_context* c = a->context; + + // Performance: We do not need the values to be decoded + grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), GRIB_GEOITERATOR_NO_VALUES, &ret); + if (ret != GRIB_SUCCESS) { + if (iter) + grib_iterator_delete(iter); + grib_context_log(c, GRIB_LOG_ERROR, "latitudes: Unable to create iterator"); + return ret; + } + v = (double*)grib_context_malloc_clear(c, size * sizeof(double)); + if (!v) { + grib_context_log(c, GRIB_LOG_ERROR, "latitudes: Error allocating %zu bytes", size * sizeof(double)); + return GRIB_OUT_OF_MEMORY; + } + *val = v; + + while (grib_iterator_next(iter, v++, &dummyLon, NULL)) {} + grib_iterator_delete(iter); + v = *val; + + // See which direction the latitudes are to be scanned + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), "jScansPositively", &jScansPositively))) + return ret; + if (jScansPositively) { + qsort(v, *len, sizeof(double), &compare_doubles_ascending); //South to North + } + else { + qsort(v, *len, sizeof(double), &compare_doubles_descending); //North to South + } + + v1 = (double*)grib_context_malloc_clear(c, size * sizeof(double)); + if (!v1) { + grib_context_log(c, GRIB_LOG_ERROR, "latitudes: Error allocating %zu bytes", size * sizeof(double)); + return GRIB_OUT_OF_MEMORY; + } + + // Construct a unique set of lats by filtering out duplicates + prev = v[0]; + v1[0] = prev; + count = 1; + for (i = 1; i < *len; i++) { + if (v[i] != prev) { + prev = v[i]; + v1[count] = prev; // Value different from previous so store it + count++; + } + } + + grib_context_free(c, v); + + *val = v1; + + *len = count; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_latitudes.h b/src/accessor/grib_accessor_class_latitudes.h new file mode 100644 index 000000000..cb1f6ada8 --- /dev/null +++ b/src/accessor/grib_accessor_class_latitudes.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_latitudes_t : public grib_accessor_double_t +{ +public: + /* Members defined in latitudes */ + const char* values; + long distinct; + double* lats; + long size; + int save; +}; + +class grib_accessor_class_latitudes_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latitudes_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latitudes_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_latlon_increment.cc b/src/accessor/grib_accessor_class_latlon_increment.cc similarity index 61% rename from src/grib_accessor_class_latlon_increment.cc rename to src/accessor/grib_accessor_class_latlon_increment.cc index de43e60c9..885a4cd61 100644 --- a/src/grib_accessor_class_latlon_increment.cc +++ b/src/accessor/grib_accessor_class_latlon_increment.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,118 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double;is_missing - IMPLEMENTS = init - MEMBERS=const char* directionIncrementGiven - MEMBERS=const char* directionIncrement - MEMBERS=const char* scansPositively - MEMBERS=const char* first - MEMBERS=const char* last - MEMBERS=const char* numberOfPoints - MEMBERS=const char* angleMultiplier - MEMBERS=const char* angleDivisor - MEMBERS=long isLongitude - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_latlon_increment -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in latlon_increment */ - const char* directionIncrementGiven; - const char* directionIncrement; - const char* scansPositively; - const char* first; - const char* last; - const char* numberOfPoints; - const char* angleMultiplier; - const char* angleDivisor; - long isLongitude; -} grib_accessor_latlon_increment; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_latlon_increment = { - &grib_accessor_class_double, /* super */ - "latlon_increment", /* name */ - sizeof(grib_accessor_latlon_increment), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_latlon_increment.h" +grib_accessor_class_latlon_increment_t _grib_accessor_class_latlon_increment{"latlon_increment"}; grib_accessor_class* grib_accessor_class_latlon_increment = &_grib_accessor_class_latlon_increment; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a; +void grib_accessor_class_latlon_increment_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_latlon_increment_t* self = (grib_accessor_latlon_increment_t*)a; int n = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -134,9 +32,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->isLongitude = grib_arguments_get_long(hand, c, n++); } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a; +int grib_accessor_class_latlon_increment_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_latlon_increment_t* self = (grib_accessor_latlon_increment_t*)a; int ret = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -221,9 +118,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_latlon_increment* self = (grib_accessor_latlon_increment*)a; +int grib_accessor_class_latlon_increment_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_latlon_increment_t* self = (grib_accessor_latlon_increment_t*)a; int ret = 0; long codedNumberOfPoints = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -305,8 +201,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) return GRIB_SUCCESS; } -static int is_missing(grib_accessor* a) -{ +int grib_accessor_class_latlon_increment_t::is_missing(grib_accessor* a){ size_t len = 1; double val = 0; diff --git a/src/accessor/grib_accessor_class_latlon_increment.h b/src/accessor/grib_accessor_class_latlon_increment.h new file mode 100644 index 000000000..8dfa7cb93 --- /dev/null +++ b/src/accessor/grib_accessor_class_latlon_increment.h @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_latlon_increment_t : public grib_accessor_double_t +{ +public: + /* Members defined in latlon_increment */ + const char* directionIncrementGiven; + const char* directionIncrement; + const char* scansPositively; + const char* first; + const char* last; + const char* numberOfPoints; + const char* angleMultiplier; + const char* angleDivisor; + long isLongitude; +}; + +class grib_accessor_class_latlon_increment_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latlon_increment_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latlon_increment_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_latlonvalues.cc b/src/accessor/grib_accessor_class_latlonvalues.cc new file mode 100644 index 000000000..5d43d6be9 --- /dev/null +++ b/src/accessor/grib_accessor_class_latlonvalues.cc @@ -0,0 +1,76 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_latlonvalues.h" + +grib_accessor_class_latlonvalues_t _grib_accessor_class_latlonvalues{"latlonvalues"}; +grib_accessor_class* grib_accessor_class_latlonvalues = &_grib_accessor_class_latlonvalues; + + +void grib_accessor_class_latlonvalues_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_latlonvalues_t* self = (grib_accessor_latlonvalues_t*)a; + int n = 0; + + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_latlonvalues_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_context* c = a->context; + int err = 0; + double* v = val; + double lat, lon, value; + size_t size = 0; + long count = 0; + grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), 0, &err); + if (err) { + if (iter) grib_iterator_delete(iter); + grib_context_log(c, GRIB_LOG_ERROR, "latlonvalues: Unable to create iterator"); + return err; + } + + err = value_count(a, &count); + if (err) return err; + size = count; + + if (*len < size) { + if (iter) grib_iterator_delete(iter); + return GRIB_ARRAY_TOO_SMALL; + } + + while (grib_iterator_next(iter, &lat, &lon, &value)) { + *(v++) = lat; + *(v++) = lon; + *(v++) = value; + } + + grib_iterator_delete(iter); + + *len = size; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_latlonvalues_t::value_count(grib_accessor* a, long* count){ + grib_accessor_latlonvalues_t* self = (grib_accessor_latlonvalues_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + int ret = GRIB_SUCCESS; + size_t size; + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) { + grib_context_log(h->context, GRIB_LOG_ERROR, "latlonvalues: Unable to get size of %s", self->values); + return ret; + } + + *count = 3 * size; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_latlonvalues.h b/src/accessor/grib_accessor_class_latlonvalues.h new file mode 100644 index 000000000..7328688c6 --- /dev/null +++ b/src/accessor/grib_accessor_class_latlonvalues.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_latlonvalues_t : public grib_accessor_double_t +{ +public: + /* Members defined in latlonvalues */ + const char* values; +}; + +class grib_accessor_class_latlonvalues_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_latlonvalues_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_latlonvalues_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_library_version.cc b/src/accessor/grib_accessor_class_library_version.cc new file mode 100644 index 000000000..527b4809a --- /dev/null +++ b/src/accessor/grib_accessor_class_library_version.cc @@ -0,0 +1,45 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_library_version.h" + +grib_accessor_class_library_version_t _grib_accessor_class_library_version{"library_version"}; +grib_accessor_class* grib_accessor_class_library_version = &_grib_accessor_class_library_version; + + +int grib_accessor_class_library_version_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + char result[30] = {0,}; + size_t size; + + int major = ECCODES_MAJOR_VERSION; + int minor = ECCODES_MINOR_VERSION; + int revision = ECCODES_REVISION_VERSION; + + snprintf(result, sizeof(result), "%d.%d.%d", major, minor, revision); + size = sizeof(result); + + if (*len < size) + return GRIB_ARRAY_TOO_SMALL; + strcpy(val, result); + + *len = size; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_library_version_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_library_version_t::string_length(grib_accessor* a){ + return 255; +} diff --git a/src/accessor/grib_accessor_class_library_version.h b/src/accessor/grib_accessor_class_library_version.h new file mode 100644 index 000000000..cb2a45f04 --- /dev/null +++ b/src/accessor/grib_accessor_class_library_version.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_library_version_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in library_version */ +}; + +class grib_accessor_class_library_version_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_library_version_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_library_version_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; +}; diff --git a/src/grib_accessor_class_local_definition.cc b/src/accessor/grib_accessor_class_local_definition.cc similarity index 72% rename from src/grib_accessor_class_local_definition.cc rename to src/accessor/grib_accessor_class_local_definition.cc index 782ce5fde..0964a3005 100644 --- a/src/grib_accessor_class_local_definition.cc +++ b/src/accessor/grib_accessor_class_local_definition.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,125 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * This pertains to GRIB edition 2 - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* productDefinitionTemplateNumberInternal - MEMBERS=const char* grib2LocalSectionNumber - MEMBERS=const char* type - MEMBERS=const char* stream - MEMBERS=const char* the_class - MEMBERS=const char* eps - MEMBERS=const char* stepType - MEMBERS=const char* derivedForecast - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_local_definition -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in local_definition */ - const char* productDefinitionTemplateNumber; - const char* productDefinitionTemplateNumberInternal; - const char* grib2LocalSectionNumber; - const char* type; - const char* stream; - const char* the_class; - const char* eps; - const char* stepType; - const char* derivedForecast; -} grib_accessor_local_definition; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_local_definition = { - &grib_accessor_class_unsigned, /* super */ - "local_definition", /* name */ - sizeof(grib_accessor_local_definition), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_local_definition.h" +grib_accessor_class_local_definition_t _grib_accessor_class_local_definition{"local_definition"}; grib_accessor_class* grib_accessor_class_local_definition = &_grib_accessor_class_local_definition; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_local_definition* self = (grib_accessor_local_definition*)a; +void grib_accessor_class_local_definition_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); + grib_accessor_local_definition_t* self = (grib_accessor_local_definition_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -141,16 +32,14 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->derivedForecast = grib_arguments_get_name(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_local_definition* self = (grib_accessor_local_definition*)a; +int grib_accessor_class_local_definition_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_local_definition_t* self = (grib_accessor_local_definition_t*)a; return grib_get_long(grib_handle_of_accessor(a), self->grib2LocalSectionNumber, val); } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_local_definition* self = (grib_accessor_local_definition*)a; +int grib_accessor_class_local_definition_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_local_definition_t* self = (grib_accessor_local_definition_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long productDefinitionTemplateNumber = -1; long productDefinitionTemplateNumberInternal = -1; @@ -316,7 +205,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) #ifdef DEBUG // In test & development mode, fail so we remember to adjust PDTN grib_context_log(a->context, GRIB_LOG_ERROR, - "grib_accessor_local_definition: Invalid localDefinitionNumber %d", localDefinitionNumber); + "grib_accessor_local_definition_t: Invalid localDefinitionNumber %d", localDefinitionNumber); return GRIB_ENCODING_ERROR; #endif // ECC-1253: Do not fail in operations. Leave PDTN as is @@ -419,7 +308,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) { if (a->context->debug) { - fprintf(stderr, "ECCODES DEBUG grib_accessor_local_definition: ldNumber=%d, newPDTN=%ld\n", + fprintf(stderr, "ECCODES DEBUG grib_accessor_local_definition_t: ldNumber=%d, newPDTN=%ld\n", localDefinitionNumber, productDefinitionTemplateNumberNew); } if (tooEarly) @@ -435,8 +324,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return 0; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_local_definition_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_local_definition.h b/src/accessor/grib_accessor_class_local_definition.h new file mode 100644 index 000000000..f91ebbef4 --- /dev/null +++ b/src/accessor/grib_accessor_class_local_definition.h @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_local_definition_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in local_definition */ + const char* productDefinitionTemplateNumber; + const char* productDefinitionTemplateNumberInternal; + const char* grib2LocalSectionNumber; + const char* type; + const char* stream; + const char* the_class; + const char* eps; + const char* stepType; + const char* derivedForecast; +}; + +class grib_accessor_class_local_definition_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_local_definition_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_local_definition_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_long.cc b/src/accessor/grib_accessor_class_long.cc new file mode 100644 index 000000000..588083c49 --- /dev/null +++ b/src/accessor/grib_accessor_class_long.cc @@ -0,0 +1,182 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_long.h" + +grib_accessor_class_long_t _grib_accessor_class_long{"long"}; +grib_accessor_class* grib_accessor_class_long = &_grib_accessor_class_long; + +void grib_accessor_class_long_t::init(grib_accessor* a, const long len, grib_arguments* arg) { + grib_accessor_class_gen_t::init(a, len, arg); +} + +int grib_accessor_class_long_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_LONG; +} + +void grib_accessor_class_long_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_long_t::unpack_string(grib_accessor* a, char* v, size_t* len) +{ + long val = 0; + size_t l = 1; + char repres[1024]; + char format[32] = "%ld"; + grib_handle* h = grib_handle_of_accessor(a); + + a->unpack_long(&val, &l); + /* TODO: We should catch all errors but in this case the test ERA_Gen.sh will fail + * as the output from grib_ls will be different */ + + if ((val == GRIB_MISSING_LONG) && ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0)) { + snprintf(repres, sizeof(repres), "MISSING"); + } else { + size_t size = sizeof(format); + grib_get_string(h, "formatForLongs", format, &size); + snprintf(repres, sizeof(repres), format, val); + } + + l = strlen(repres) + 1; + + if (*len < l) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + /*grib_context_log(a->context,GRIB_LOG_DEBUG, "grib_accessor_long: Casting long %s to string ", a->name);*/ + + *len = l; + + strcpy(v, repres); + return GRIB_SUCCESS; +} + +int grib_accessor_class_long_t::pack_missing(grib_accessor* a) +{ + size_t len = 1; + long value = GRIB_MISSING_LONG; + + if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) + return a->pack_long(&value, &len); + + return GRIB_VALUE_CANNOT_BE_MISSING; +} + +int grib_accessor_class_long_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + size_t rlen = 0; + long count = 0; + unsigned long i = 0; + long* values = NULL; + long oneval = 0; + int ret = GRIB_SUCCESS; + + ret = a->value_count(&count); + if (ret) + return ret; + rlen = count; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %lu values", a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + if (rlen == 1) { + ret = a->unpack_long(&oneval, &rlen); + if (ret != GRIB_SUCCESS) + return ret; + *val = oneval; + *len = 1; + return GRIB_SUCCESS; + } + + values = (long*)grib_context_malloc(a->context, rlen * sizeof(long)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + ret = a->unpack_long(values, &rlen); + if (ret != GRIB_SUCCESS) { + grib_context_free(a->context, values); + return ret; + } + for (i = 0; i < rlen; i++) + val[i] = values[i]; + + grib_context_free(a->context, values); + + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_long_t::compare(grib_accessor* a, grib_accessor* b) +{ + int retval = 0; + long* aval = 0; + long* bval = 0; + long count = 0; + + size_t alen = 0; + size_t blen = 0; + int err = 0; + + err = a->value_count(&count); + if (err) + return err; + alen = count; + + err = b->value_count(&count); + if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (long*)grib_context_malloc(a->context, alen * sizeof(long)); + bval = (long*)grib_context_malloc(b->context, blen * sizeof(long)); + + a->unpack_long(aval, &alen); + b->unpack_long(bval, &blen); + + retval = GRIB_SUCCESS; + for (size_t i=0; icontext, aval); + grib_context_free(b->context, bval); + + return retval; +} + +int grib_accessor_class_long_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ + long v = 0; /* The converted value */ + + // ECC-1722 + if (STR_EQUAL_NOCASE(val, "missing")) { + return pack_missing(a); + } + + if (string_to_long(val, &v, 1) != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Trying to pack \"%s\" as long. String cannot be converted to an integer", val); + return GRIB_WRONG_TYPE; + } + return a->pack_long(&v, len); +} diff --git a/src/accessor/grib_accessor_class_long.h b/src/accessor/grib_accessor_class_long.h new file mode 100644 index 000000000..72a67a8e5 --- /dev/null +++ b/src/accessor/grib_accessor_class_long.h @@ -0,0 +1,31 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_long_t : public grib_accessor_gen_t +{}; + +class grib_accessor_class_long_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_long_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_long_t{}; } + void init(grib_accessor* a, const long len, grib_arguments* arg) override; + int get_native_type(grib_accessor* a) override; + int pack_missing(grib_accessor* a) override; + int pack_string(grib_accessor* a, const char*, size_t* len) override; + int unpack_double(grib_accessor* a, double* val, size_t* len) override; + int unpack_string(grib_accessor* a, char*, size_t* len) override; + void dump(grib_accessor* a, grib_dumper*) override; + int compare(grib_accessor* a, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_long_vector.cc b/src/accessor/grib_accessor_class_long_vector.cc new file mode 100644 index 000000000..0aee8c8c9 --- /dev/null +++ b/src/accessor/grib_accessor_class_long_vector.cc @@ -0,0 +1,95 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_long_vector.h" +#include "grib_accessor_class_abstract_long_vector.h" + +grib_accessor_class_long_vector_t _grib_accessor_class_long_vector{"long_vector"}; +grib_accessor_class* grib_accessor_class_long_vector = &_grib_accessor_class_long_vector; + + +void grib_accessor_class_long_vector_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_long_vector_t::init(a, l, c); + grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; + grib_accessor* va = NULL; + grib_accessor_abstract_long_vector_t* v = NULL; + int n = 0; + + self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + v = (grib_accessor_abstract_long_vector_t*)va; + + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + + /* check self->index on init and never change it */ + Assert(self->index < v->number_of_elements && self->index >= 0); + + a->length = 0; +} + +int grib_accessor_class_long_vector_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + size_t size = 0; + int err = 0; + long* vector; + grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; + grib_accessor* va = NULL; + grib_accessor_abstract_long_vector_t* v = NULL; + + va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + v = (grib_accessor_abstract_long_vector_t*)va; + + /*TODO implement the dirty mechanism to avoid to unpack every time */ + err = grib_get_size(grib_handle_of_accessor(a), self->vector, &size); + if (err) return err; + DEBUG_ASSERT(size > 0); + vector = (long*)grib_context_malloc(a->context, sizeof(long) * size); + err = va->unpack_long(vector, &size); grib_context_free(a->context, vector); + if (err) return err; + + *val = v->v[self->index]; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_long_vector_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + long lval = 0; + int err = 0; + grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; + grib_accessor* va = NULL; + grib_accessor_abstract_long_vector_t* v = NULL; + va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + v = (grib_accessor_abstract_long_vector_t*)va; + + err = unpack_long(a, &lval, len); + + *val = (double)v->v[self->index]; + + return err; +} + +int grib_accessor_class_long_vector_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + int err = 0; + grib_accessor_long_vector_t* self = (grib_accessor_long_vector_t*)a; + grib_accessor* va = NULL; + grib_accessor_abstract_long_vector_t* v = NULL; + + va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + v = (grib_accessor_abstract_long_vector_t*)va; + + v->pack_index = self->index; + + err = va->pack_long(val, len); + return err; +} + +int grib_accessor_class_long_vector_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_long_vector.h b/src/accessor/grib_accessor_class_long_vector.h new file mode 100644 index 000000000..010a4ed7e --- /dev/null +++ b/src/accessor/grib_accessor_class_long_vector.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_abstract_long_vector.h" + +class grib_accessor_long_vector_t : public grib_accessor_abstract_long_vector_t +{ +public: + /* Members defined in long_vector */ + const char* vector; + int index; +}; + +class grib_accessor_class_long_vector_t : public grib_accessor_class_abstract_long_vector_t +{ +public: + grib_accessor_class_long_vector_t(const char* name) : grib_accessor_class_abstract_long_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_long_vector_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_longitudes.cc b/src/accessor/grib_accessor_class_longitudes.cc similarity index 55% rename from src/grib_accessor_class_longitudes.cc rename to src/accessor/grib_accessor_class_longitudes.cc index 083d40138..a9ae31309 100644 --- a/src/grib_accessor_class_longitudes.cc +++ b/src/accessor/grib_accessor_class_longitudes.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,114 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS =const char* values - MEMBERS =long distinct - MEMBERS =double* lons - MEMBERS =long size - MEMBERS =int save - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_longitudes -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in longitudes */ - const char* values; - long distinct; - double* lons; - long size; - int save; -} grib_accessor_longitudes; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_longitudes = { - &grib_accessor_class_double, /* super */ - "longitudes", /* name */ - sizeof(grib_accessor_longitudes), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_longitudes.h" +grib_accessor_class_longitudes_t _grib_accessor_class_longitudes{"longitudes"}; grib_accessor_class* grib_accessor_class_longitudes = &_grib_accessor_class_longitudes; -/* END_CLASS_IMP */ - static int get_distinct(grib_accessor* a, double** val, long* len); -static int compare_doubles(const void* a, const void* b); - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_longitudes* self = (grib_accessor_longitudes*)a; +int compare_doubles(const void* a, const void* b); +void grib_accessor_class_longitudes_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; int n = 0; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -126,10 +30,9 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ +int grib_accessor_class_longitudes_t::unpack_double(grib_accessor* a, double* val, size_t* len){ grib_context* c = a->context; - grib_accessor_longitudes* self = (grib_accessor_longitudes*)a; + grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; int ret = 0; double* v = val; double dummyLat = 0; @@ -181,9 +84,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_longitudes* self = (grib_accessor_longitudes*)a; +int grib_accessor_class_longitudes_t::value_count(grib_accessor* a, long* len){ + grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; grib_handle* h = grib_handle_of_accessor(a); grib_context* c = a->context; double* val = NULL; @@ -196,6 +98,13 @@ static int value_count(grib_accessor* a, long* len) } *len = size; + // See ECC-1792 + // Give priority to the Grid Section (rather than the Data Section) + long numberOfDataPoints = 0; + if (grib_get_long(h, "numberOfDataPoints", &numberOfDataPoints) == GRIB_SUCCESS) { + *len = numberOfDataPoints; + } + if (self->distinct) { ret = get_distinct(a, &val, len); if (ret != GRIB_SUCCESS) @@ -212,15 +121,13 @@ static int value_count(grib_accessor* a, long* len) return ret; } -static int get_distinct(grib_accessor* a, double** val, long* len) -{ +static int get_distinct(grib_accessor* a, double** val, long* len){ long count = 0; double prev; double* v = NULL; double* v1 = NULL; double dummyLat = 0; int ret = 0; - int i; size_t size = *len; grib_context* c = a->context; @@ -254,7 +161,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len) prev = v[0]; v1[0] = prev; count = 1; - for (i = 1; i < *len; i++) { + for (long i = 1; i < *len; i++) { if (v[i] != prev) { prev = v[i]; v1[count] = prev; @@ -270,8 +177,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len) return GRIB_SUCCESS; } -static int compare_doubles(const void* a, const void* b) -{ +int compare_doubles(const void* a, const void* b){ double* arg1 = (double*)a; double* arg2 = (double*)b; if (*arg1 < *arg2) diff --git a/src/accessor/grib_accessor_class_longitudes.h b/src/accessor/grib_accessor_class_longitudes.h new file mode 100644 index 000000000..def174a74 --- /dev/null +++ b/src/accessor/grib_accessor_class_longitudes.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_longitudes_t : public grib_accessor_double_t +{ +public: + /* Members defined in longitudes */ + const char* values; + long distinct; + double* lons; + long size; + int save; +}; + +class grib_accessor_class_longitudes_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_longitudes_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_longitudes_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_lookup.cc b/src/accessor/grib_accessor_class_lookup.cc new file mode 100644 index 000000000..17ccd4d61 --- /dev/null +++ b/src/accessor/grib_accessor_class_lookup.cc @@ -0,0 +1,133 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_lookup.h" + +grib_accessor_class_lookup_t _grib_accessor_class_lookup{"lookup"}; +grib_accessor_class* grib_accessor_class_lookup = &_grib_accessor_class_lookup; + + +void grib_accessor_class_lookup_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_long_t::init(a, len, arg); + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + a->length = 0; + self->llength = len; + self->loffset = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 0); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + self->real_name = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 1); +} + +void grib_accessor_class_lookup_t::post_init(grib_accessor* a){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + if (self->real_name) { + grib_dependency_observe_expression(a, self->real_name); + } +} + +void grib_accessor_class_lookup_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + unsigned char bytes[1024] = {0,}; + char msg[1024] = {0,}; + char buf[2048]; + int i; + unsigned long v = 0; + + size_t llen = self->llength; + a->unpack_bytes(bytes, &llen); + bytes[llen] = 0; + for (i = 0; i < llen; i++) { + msg[i] = isprint(bytes[i]) ? bytes[i] : '?'; + v <<= 8; + v |= bytes[i]; + } + + msg[llen] = 0; + + snprintf(buf, sizeof(buf), "%s %lu %ld-%ld", msg, v, (long)a->offset + self->loffset, (long)self->llength); + + grib_dump_long(dumper, a, buf); +} + +int grib_accessor_class_lookup_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + unsigned char bytes[1024] = {0,}; + int i; + + size_t llen = self->llength; + a->unpack_bytes(bytes, &llen); + bytes[llen] = 0; + + for (i = 0; i < llen; i++) { + v[i] = isprint(bytes[i]) ? bytes[i] : '?'; + } + + v[llen] = 0; + if (llen == 1 && v[0] == '?') { + /* Try unpack as long */ + size_t length = 10; + long lval = 0; + int err = unpack_long(a, &lval, &length); + if (!err) { + char str[5]; + int conv = snprintf(str, sizeof(str), "%ld", lval); + if (conv == 1) { + v[0] = str[0]; + } + } + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_lookup_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + long pos = (a->offset + self->loffset) * 8; + + if (len[0] < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + len[0] = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + /* This is used when reparsing or rebuilding */ + if (h->loader) { + Assert(*len == 1); + return h->loader->lookup_long(h->context, h->loader, a->name, val); + } + + val[0] = grib_decode_unsigned_long(h->buffer->data, &pos, self->llength * 8); + len[0] = 1; + + /*printf("###########lookup unpack_long: %s %ld %ld\n",a->name, pos/8, val[0]);*/ + + return GRIB_SUCCESS; +} + +int grib_accessor_class_lookup_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +long grib_accessor_class_lookup_t::byte_count(grib_accessor* a){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + return self->llength; +} + +long grib_accessor_class_lookup_t::byte_offset(grib_accessor* a){ + grib_accessor_lookup_t* self = (grib_accessor_lookup_t*)a; + return self->loffset; +} + +int grib_accessor_class_lookup_t::notify_change(grib_accessor* self, grib_accessor* changed){ + /* Forward changes */ + return grib_dependency_notify_change(self); +} diff --git a/src/accessor/grib_accessor_class_lookup.h b/src/accessor/grib_accessor_class_lookup.h new file mode 100644 index 000000000..be1663ae7 --- /dev/null +++ b/src/accessor/grib_accessor_class_lookup.h @@ -0,0 +1,38 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_lookup_t : public grib_accessor_long_t +{ +public: + long llength; + long loffset; + grib_expression* real_name; +}; + +class grib_accessor_class_lookup_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_lookup_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_lookup_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void post_init(grib_accessor*) override; + int notify_change(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_mars_param.cc b/src/accessor/grib_accessor_class_mars_param.cc new file mode 100644 index 000000000..feb5fc905 --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_param.cc @@ -0,0 +1,53 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_mars_param.h" + +grib_accessor_class_mars_param_t _grib_accessor_class_mars_param{"mars_param"}; +grib_accessor_class* grib_accessor_class_mars_param = &_grib_accessor_class_mars_param; + + +void grib_accessor_class_mars_param_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_ascii_t::init(a, l, c); + int n = 0; + grib_accessor_mars_param_t* self = (grib_accessor_mars_param_t*)a; + self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->table = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->param = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +// For an implementation of pack_string, see +// src/deprecated/grib_accessor_class_mars_param.cc + +// For an alternative implementation of unpack_string, see +// src/deprecated/grib_accessor_class_mars_param.cc +// +int grib_accessor_class_mars_param_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_mars_param_t* self = (grib_accessor_mars_param_t*)a; + long param = 0; + long table = 0; + int ret = 0; + + if (self->table != NULL && (ret = grib_get_long_internal(grib_handle_of_accessor(a), self->table, &table)) != GRIB_SUCCESS) + return ret; + if (self->param != NULL && (ret = grib_get_long_internal(grib_handle_of_accessor(a), self->param, ¶m)) != GRIB_SUCCESS) + return ret; + + /*if (table==200) table=128;*/ + snprintf(val, 32, "%ld.%ld", param, table); + *len = strlen(val) + 1; + + return GRIB_SUCCESS; +} + +size_t grib_accessor_class_mars_param_t::string_length(grib_accessor* a){ + return 7; +} diff --git a/src/accessor/grib_accessor_class_mars_param.h b/src/accessor/grib_accessor_class_mars_param.h new file mode 100644 index 000000000..1eab50fb6 --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_param.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_mars_param_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in mars_param */ + const char* paramId; + const char* table; + const char* param; +}; + +class grib_accessor_class_mars_param_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_mars_param_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_mars_param_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_mars_step.cc b/src/accessor/grib_accessor_class_mars_step.cc new file mode 100644 index 000000000..8fd9f9dfa --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_step.cc @@ -0,0 +1,126 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_mars_step.h" + +grib_accessor_class_mars_step_t _grib_accessor_class_mars_step{ "mars_step" }; +grib_accessor_class* grib_accessor_class_mars_step = &_grib_accessor_class_mars_step; + + +void grib_accessor_class_mars_step_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_ascii_t::init(a, l, c); + int n = 0; + grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; + self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->stepType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_mars_step_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ + char stepType[100]; + size_t stepTypeLen = 100; + char buf[100] = {0,}; + int ret; + grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + + if (!stepRangeAcc) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s not found", self->stepRange); + return GRIB_NOT_FOUND; + } + + if ((ret = grib_get_string(grib_handle_of_accessor(a), self->stepType, stepType, &stepTypeLen)) != GRIB_SUCCESS) + return ret; + + if (!strcmp(stepType, "instant")) + snprintf(buf, sizeof(buf), "%s", val); + else + snprintf(buf, sizeof(buf), "0-%s", val); + + return stepRangeAcc->pack_string(buf, len); +} + +int grib_accessor_class_mars_step_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; + + int ret = 0; + char buf[100] = {0,}; + char* p = NULL; + size_t buflen = 100; + long step; + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + const char* cclass_name = a->cclass->name; + + if (!stepRangeAcc) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s: %s not found", cclass_name, self->stepRange); + return GRIB_NOT_FOUND; + } + + if ((ret = stepRangeAcc->unpack_string(buf, &buflen)) != GRIB_SUCCESS) + return ret; + + if (*len < buflen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, buflen, *len); + *len = buflen; + return GRIB_BUFFER_TOO_SMALL; + } + + strcpy(val, buf); + step = strtol(buf, &p, 10); + + if (p != NULL && *p == '-' && step == 0) + strcpy(val, ++p); + + *len = strlen(val); + + return ret; +} + +int grib_accessor_class_mars_step_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + char buff[100] = {0,}; + size_t bufflen = 100; + + snprintf(buff, sizeof(buff), "%ld", *val); + + return pack_string(a, buff, &bufflen); +} + +int grib_accessor_class_mars_step_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + + if (!stepRangeAcc) + return GRIB_NOT_FOUND; + + return stepRangeAcc->unpack_long(val, len); +} + +int grib_accessor_class_mars_step_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +size_t grib_accessor_class_mars_step_t::string_length(grib_accessor* a) +{ + return 16; +} + +int grib_accessor_class_mars_step_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_mars_step.h b/src/accessor/grib_accessor_class_mars_step.h new file mode 100644 index 000000000..8a49f56a6 --- /dev/null +++ b/src/accessor/grib_accessor_class_mars_step.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_mars_step_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in mars_step */ + const char* stepRange; + const char* stepType; +}; + +class grib_accessor_class_mars_step_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_mars_step_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_mars_step_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_md5.cc b/src/accessor/grib_accessor_class_md5.cc similarity index 50% rename from src/grib_accessor_class_md5.cc rename to src/accessor/grib_accessor_class_md5.cc index dfb08a7fb..40cbae672 100644 --- a/src/grib_accessor_class_md5.cc +++ b/src/accessor/grib_accessor_class_md5.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,108 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" +#include "grib_accessor_class_md5.h" #include "md5.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init - IMPLEMENTS = compare;unpack_string;value_count;destroy - MEMBERS = const char* offset - MEMBERS = grib_expression* length - MEMBERS = grib_string_list* blocklist - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_md5 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in md5 */ - const char* offset; - grib_expression* length; - grib_string_list* blocklist; -} grib_accessor_md5; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_md5 = { - &grib_accessor_class_gen, /* super */ - "md5", /* name */ - sizeof(grib_accessor_md5), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_md5_t _grib_accessor_class_md5{ "md5" }; grib_accessor_class* grib_accessor_class_md5 = &_grib_accessor_class_md5; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) +void grib_accessor_class_md5_t::init(grib_accessor* a, const long len, grib_arguments* arg) { - grib_accessor_md5* self = (grib_accessor_md5*)a; + grib_accessor_class_gen_t::init(a, len, arg); + grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; char* b = 0; int n = 0; grib_string_list* current = 0; @@ -138,12 +48,12 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_md5_t::get_native_type(grib_accessor* a) { return GRIB_TYPE_STRING; } -static int compare(grib_accessor* a, grib_accessor* b) +int grib_accessor_class_md5_t::compare(grib_accessor* a, grib_accessor* b) { int retval = GRIB_SUCCESS; @@ -152,12 +62,12 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); + err = b->value_count(&count); if (err) return err; blen = count; @@ -168,22 +78,22 @@ static int compare(grib_accessor* a, grib_accessor* b) return retval; } -static int unpack_string(grib_accessor* a, char* v, size_t* len) +int grib_accessor_class_md5_t::unpack_string(grib_accessor* a, char* v, size_t* len) { - grib_accessor_md5* self = (grib_accessor_md5*)a; + grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; unsigned mess_len; unsigned char* mess; unsigned char* p; long offset = 0, length = 0; grib_string_list* blocklist = NULL; int ret = GRIB_SUCCESS; - long i = 0; + long i = 0; struct grib_md5_state md5c; if (*len < 32) { const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + "%s: Buffer too small for %s. It is %d bytes long (len=%zu)", cclass_name, a->name, 32, *len); *len = 32; return GRIB_BUFFER_TOO_SMALL; @@ -226,9 +136,9 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len) return ret; } -static void destroy(grib_context* c, grib_accessor* a) +void grib_accessor_class_md5_t::destroy(grib_context* c, grib_accessor* a) { - grib_accessor_md5* self = (grib_accessor_md5*)a; + grib_accessor_md5_t* self = (grib_accessor_md5_t*)a; if (self->blocklist) { grib_string_list* next = self->blocklist; grib_string_list* cur = NULL; @@ -239,9 +149,10 @@ static void destroy(grib_context* c, grib_accessor* a) grib_context_free(c, cur); } } + grib_accessor_class_gen_t::destroy(c, a); } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_md5_t::value_count(grib_accessor* a, long* count) { *count = 1; /* ECC-1475 */ return 0; diff --git a/src/accessor/grib_accessor_class_md5.h b/src/accessor/grib_accessor_class_md5.h new file mode 100644 index 000000000..ae66f397f --- /dev/null +++ b/src/accessor/grib_accessor_class_md5.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_md5_t : public grib_accessor_gen_t +{ +public: + /* Members defined in md5 */ + const char* offset; + grib_expression* length; + grib_string_list* blocklist; +}; + +class grib_accessor_class_md5_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_md5_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_md5_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_message.cc b/src/accessor/grib_accessor_class_message.cc new file mode 100644 index 000000000..be704b1a1 --- /dev/null +++ b/src/accessor/grib_accessor_class_message.cc @@ -0,0 +1,75 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_message.h" + +grib_accessor_class_message_t _grib_accessor_class_message{"message"}; +grib_accessor_class* grib_accessor_class_message = &_grib_accessor_class_message; + + + +void grib_accessor_class_message_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bytes_t::init(a, len, arg); + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = grib_handle_of_accessor(a)->buffer->ulength - len - a->offset; +} + +// static int compare(grib_accessor* a, grib_accessor* b) +// { +// if (a->length != b->length) +// return GRIB_COUNT_MISMATCH; +// return GRIB_SUCCESS; +// } + +void grib_accessor_class_message_t::update_size(grib_accessor* a, size_t new_size){ + a->length = new_size; +} + +void grib_accessor_class_message_t::resize(grib_accessor* a, size_t new_size){ + grib_context_log(a->context, GRIB_LOG_FATAL, "%s %s: Not supported", a->cclass->name, __func__); + + // void* zero = grib_context_malloc_clear(a->context, new_size); + // grib_buffer_replace(a, (const unsigned char*)zero, new_size, 1, 0); + // grib_context_free(a->context, zero); + // grib_context_log(a->context, GRIB_LOG_DEBUG, "resize: grib_accessor_class_message %ld %ld %s %s", + // (long)new_size, (long)a->length, a->cclass->name, a->name); + // Assert(new_size == a->length); +} + +int grib_accessor_class_message_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +int grib_accessor_class_message_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + long i = 0; + size_t l = string_length(a) + 1; + grib_handle* h = grib_handle_of_accessor(a); + + if (*len < l) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + a->cclass->name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + + for (i = 0; i < a->length; i++) + val[i] = h->buffer->data[a->offset + i]; + val[i] = 0; + *len = i; + return GRIB_SUCCESS; +} + +size_t grib_accessor_class_message_t::string_length(grib_accessor* a){ + return a->length; +} diff --git a/src/accessor/grib_accessor_class_message.h b/src/accessor/grib_accessor_class_message.h new file mode 100644 index 000000000..2e29d6ebd --- /dev/null +++ b/src/accessor/grib_accessor_class_message.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_bytes.h" + +class grib_accessor_message_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in message */ +}; + +class grib_accessor_class_message_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_message_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_message_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + void resize(grib_accessor*,size_t) override; +}; diff --git a/src/accessor/grib_accessor_class_message_copy.cc b/src/accessor/grib_accessor_class_message_copy.cc new file mode 100644 index 000000000..7927b6c60 --- /dev/null +++ b/src/accessor/grib_accessor_class_message_copy.cc @@ -0,0 +1,59 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_message_copy.h" + +grib_accessor_class_message_copy_t _grib_accessor_class_message_copy{"message_copy"}; +grib_accessor_class* grib_accessor_class_message_copy = &_grib_accessor_class_message_copy; + + +void grib_accessor_class_message_copy_t::init(grib_accessor* a, const long length, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, length, args); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +void grib_accessor_class_message_copy_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_message_copy_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_message_copy_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + size_t slen = grib_handle_of_accessor(a)->buffer->ulength; + size_t i; + unsigned char* v = 0; + + if (*len < slen) { + return GRIB_ARRAY_TOO_SMALL; + } + v = grib_handle_of_accessor(a)->buffer->data; + /* replace unprintable characters with space */ + for (i = 0; i < slen; i++) + if (v[i] > 126) + v[i] = 32; + memcpy(val, grib_handle_of_accessor(a)->buffer->data, slen); + val[i] = 0; + + *len = slen; + + return GRIB_SUCCESS; +} + +size_t grib_accessor_class_message_copy_t::string_length(grib_accessor* a){ + return grib_handle_of_accessor(a)->buffer->ulength; +} + +long grib_accessor_class_message_copy_t::byte_count(grib_accessor* a){ + return a->length; +} diff --git a/src/accessor/grib_accessor_class_message_copy.h b/src/accessor/grib_accessor_class_message_copy.h new file mode 100644 index 000000000..608817a93 --- /dev/null +++ b/src/accessor/grib_accessor_class_message_copy.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_message_copy_t : public grib_accessor_gen_t +{ +public: + /* Members defined in message_copy */ +}; + +class grib_accessor_class_message_copy_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_message_copy_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_message_copy_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_multdouble.cc b/src/accessor/grib_accessor_class_multdouble.cc new file mode 100644 index 000000000..cbe5b42da --- /dev/null +++ b/src/accessor/grib_accessor_class_multdouble.cc @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_multdouble.h" + +grib_accessor_class_multdouble_t _grib_accessor_class_multdouble{"multdouble"}; +grib_accessor_class* grib_accessor_class_multdouble = &_grib_accessor_class_multdouble; + + +void grib_accessor_class_multdouble_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_multdouble_t* self = (grib_accessor_multdouble_t*)a; + int n = 0; + + self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->multiplier = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_multdouble_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + const grib_accessor_multdouble_t* self = (grib_accessor_multdouble_t*)a; + int ret = GRIB_SUCCESS; + double value = 0; + + ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value); + if (ret != GRIB_SUCCESS) + return ret; + + *val = value * self->multiplier; + + *len = 1; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_multdouble.h b/src/accessor/grib_accessor_class_multdouble.h new file mode 100644 index 000000000..025daf903 --- /dev/null +++ b/src/accessor/grib_accessor_class_multdouble.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_multdouble_t : public grib_accessor_double_t +{ +public: + /* Members defined in multdouble */ + const char* val; + double multiplier; +}; + +class grib_accessor_class_multdouble_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_multdouble_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_multdouble_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_nearest.cc b/src/accessor/grib_accessor_class_nearest.cc new file mode 100644 index 000000000..6dbac1722 --- /dev/null +++ b/src/accessor/grib_accessor_class_nearest.cc @@ -0,0 +1,49 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_nearest.h" + +grib_accessor_class_nearest_t _grib_accessor_class_nearest{"nearest"}; +grib_accessor_class* grib_accessor_class_nearest = &_grib_accessor_class_nearest; + + +void grib_accessor_class_nearest_t::init(grib_accessor* a, const long l, grib_arguments* args) +{ + grib_accessor_class_gen_t::init(a, l, args); + grib_accessor_nearest_t* self = (grib_accessor_nearest_t*)a; + self->args = args; +} + +void grib_accessor_class_nearest_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + /* TODO: pass args */ + grib_dump_label(dumper, a, NULL); +} + +grib_nearest* grib_nearest_new(const grib_handle* ch, int* error) +{ + grib_handle* h = (grib_handle*)ch; + grib_accessor* a = NULL; + grib_accessor_nearest_t* na = NULL; + grib_nearest* n = NULL; + *error = GRIB_NOT_IMPLEMENTED; + a = grib_find_accessor(h, "NEAREST"); + na = (grib_accessor_nearest_t*)a; + + if (!a) + return NULL; + + n = grib_nearest_factory(h, na->args, error); + + if (n) + *error = GRIB_SUCCESS; + + return n; +} diff --git a/src/accessor/grib_accessor_class_nearest.h b/src/accessor/grib_accessor_class_nearest.h new file mode 100644 index 000000000..3ac4fdae2 --- /dev/null +++ b/src/accessor/grib_accessor_class_nearest.h @@ -0,0 +1,31 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_nearest_t : public grib_accessor_gen_t +{ +public: + grib_arguments* args; +}; + + +class grib_accessor_class_nearest_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_nearest_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_nearest_t{}; } + void init(grib_accessor* a, const long l, grib_arguments* args) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; +}; + +//grib_nearest* grib_nearest_new(const grib_handle* ch, int* error); diff --git a/src/accessor/grib_accessor_class_non_alpha.cc b/src/accessor/grib_accessor_class_non_alpha.cc new file mode 100644 index 000000000..68aaffdd7 --- /dev/null +++ b/src/accessor/grib_accessor_class_non_alpha.cc @@ -0,0 +1,112 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_non_alpha.h" + +grib_accessor_class_non_alpha_t _grib_accessor_class_non_alpha{"non_alpha"}; +grib_accessor_class* grib_accessor_class_non_alpha = &_grib_accessor_class_non_alpha; + + +void grib_accessor_class_non_alpha_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; + size_t i = 0; + unsigned char* v; + + v = buffer->data + a->offset; + i = 0; + while ((*v < 33 || *v > 126) && i <= buffer->ulength) { + v++; + i++; + } + a->length = i; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_non_alpha_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +size_t grib_accessor_class_non_alpha_t::string_length(grib_accessor* a){ + return a->length; +} + +void grib_accessor_class_non_alpha_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_non_alpha_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_non_alpha_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_handle* hand = grib_handle_of_accessor(a); + long i = 0; + + if (*len < (a->length + 1)) { + grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", + *len, a->name, a->length + 1); + *len = a->length + 1; + return GRIB_BUFFER_TOO_SMALL; + } + + for (i = 0; i < a->length; i++) { + val[i] = hand->buffer->data[a->offset + i]; + } + val[i] = 0; + *len = i; + return GRIB_SUCCESS; +} + +int grib_accessor_class_non_alpha_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + size_t i = 0; + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + i = 0; + while (i < l - 1 && val[i] == ' ') + i++; + + if (val[i] == 0) { + *v = 0; + return 0; + } + if (val[i + 1] == ' ' && i < l - 2) + val[i + 1] = 0; + + *v = strtol(val, &last, 10); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_non_alpha_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + char val[1024]; + size_t l = sizeof(val); + char* last = NULL; + a->unpack_string(val, &l); + *v = strtod(val, &last); + + if (*last == 0) { + return GRIB_SUCCESS; + } + + return GRIB_NOT_IMPLEMENTED; +} + +long grib_accessor_class_non_alpha_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_non_alpha.h b/src/accessor/grib_accessor_class_non_alpha.h new file mode 100644 index 000000000..83b1ca9ba --- /dev/null +++ b/src/accessor/grib_accessor_class_non_alpha.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_non_alpha_t : public grib_accessor_gen_t +{ +public: + /* Members defined in non_alpha */ +}; + +class grib_accessor_class_non_alpha_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_non_alpha_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_non_alpha_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.cc b/src/accessor/grib_accessor_class_number_of_coded_values.cc new file mode 100644 index 000000000..f1023dd2e --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_coded_values.cc @@ -0,0 +1,66 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_number_of_coded_values.h" + +grib_accessor_class_number_of_coded_values_t _grib_accessor_class_number_of_coded_values{"number_of_coded_values"}; +grib_accessor_class* grib_accessor_class_number_of_coded_values = &_grib_accessor_class_number_of_coded_values; + + +void grib_accessor_class_number_of_coded_values_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + int n = 0; + grib_accessor_number_of_coded_values_t* self = (grib_accessor_number_of_coded_values_t*)a; + self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_number_of_coded_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int ret = GRIB_SUCCESS; + long bpv = 0; + long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; + + grib_accessor_number_of_coded_values_t* self = (grib_accessor_number_of_coded_values_t*)a; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) + return ret; + + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) + return ret; + + if (bpv != 0) { + grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_number_of_coded_values_t: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n", + offsetAfterData, offsetBeforeData, unusedBits, bpv); + DEBUG_ASSERT(offsetAfterData > offsetBeforeData); + *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv; + } + else { + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) + return ret; + + *val = numberOfValues; + } + + return ret; +} diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.h b/src/accessor/grib_accessor_class_number_of_coded_values.h new file mode 100644 index 000000000..6578e1dcf --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_coded_values.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_coded_values_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_coded_values */ + const char* numberOfValues; + const char* bitsPerValue; + const char* offsetBeforeData; + const char* offsetAfterData; + const char* unusedBits; +}; + +class grib_accessor_class_number_of_coded_values_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_coded_values_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_coded_values_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_number_of_points.cc b/src/accessor/grib_accessor_class_number_of_points.cc new file mode 100644 index 000000000..c1b63f2a2 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_points.cc @@ -0,0 +1,80 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_number_of_points.h" + +grib_accessor_class_number_of_points_t _grib_accessor_class_number_of_points{"number_of_points"}; +grib_accessor_class* grib_accessor_class_number_of_points = &_grib_accessor_class_number_of_points; + + +void grib_accessor_class_number_of_points_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_accessor_number_of_points_t* self = (grib_accessor_number_of_points_t*)a; + self->ni = grib_arguments_get_name(hand, c, n++); + self->nj = grib_arguments_get_name(hand, c, n++); + self->plpresent = grib_arguments_get_name(hand, c, n++); + self->pl = grib_arguments_get_name(hand, c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_number_of_points_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_number_of_points_t* self = (grib_accessor_number_of_points_t*)a; + + int ret = GRIB_SUCCESS; + long ni = 0, nj = 0, plpresent = 0; + size_t plsize = 0; + long* pl = NULL; + int i = 0; + grib_context* c = a->context; + grib_handle* hand = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(hand, self->ni, &ni)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(hand, self->nj, &nj)) != GRIB_SUCCESS) + return ret; + + if (self->plpresent && + ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS)) + return ret; + + if (grib_is_missing(hand, self->nj, &ret) && ret == GRIB_SUCCESS) { + grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 'missing'!", self->nj); + return GRIB_GEOCALCULUS_PROBLEM; + } + + if (nj == 0) { + grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 0!", self->nj); + return GRIB_GEOCALCULUS_PROBLEM; + } + + if (plpresent) { + /*reduced*/ + plsize = nj; + pl = (long*)grib_context_malloc(c, sizeof(long) * plsize); + grib_get_long_array_internal(hand, self->pl, pl, &plsize); + *val = 0; + for (i = 0; i < plsize; i++) + *val += pl[i]; + grib_context_free(c, pl); + } + else { + /*regular*/ + *val = ni * nj; + } + + return ret; +} diff --git a/src/accessor/grib_accessor_class_number_of_points.h b/src/accessor/grib_accessor_class_number_of_points.h new file mode 100644 index 000000000..f55d9bbeb --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_points.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_points_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_points */ + const char* ni; + const char* nj; + const char* plpresent; + const char* pl; +}; + +class grib_accessor_class_number_of_points_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_points_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_points_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_number_of_points_gaussian.cc b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc similarity index 62% rename from src/grib_accessor_class_number_of_points_gaussian.cc rename to src/accessor/grib_accessor_class_number_of_points_gaussian.cc index 5d952b937..39324fbd3 100644 --- a/src/grib_accessor_class_number_of_points_gaussian.cc +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,137 +9,31 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - ************************************/ - -#include "grib_api_internal.h" - - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* ni - MEMBERS = const char* nj - MEMBERS = const char* plpresent - MEMBERS = const char* pl - MEMBERS = const char* order - MEMBERS = const char* lat_first - MEMBERS = const char* lon_first - MEMBERS = const char* lat_last - MEMBERS = const char* lon_last - MEMBERS = const char* support_legacy - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_points_gaussian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in number_of_points_gaussian */ - const char* ni; - const char* nj; - const char* plpresent; - const char* pl; - const char* order; - const char* lat_first; - const char* lon_first; - const char* lat_last; - const char* lon_last; - const char* support_legacy; -} grib_accessor_number_of_points_gaussian; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_number_of_points_gaussian = { - &grib_accessor_class_long, /* super */ - "number_of_points_gaussian", /* name */ - sizeof(grib_accessor_number_of_points_gaussian), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_number_of_points_gaussian.h" +grib_accessor_class_number_of_points_gaussian_t _grib_accessor_class_number_of_points_gaussian{ "number_of_points_gaussian" }; grib_accessor_class* grib_accessor_class_number_of_points_gaussian = &_grib_accessor_class_number_of_points_gaussian; -/* END_CLASS_IMP */ #define EFDEBUG 0 -static void init(grib_accessor* a, const long l, grib_arguments* c) +void grib_accessor_class_number_of_points_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c) { - int n = 0; - grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a; - self->ni = grib_arguments_get_name(h, c, n++); - self->nj = grib_arguments_get_name(h, c, n++); - self->plpresent = grib_arguments_get_name(h, c, n++); - self->pl = grib_arguments_get_name(h, c, n++); - self->order = grib_arguments_get_name(h, c, n++); - self->lat_first = grib_arguments_get_name(h, c, n++); - self->lon_first = grib_arguments_get_name(h, c, n++); - self->lat_last = grib_arguments_get_name(h, c, n++); - self->lon_last = grib_arguments_get_name(h, c, n++); - self->support_legacy = grib_arguments_get_name(h, c, n++); + grib_accessor_class_long_t::init(a, l, c); + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; + + self->ni = grib_arguments_get_name(h, c, n++); + self->nj = grib_arguments_get_name(h, c, n++); + self->plpresent = grib_arguments_get_name(h, c, n++); + self->pl = grib_arguments_get_name(h, c, n++); + self->order = grib_arguments_get_name(h, c, n++); + self->lat_first = grib_arguments_get_name(h, c, n++); + self->lon_first = grib_arguments_get_name(h, c, n++); + self->lat_last = grib_arguments_get_name(h, c, n++); + self->lon_last = grib_arguments_get_name(h, c, n++); + self->support_legacy = grib_arguments_get_name(h, c, n++); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->length = 0; @@ -147,7 +42,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) // Old implementation of num_points_reduced_gauss_old // See src/deprecated/grib_accessor_class_number_of_points_gaussian.cc // - static int angleApproximatelyEqual(double A, double B, double angular_precision) { return angular_precision > 0 ? (fabs(A - B) <= angular_precision) : (A == B); @@ -218,15 +112,15 @@ static int get_number_of_data_values(grib_handle* h, size_t* numDataValues) return err; } -static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len); -static int unpack_long_new(grib_accessor* a, long* val, size_t* len); +int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len); +int unpack_long_new(grib_accessor* a, long* val, size_t* len); -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_number_of_points_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - int err = GRIB_SUCCESS; - long support_legacy = 1; - grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a; - grib_handle* h = grib_handle_of_accessor(a); + int err = GRIB_SUCCESS; + long support_legacy = 1; + grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; + grib_handle* h = grib_handle_of_accessor(a); if ((err = grib_get_long_internal(h, self->support_legacy, &support_legacy)) != GRIB_SUCCESS) return err; @@ -238,7 +132,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) } /* New algorithm */ -static int unpack_long_new(grib_accessor* a, long* val, size_t* len) +int unpack_long_new(grib_accessor* a, long* val, size_t* len) { int err = GRIB_SUCCESS; int is_global = 0; @@ -253,8 +147,8 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len) long angleSubdivisions = 0; grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a; - grib_context* c = a->context; + grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; + grib_context* c = a->context; if ((err = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS) return err; @@ -274,9 +168,9 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len) } if (plpresent) { - long max_pl = 0; - int j = 0; - double lon_first_row = 0, lon_last_row = 0; + long max_pl = 0; + int j = 0; + // double lon_first_row = 0, lon_last_row = 0; /*reduced*/ if ((err = grib_get_long_internal(h, self->order, &order)) != GRIB_SUCCESS) @@ -324,11 +218,9 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len) return GRIB_GEOCALCULUS_PROBLEM; } grib_get_reduced_row_wrapper(h, pl[j], lon_first, lon_last, &row_count, &ilon_first, &ilon_last); - lon_first_row = ((ilon_first)*360.0) / pl[j]; - lon_last_row = ((ilon_last)*360.0) / pl[j]; + // lon_first_row = ((ilon_first)*360.0) / pl[j]; + // lon_last_row = ((ilon_last)*360.0) / pl[j]; *val += row_count; - (void)lon_last_row; - (void)lon_first_row; } } else { @@ -349,7 +241,7 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len) } /* With Legacy support */ -static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len) +int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len) { int err = GRIB_SUCCESS; int is_global = 0; @@ -365,8 +257,8 @@ static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* grib_handle* h = grib_handle_of_accessor(a); size_t numDataValues = 0; - grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a; - grib_context* c = a->context; + grib_accessor_number_of_points_gaussian_t* self = (grib_accessor_number_of_points_gaussian_t*)a; + grib_context* c = a->context; if ((err = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS) return err; @@ -387,8 +279,8 @@ static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* if (plpresent) { long max_pl = 0; - int j = 0; - double lon_first_row = 0, lon_last_row = 0; + int j = 0; + // double lon_first_row = 0, lon_last_row = 0; /*reduced*/ if ((err = grib_get_long_internal(h, self->order, &order)) != GRIB_SUCCESS) @@ -449,14 +341,12 @@ static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* } grib_get_reduced_row_wrapper(h, pl[j], lon_first, lon_last, &row_count, &ilon_first, &ilon_last); -// if ( row_count != pl[j] ) { -// printf("oops...... rc=%ld but pl[%d]=%ld\n", row_count, j,pl[j]); -// } - lon_first_row = ((ilon_first)*360.0) / pl[j]; - lon_last_row = ((ilon_last)*360.0) / pl[j]; + // if ( row_count != pl[j] ) { + // printf("oops...... rc=%ld but pl[%d]=%ld\n", row_count, j,pl[j]); + // } + // lon_first_row = ((ilon_first)*360.0) / pl[j]; + // lon_last_row = ((ilon_last)*360.0) / pl[j]; *val += row_count; - (void)lon_last_row; - (void)lon_first_row; #if EFDEBUG printf(" ilon_first=%ld lon_first=%.10e ilon_last=%ld lon_last=%.10e count=%ld row_count=%ld\n", ilon_first, lon_first_row, ilon_last, lon_last_row, *val, row_count); diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.h b/src/accessor/grib_accessor_class_number_of_points_gaussian.h new file mode 100644 index 000000000..d00fb5b6e --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.h @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_points_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_points_gaussian */ + const char* ni; + const char* nj; + const char* plpresent; + const char* pl; + const char* order; + const char* lat_first; + const char* lon_first; + const char* lat_last; + const char* lon_last; + const char* support_legacy; +}; + +class grib_accessor_class_number_of_points_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_points_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_points_gaussian_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_number_of_values.cc b/src/accessor/grib_accessor_class_number_of_values.cc new file mode 100644 index 000000000..414cf5e05 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values.cc @@ -0,0 +1,67 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_number_of_values.h" + +grib_accessor_class_number_of_values_t _grib_accessor_class_number_of_values{"number_of_values"}; +grib_accessor_class* grib_accessor_class_number_of_values = &_grib_accessor_class_number_of_values; + + +void grib_accessor_class_number_of_values_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + int n = 0; + grib_accessor_number_of_values_t* self = (grib_accessor_number_of_values_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + + self->values = grib_arguments_get_name(hand, c, n++); + self->bitsPerValue = grib_arguments_get_name(hand, c, n++); + self->numberOfPoints = grib_arguments_get_name(hand, c, n++); + self->bitmapPresent = grib_arguments_get_name(hand, c, n++); + self->bitmap = grib_arguments_get_name(hand, c, n++); + self->numberOfCodedValues = grib_arguments_get_name(hand, c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + + a->length = 0; +} + +int grib_accessor_class_number_of_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_number_of_values_t* self = (grib_accessor_number_of_values_t*)a; + int ret = GRIB_SUCCESS, i; + long npoints = 0, bitmap_present = 0; + size_t size = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &npoints)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitmapPresent, &bitmap_present)) != GRIB_SUCCESS) + return ret; + + if (bitmap_present) { + double* bitmap; + size = npoints; + bitmap = (double*)grib_context_malloc(a->context, sizeof(double) * size); + if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->bitmap, bitmap, &size)) != GRIB_SUCCESS) { + grib_context_free(a->context, bitmap); + return ret; + } + *val = 0; + for (i = 0; i < size; i++) + if (bitmap[i] != 0) + (*val)++; + + grib_context_free(a->context, bitmap); + } + else { + *val = npoints; + } + + return ret; +} diff --git a/src/accessor/grib_accessor_class_number_of_values.h b/src/accessor/grib_accessor_class_number_of_values.h new file mode 100644 index 000000000..895669f34 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_number_of_values_t : public grib_accessor_long_t +{ +public: + /* Members defined in number_of_values */ + const char* values; + const char* bitsPerValue; + const char* numberOfPoints; + const char* bitmapPresent; + const char* bitmap; + const char* numberOfCodedValues; +}; + +class grib_accessor_class_number_of_values_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_number_of_values_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_values_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc new file mode 100644 index 000000000..b8f1d667b --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc @@ -0,0 +1,63 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_number_of_values_data_raw_packing.h" + +grib_accessor_class_number_of_values_data_raw_packing_t _grib_accessor_class_number_of_values_data_raw_packing{"number_of_values_data_raw_packing"}; +grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing = &_grib_accessor_class_number_of_values_data_raw_packing; + + +void grib_accessor_class_number_of_values_data_raw_packing_t::init(grib_accessor* a, const long v, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, v, args); + int n = 0; + grib_accessor_number_of_values_data_raw_packing_t* self = (grib_accessor_number_of_values_data_raw_packing_t*)a; + + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_number_of_values_data_raw_packing_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + int err = 0; + grib_accessor_number_of_values_data_raw_packing_t* self = (grib_accessor_number_of_values_data_raw_packing_t*)a; + grib_accessor* adata = NULL; + long precision = 0; + int bytes = 0; + long byte_count = 0; + + adata = grib_find_accessor(grib_handle_of_accessor(a), self->values); + Assert(adata != NULL); + byte_count = adata->byte_count(); + if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) + return err; + + switch (precision) { + case 1: + bytes = 4; + break; + + case 2: + bytes = 8; + break; + + default: + return GRIB_NOT_IMPLEMENTED; + } + + *val = byte_count / bytes; + + return err; +} + +int grib_accessor_class_number_of_values_data_raw_packing_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h new file mode 100644 index 000000000..798f428f5 --- /dev/null +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_number_of_values_data_raw_packing_t : public grib_accessor_gen_t +{ +public: + /* Members defined in number_of_values_data_raw_packing */ + const char* values; + const char* precision; +}; + +class grib_accessor_class_number_of_values_data_raw_packing_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_number_of_values_data_raw_packing_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_number_of_values_data_raw_packing_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/grib_accessor_class_octahedral_gaussian.cc new file mode 100644 index 000000000..8c556e84a --- /dev/null +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.cc @@ -0,0 +1,120 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_octahedral_gaussian.h" + +grib_accessor_class_octahedral_gaussian_t _grib_accessor_class_octahedral_gaussian{"octahedral_gaussian"}; +grib_accessor_class* grib_accessor_class_octahedral_gaussian = &_grib_accessor_class_octahedral_gaussian; + + +void grib_accessor_class_octahedral_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_octahedral_gaussian_t* self = (grib_accessor_octahedral_gaussian_t*)a; + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + self->N = grib_arguments_get_name(hand, c, n++); + self->Ni = grib_arguments_get_name(hand, c, n++); + self->plpresent = grib_arguments_get_name(hand, c, n++); + self->pl = grib_arguments_get_name(hand, c, n++); +} + +/* Returns 1 (=true) if input pl array is Octahedral, 0 otherwise. + * Possible cases for the deltas in an octahedral pl array: + * +4 .. +4 Top part, above equator + * +4 .. 0 Top part, above and including equator + * +4.. 0 -4.. Middle part, above, equator and below + * 0 -4.. Equator and below + * -4 ..-4 All below equator + * Anything else is considered not octahedral + */ +static int is_pl_octahedral(const long pl[], size_t size){ + long i; + long prev_diff = -1; + for (i = 1; i < size; ++i) { + const long diff = pl[i] - pl[i - 1]; + if (diff == 0) { + /* prev must be +4 or undef */ + if (!(prev_diff == +4 || i == 1)) { + return 0; + } + } + else { + if (labs(diff) != 4) { + return 0; + } + if (diff == +4) { + /* prev must be +4 or undef */ + if (!(prev_diff == +4 || i == 1)) { + return 0; + } + } + if (diff == -4) { + /* prev must be 0, -4 or undef */ + if (!(prev_diff == -4 || prev_diff == 0 || i == 1)) { + return 0; + } + } + } + prev_diff = diff; + } + return 1; /* it's octahedral */ +} + +int grib_accessor_class_octahedral_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_octahedral_gaussian_t* self = (grib_accessor_octahedral_gaussian_t*)a; + int ret = GRIB_SUCCESS; + long Ni; + long plpresent = 0; + long* pl = NULL; /* pl array */ + size_t plsize = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_context* c = a->context; + + if ((ret = grib_get_long_internal(hand, self->Ni, &Ni)) != GRIB_SUCCESS) + return ret; + + /* If Ni is not missing, then this is a plain gaussian grid and not reduced. */ + /* So it cannot be an octahedral grid */ + if (Ni != GRIB_MISSING_LONG) { + *val = 0; + return GRIB_SUCCESS; + } + + if ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS) + return ret; + if (!plpresent) { + *val = 0; /* Not octahedral */ + return GRIB_SUCCESS; + } + + if ((ret = grib_get_size(hand, self->pl, &plsize)) != GRIB_SUCCESS) + return ret; + Assert(plsize); /* pl array must have at least one element */ + + pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize); + if (!pl) { + return GRIB_OUT_OF_MEMORY; + } + if ((ret = grib_get_long_array_internal(hand, self->pl, pl, &plsize)) != GRIB_SUCCESS) + return ret; + + /* pl[0] is guaranteed to exist. Have already asserted previously */ + *val = is_pl_octahedral(pl, plsize); + grib_context_free(c, pl); + + return ret; +} + +int grib_accessor_class_octahedral_gaussian_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.h b/src/accessor/grib_accessor_class_octahedral_gaussian.h new file mode 100644 index 000000000..cc7f52a25 --- /dev/null +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_octahedral_gaussian_t : public grib_accessor_long_t +{ +public: + /* Members defined in octahedral_gaussian */ + const char* N; + const char* Ni; + const char* plpresent; + const char* pl; +}; + +class grib_accessor_class_octahedral_gaussian_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_octahedral_gaussian_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_octahedral_gaussian_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_octet_number.cc b/src/accessor/grib_accessor_class_octet_number.cc new file mode 100644 index 000000000..4b270f257 --- /dev/null +++ b/src/accessor/grib_accessor_class_octet_number.cc @@ -0,0 +1,47 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_octet_number.h" + +grib_accessor_class_octet_number_t _grib_accessor_class_octet_number{"octet_number"}; +grib_accessor_class* grib_accessor_class_octet_number = &_grib_accessor_class_octet_number; + + +void grib_accessor_class_octet_number_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_octet_number_t* self = (grib_accessor_octet_number_t*)a; + + int n = 0; + self->left = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->right = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + + a->length = 0; +} + +int grib_accessor_class_octet_number_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_octet_number_t* self = (grib_accessor_octet_number_t*)a; + int ret = GRIB_SUCCESS; + long offset; + + offset = a->offset + self->right; + + if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->left, offset)) != GRIB_SUCCESS) + return ret; + + *val = offset; + *len = 1; + + return ret; +} + +int grib_accessor_class_octet_number_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_octet_number.h b/src/accessor/grib_accessor_class_octet_number.h new file mode 100644 index 000000000..691dcb564 --- /dev/null +++ b/src/accessor/grib_accessor_class_octet_number.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_octet_number_t : public grib_accessor_long_t +{ +public: + /* Members defined in octet_number */ + const char* left; + long right; +}; + +class grib_accessor_class_octet_number_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_octet_number_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_octet_number_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_offset_file.cc b/src/accessor/grib_accessor_class_offset_file.cc new file mode 100644 index 000000000..b52e8eb41 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_file.cc @@ -0,0 +1,55 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_offset_file.h" + +grib_accessor_class_offset_file_t _grib_accessor_class_offset_file{"offset_file"}; +grib_accessor_class* grib_accessor_class_offset_file = &_grib_accessor_class_offset_file; + + +void grib_accessor_class_offset_file_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_offset_file_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + *val = (double)grib_handle_of_accessor(a)->offset; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_offset_file_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + double val = 0; + size_t l = 1; + char repres[1024] = {0,}; + int err = 0; + const char* cclass_name = a->cclass->name; + + err = a->unpack_double(&val, &l); if (err) return err; + + snprintf(repres, sizeof(repres), "%.0f", val); + + l = strlen(repres) + 1; + if (l > *len) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, l, *len); + *len = l; + return GRIB_BUFFER_TOO_SMALL; + } + grib_context_log(a->context, GRIB_LOG_DEBUG, "%s: Casting double %s to string", __func__, a->name); + + *len = l; + + strcpy(v, repres); + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_offset_file.h b/src/accessor/grib_accessor_class_offset_file.h new file mode 100644 index 000000000..6cb25b864 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_file.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_offset_file_t : public grib_accessor_double_t +{ +public: + /* Members defined in offset_file */ +}; + +class grib_accessor_class_offset_file_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_offset_file_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_offset_file_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_offset_values.cc b/src/accessor/grib_accessor_class_offset_values.cc new file mode 100644 index 000000000..26f78b5c3 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_values.cc @@ -0,0 +1,83 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_offset_values.h" + +grib_accessor_class_offset_values_t _grib_accessor_class_offset_values{"offset_values"}; +grib_accessor_class* grib_accessor_class_offset_values = &_grib_accessor_class_offset_values; + + +void grib_accessor_class_offset_values_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_double_t::init(a, l, args); + int n = 0; + grib_accessor_offset_values_t* self = (grib_accessor_offset_values_t*)a; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_offset_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + int ret = 0; + *val = 0; + *len = 1; + return ret; +} + +int grib_accessor_class_offset_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + double* values = NULL; + size_t size = 0; + double missingValue = 0; + long missingValuesPresent = 0; + int ret = 0, i = 0; + grib_accessor_offset_values_t* self = (grib_accessor_offset_values_t*)a; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (*val == 0) + return GRIB_SUCCESS; + + if ((ret = grib_get_double_internal(h, self->missingValue, &missingValue)) != GRIB_SUCCESS) { + return ret; + } + if ((ret = grib_get_long_internal(h, "missingValuesPresent", &missingValuesPresent)) != GRIB_SUCCESS) { + return ret; + } + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + for (i = 0; i < size; i++) { + if (missingValuesPresent) { + if (values[i] != missingValue) + values[i] += *val; + } + else { + values[i] += *val; + } + } + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) + return ret; + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_offset_values.h b/src/accessor/grib_accessor_class_offset_values.h new file mode 100644 index 000000000..702e48da7 --- /dev/null +++ b/src/accessor/grib_accessor_class_offset_values.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_offset_values_t : public grib_accessor_double_t +{ +public: + /* Members defined in offset_values */ + const char* values; + const char* missingValue; +}; + +class grib_accessor_class_offset_values_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_offset_values_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_offset_values_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_optimal_step_units.cc b/src/accessor/grib_accessor_class_optimal_step_units.cc new file mode 100644 index 000000000..adc89e743 --- /dev/null +++ b/src/accessor/grib_accessor_class_optimal_step_units.cc @@ -0,0 +1,216 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_optimal_step_units.h" +#include "step.h" +#include "step_utilities.h" + +grib_accessor_class_optimal_step_units_t _grib_accessor_class_optimal_step_units{"optimal_step_units"}; +grib_accessor_class* grib_accessor_class_optimal_step_units = &_grib_accessor_class_optimal_step_units; + + +void grib_accessor_class_optimal_step_units_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_gen_t::init(a, l, c); + grib_accessor_optimal_step_units_t* self = (grib_accessor_optimal_step_units_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->forecast_time_value = grib_arguments_get_name(hand, c, n++); + self->forecast_time_unit = grib_arguments_get_name(hand, c, n++); + self->time_range_value = grib_arguments_get_name(hand, c, n++); + self->time_range_unit = grib_arguments_get_name(hand, c, n++); + a->length = 0; + self->overwriteStepUnits = eccodes::Unit{eccodes::Unit::Value::MISSING}.value(); +} + +void grib_accessor_class_optimal_step_units_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +size_t grib_accessor_class_optimal_step_units_t::string_length(grib_accessor* a){ + return 255; +} + +int grib_accessor_class_optimal_step_units_t::pack_expression(grib_accessor* a, grib_expression* e){ + const char* cval = NULL; + int ret = 0; + long lval = 0; + size_t len = 1; + grib_handle* hand = grib_handle_of_accessor(a); + const char* cclass_name = a->cclass->name; + + if (strcmp(e->cclass->name, "long") == 0) { + grib_expression_evaluate_long(hand, e, &lval); /* TODO: check return value */ + ret = a->pack_long(&lval, &len); } + else { + char tmp[1024]; + len = sizeof(tmp); + cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); + if (ret != GRIB_SUCCESS) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s.%s: Unable to evaluate string %s to be set in %s", + cclass_name, __func__, grib_expression_get_name(e), a->name); + return ret; + } + len = strlen(cval) + 1; + //if (hand->context->debug) + // printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %s\n", a->name, cval); + ret = a->pack_string(cval, &len); } + return ret; +} + +int grib_accessor_class_optimal_step_units_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_optimal_step_units_t* self = (grib_accessor_optimal_step_units_t*)a; + + long start_step = 0; + long start_step_unit = 0; + long end_step = 0; + long end_step_unit = 0; + int ret; + + auto supported_units = eccodes::Unit::list_supported_units(); + try { + eccodes::Unit unit{*val}; // throws if not supported + auto iter = std::find(supported_units.begin(), supported_units.end(), unit); + if (iter == supported_units.end()) { + throw std::runtime_error{"eccodes::Unit not supported"}; + } + } + catch (std::exception& e) { + std::string supported_units_str; + for (auto& u : supported_units) + supported_units_str += eccodes::Unit{u}.value() + ","; + supported_units_str.pop_back(); + + std::string msg = std::string{"Invalid unit: "} + std::to_string(*val) + " (" + e.what() + ")" + + ". Available units are: " + supported_units_str; + grib_context_log(a->context, GRIB_LOG_ERROR, "%s", msg.c_str()); + return GRIB_INVALID_ARGUMENT; + } + + // ECC-1813: When the stepUnits key is used without specifying a value, as in the command + // "grib-set -s stepUnits=m in.grib out.grib", the following code initiates an indirect update + // of the low-level keys: forecastTime,indicatorOfUnitOfTimeRange,indicatorOfUnitForTimeRange,lengthOfTimeRange + + self->overwriteStepUnits = *val; + if ((ret = grib_set_long_internal(h, "forceStepUnits", *val)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(h, "startStep", &start_step)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, "startStepUnit", &start_step_unit)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, "endStep", &end_step)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, "endStepUnit", &end_step_unit)) != GRIB_SUCCESS) + return ret; + + try { + eccodes::Step start{start_step, start_step_unit}; + start.set_unit(*val); + eccodes::Step end{end_step, end_step_unit}; + end.set_unit(*val); + + if ((ret = grib_set_long_internal(h, "startStepUnit", start.unit().value())) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(h, "startStep", start.value())) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(h, "endStepUnit", end.unit().value())) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(h, "endStep", end.value())) != GRIB_SUCCESS) + return ret; + } + catch (std::exception& e) { + std::string msg = std::string{"Failed to convert steps to: "} + std::to_string(*val) + " (" + e.what() + ")"; + grib_context_log(a->context, GRIB_LOG_ERROR, "%s", msg.c_str()); + return GRIB_INTERNAL_ERROR; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_optimal_step_units_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + const grib_accessor_optimal_step_units_t* self = (grib_accessor_optimal_step_units_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + try { + if (eccodes::Unit{self->overwriteStepUnits} != eccodes::Unit{eccodes::Unit::Value::MISSING}) { + *val = self->overwriteStepUnits; + return GRIB_SUCCESS; + } + + auto forecast_time_opt = get_step(h, self->forecast_time_value, self->forecast_time_unit); + auto time_range_opt = get_step(h, self->time_range_value, self->time_range_unit); + + if (forecast_time_opt && time_range_opt) { + auto [step_a, step_b] = find_common_units(forecast_time_opt.value().optimize_unit(), + (forecast_time_opt.value() + time_range_opt.value()).optimize_unit()); + *val = step_a.unit().value(); + } + else if (forecast_time_opt && !time_range_opt) { + *val = forecast_time_opt.value().optimize_unit().unit().value(); + } + else if (!forecast_time_opt && time_range_opt) { + *val = time_range_opt.value().optimize_unit().unit().value(); + } + else if (!forecast_time_opt && !time_range_opt) { + *val = eccodes::Unit{eccodes::Unit::Value::HOUR}.value(); + } + } + catch (std::exception& e) { + grib_context_log(a->context, GRIB_LOG_ERROR, "%s", e.what()); + return GRIB_INTERNAL_ERROR; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_optimal_step_units_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + try { + long unit = eccodes::Unit{val}.value(); + pack_long(a, &unit, len); + } + catch (std::exception& e) { + auto supported_units = eccodes::Unit::list_supported_units(); + std::string supported_units_str; + for (auto& u : supported_units) + supported_units_str += eccodes::Unit{u}.value() + ","; + supported_units_str.pop_back(); + + std::string msg = "Invalid unit: " + std::string(val) + " (" + e.what() + ")" + ". Available units are: " + supported_units_str; + grib_context_log(a->context, GRIB_LOG_ERROR, "%s", msg.c_str()); + return GRIB_INVALID_ARGUMENT; + } + + return GRIB_SUCCESS; +} + +int grib_accessor_class_optimal_step_units_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + int ret = 0; + long unit = 0; + size_t unit_len = 0; + if ((ret = unpack_long(a, &unit, &unit_len)) != GRIB_SUCCESS) + return ret; + *len = snprintf(val, *len, "%s", eccodes::Unit{unit}.value().c_str()); + return GRIB_SUCCESS; +} + +// Step units are never missing +// If the user does not specify a step unit, we default to hours +int grib_accessor_class_optimal_step_units_t::is_missing(grib_accessor* a){ + return 0; +} + +int grib_accessor_class_optimal_step_units_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_optimal_step_units.h b/src/accessor/grib_accessor_class_optimal_step_units.h new file mode 100644 index 000000000..e7aa35247 --- /dev/null +++ b/src/accessor/grib_accessor_class_optimal_step_units.h @@ -0,0 +1,42 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_optimal_step_units_t : public grib_accessor_gen_t +{ +public: + /* Members defined in optimal_step_units */ + const char* forecast_time_value; + const char* forecast_time_unit; + const char* time_range_value; + const char* time_range_unit; + long overwriteStepUnits; +}; + +class grib_accessor_class_optimal_step_units_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_optimal_step_units_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_optimal_step_units_t{}; } + int get_native_type(grib_accessor*) override; + int is_missing(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int pack_expression(grib_accessor*, grib_expression*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.cc b/src/accessor/grib_accessor_class_pack_bufr_values.cc new file mode 100644 index 000000000..08b80d607 --- /dev/null +++ b/src/accessor/grib_accessor_class_pack_bufr_values.cc @@ -0,0 +1,70 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_pack_bufr_values.h" + +grib_accessor_class_pack_bufr_values_t _grib_accessor_class_pack_bufr_values{"pack_bufr_values"}; +grib_accessor_class* grib_accessor_class_pack_bufr_values = &_grib_accessor_class_pack_bufr_values; + + +void grib_accessor_class_pack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); + char* key; + grib_accessor_pack_bufr_values_t* self = (grib_accessor_pack_bufr_values_t*)a; + key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); + self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); + + a->length = 0; +} + +void grib_accessor_class_pack_bufr_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +} + +int grib_accessor_class_pack_bufr_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_pack_bufr_values_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_pack_bufr_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_pack_bufr_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_pack_bufr_values_t::value_count(grib_accessor* a, long* count){ + *count = 1; + return 0; +} + +void grib_accessor_class_pack_bufr_values_t::destroy(grib_context* context, grib_accessor* a){ + grib_accessor_class_gen_t::destroy(context, a); +} + +int grib_accessor_class_pack_bufr_values_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_pack_bufr_values_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_pack_bufr_values_t* self = (grib_accessor_pack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->pack_double(0, 0);} + +int grib_accessor_class_pack_bufr_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_pack_bufr_values_t* self = (grib_accessor_pack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->pack_double(0, 0);} diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.h b/src/accessor/grib_accessor_class_pack_bufr_values.h new file mode 100644 index 000000000..0a59a5141 --- /dev/null +++ b/src/accessor/grib_accessor_class_pack_bufr_values.h @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_pack_bufr_values_t : public grib_accessor_gen_t +{ +public: + /* Members defined in pack_bufr_values */ + grib_accessor* data_accessor; +}; + +class grib_accessor_class_pack_bufr_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_pack_bufr_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_pack_bufr_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_packing_type.cc b/src/accessor/grib_accessor_class_packing_type.cc new file mode 100644 index 000000000..5dd862a07 --- /dev/null +++ b/src/accessor/grib_accessor_class_packing_type.cc @@ -0,0 +1,74 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_packing_type.h" + +grib_accessor_class_packing_type_t _grib_accessor_class_packing_type{"packing_type"}; +grib_accessor_class* grib_accessor_class_packing_type = &_grib_accessor_class_packing_type; + + +void grib_accessor_class_packing_type_t::init(grib_accessor* a, const long l, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, l, args); + int n = 0; + grib_accessor_packing_type_t* self = (grib_accessor_packing_type_t*)a; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->packing_type = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +size_t grib_accessor_class_packing_type_t::string_length(grib_accessor* a){ + return 1024; +} + +int grib_accessor_class_packing_type_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_packing_type_t::pack_string(grib_accessor*a, const char* sval, size_t* len){ + grib_accessor_packing_type_t* self = (grib_accessor_packing_type_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + double* values = NULL; + grib_context* c = a->context; + size_t size = 0; + int err = 0; + + if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return err; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) return GRIB_OUT_OF_MEMORY; + + if ((err = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + if ((err = grib_set_string_internal(h, self->packing_type, sval, len)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + if ((err = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return err; + } + + grib_context_free(c, values); + return GRIB_SUCCESS; +} + +int grib_accessor_class_packing_type_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_packing_type_t* self = (grib_accessor_packing_type_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + return grib_get_string(h, self->packing_type, val, len); +} diff --git a/src/accessor/grib_accessor_class_packing_type.h b/src/accessor/grib_accessor_class_packing_type.h new file mode 100644 index 000000000..7deb8f4cf --- /dev/null +++ b/src/accessor/grib_accessor_class_packing_type.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_packing_type_t : public grib_accessor_gen_t +{ +public: + /* Members defined in packing_type */ + const char* values; + const char* packing_type; +}; + +class grib_accessor_class_packing_type_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_packing_type_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_packing_type_t{}; } + int get_native_type(grib_accessor*) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_pad.cc b/src/accessor/grib_accessor_class_pad.cc new file mode 100644 index 000000000..345b510fb --- /dev/null +++ b/src/accessor/grib_accessor_class_pad.cc @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_pad.h" + +grib_accessor_class_pad_t _grib_accessor_class_pad{"pad"}; +grib_accessor_class* grib_accessor_class_pad = &_grib_accessor_class_pad; + + + +size_t grib_accessor_class_pad_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_pad_t* self = (grib_accessor_pad_t*)a; + + long length = 0; + + grib_expression_evaluate_long(grib_handle_of_accessor(a), self->expression, &length); + + return length > 0 ? length : 0; +} + + +void grib_accessor_class_pad_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_padding_t::init(a, len, arg); + grib_accessor_pad_t* self = (grib_accessor_pad_t*)a; + + self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); + a->length = preferred_size(a, 1); +} diff --git a/src/accessor/grib_accessor_class_pad.h b/src/accessor/grib_accessor_class_pad.h new file mode 100644 index 000000000..5234e73a5 --- /dev/null +++ b/src/accessor/grib_accessor_class_pad.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_padding.h" + +class grib_accessor_pad_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padding */ + /* Members defined in pad */ + grib_expression* expression; +}; + +class grib_accessor_class_pad_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_pad_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_pad_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; diff --git a/src/accessor/grib_accessor_class_padding.cc b/src/accessor/grib_accessor_class_padding.cc new file mode 100644 index 000000000..499c77f2b --- /dev/null +++ b/src/accessor/grib_accessor_class_padding.cc @@ -0,0 +1,58 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_padding.h" + +grib_accessor_class_padding_t _grib_accessor_class_padding{"padding"}; +grib_accessor_class* grib_accessor_class_padding = &_grib_accessor_class_padding; + + +void grib_accessor_class_padding_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_bytes_t::init(a, len, arg); + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_padding_t::compare(grib_accessor* a, grib_accessor* b){ + if (a->length != b->length) + return GRIB_COUNT_MISMATCH; + return GRIB_SUCCESS; +} + +void grib_accessor_class_padding_t::update_size(grib_accessor* a, size_t new_size){ + a->length = new_size; +} + +void grib_accessor_class_padding_t::resize(grib_accessor* a, size_t new_size){ + void* zero = grib_context_malloc_clear(a->context, new_size); + + grib_buffer_replace(a, (const unsigned char*)zero, new_size, + /*update_lengths=*/1, /*update_paddings=*/0); + grib_context_free(a->context, zero); + + grib_context_log(a->context, GRIB_LOG_DEBUG, + "grib_accessor_class_padding::resize new_size=%zu a->length=%ld %s %s", + new_size, a->length, a->cclass->name, a->name); + Assert(new_size == a->length); +} + +int grib_accessor_class_padding_t::value_count(grib_accessor* a, long* c){ + *c = a->length; + return 0; +} + +long grib_accessor_class_padding_t::byte_count(grib_accessor* a){ + return a->length; +} + +size_t grib_accessor_class_padding_t::string_length(grib_accessor* a){ + return (size_t)a->length; +} diff --git a/src/accessor/grib_accessor_class_padding.h b/src/accessor/grib_accessor_class_padding.h new file mode 100644 index 000000000..6d4175de3 --- /dev/null +++ b/src/accessor/grib_accessor_class_padding.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_bytes.h" + +class grib_accessor_padding_t : public grib_accessor_bytes_t +{ +public: + /* Members defined in padding */ +}; + +class grib_accessor_class_padding_t : public grib_accessor_class_bytes_t +{ +public: + grib_accessor_class_padding_t(const char* name) : grib_accessor_class_bytes_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padding_t{}; } + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + void resize(grib_accessor*,size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_padto.cc b/src/accessor/grib_accessor_class_padto.cc new file mode 100644 index 000000000..110d8d858 --- /dev/null +++ b/src/accessor/grib_accessor_class_padto.cc @@ -0,0 +1,45 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_padto.h" + +grib_accessor_class_padto_t _grib_accessor_class_padto{"padto"}; +grib_accessor_class* grib_accessor_class_padto = &_grib_accessor_class_padto; + + + +size_t grib_accessor_class_padto_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_padto_t* self = (grib_accessor_padto_t*)a; + + long length = 0; + long theEnd; + + grib_expression_evaluate_long(grib_handle_of_accessor(a), self->expression, &theEnd); + + length = theEnd - a->offset; + + /* printf("preferred_size: prefered: %ld current:%ld %s %s %ld\n", (long)length,(long)a->length,a->cclass->name,a->name,(long)a->offset); */ + + return length > 0 ? length : 0; +} + + +void grib_accessor_class_padto_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_padding_t::init(a, len, arg); + grib_accessor_padto_t* self = (grib_accessor_padto_t*)a; + + self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); + a->length = preferred_size(a, 1); +} + +void grib_accessor_class_padto_t::dump(grib_accessor* a, grib_dumper* dumper){ + /*grib_dump_string(dumper,a,NULL);*/ +} diff --git a/src/accessor/grib_accessor_class_padto.h b/src/accessor/grib_accessor_class_padto.h new file mode 100644 index 000000000..a1b7b398a --- /dev/null +++ b/src/accessor/grib_accessor_class_padto.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_padding.h" + +class grib_accessor_padto_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padto */ + grib_expression* expression; +}; + +class grib_accessor_class_padto_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padto_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padto_t{}; } + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; diff --git a/src/accessor/grib_accessor_class_padtoeven.cc b/src/accessor/grib_accessor_class_padtoeven.cc new file mode 100644 index 000000000..adf8b0d84 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtoeven.cc @@ -0,0 +1,48 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_padtoeven.h" + +grib_accessor_class_padtoeven_t _grib_accessor_class_padtoeven{"padtoeven"}; +grib_accessor_class* grib_accessor_class_padtoeven = &_grib_accessor_class_padtoeven; + + +size_t grib_accessor_class_padtoeven_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_padtoeven_t* self = (grib_accessor_padtoeven_t*)a; + long offset = 0; + long length = 0; + long seclen; + + grib_get_long_internal(grib_handle_of_accessor(a), self->section_offset, &offset); + grib_get_long_internal(grib_handle_of_accessor(a), self->section_length, &length); + + if ((length % 2) && from_handle) { + // grib_context_log(a->context, + // GRIB_LOG_ERROR,"GRIB message has an odd length section (%ld, %s)", + // (long)length,a->name); + return 0; + } + + /* printf("EVEN %ld %ld\n",(long) a->offset,(long) offset);*/ + seclen = a->offset - offset; + + return (seclen % 2) ? 1 : 0; +} + +void grib_accessor_class_padtoeven_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_padding_t::init(a, len, args); + grib_accessor_padtoeven_t* self = (grib_accessor_padtoeven_t*)a; + + self->section_offset = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); + self->section_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); + + a->length = preferred_size(a, 1); +} diff --git a/src/accessor/grib_accessor_class_padtoeven.h b/src/accessor/grib_accessor_class_padtoeven.h new file mode 100644 index 000000000..9f42f5880 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtoeven.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_padding.h" + +class grib_accessor_padtoeven_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padtoeven */ + const char* section_offset; + const char* section_length; +}; + +class grib_accessor_class_padtoeven_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padtoeven_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padtoeven_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; diff --git a/src/accessor/grib_accessor_class_padtomultiple.cc b/src/accessor/grib_accessor_class_padtomultiple.cc new file mode 100644 index 000000000..d4e463578 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtomultiple.cc @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_padtomultiple.h" + +grib_accessor_class_padtomultiple_t _grib_accessor_class_padtomultiple{"padtomultiple"}; +grib_accessor_class* grib_accessor_class_padtomultiple = &_grib_accessor_class_padtomultiple; + + +size_t grib_accessor_class_padtomultiple_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_padtomultiple_t* self = (grib_accessor_padtomultiple_t*)a; + long padding = 0; + long begin = 0; + long multiple = 0; + + grib_expression_evaluate_long(grib_handle_of_accessor(a), self->begin, &begin); + grib_expression_evaluate_long(grib_handle_of_accessor(a), self->multiple, &multiple); + + padding = a->offset - begin; + padding = ((padding + multiple - 1) / multiple) * multiple - padding; + + return padding == 0 ? multiple : padding; +} + +void grib_accessor_class_padtomultiple_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_padding_t::init(a, len, arg); + grib_accessor_padtomultiple_t* self = (grib_accessor_padtomultiple_t*)a; + + self->begin = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); + self->multiple = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 1); + a->length = preferred_size(a, 1); +} diff --git a/src/accessor/grib_accessor_class_padtomultiple.h b/src/accessor/grib_accessor_class_padtomultiple.h new file mode 100644 index 000000000..1de8e4059 --- /dev/null +++ b/src/accessor/grib_accessor_class_padtomultiple.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_padding.h" + +class grib_accessor_padtomultiple_t : public grib_accessor_padding_t +{ +public: + /* Members defined in padtomultiple */ + grib_expression* begin; + grib_expression* multiple; +}; + +class grib_accessor_class_padtomultiple_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_padtomultiple_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_padtomultiple_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; diff --git a/src/accessor/grib_accessor_class_position.cc b/src/accessor/grib_accessor_class_position.cc new file mode 100644 index 000000000..a2c3daacd --- /dev/null +++ b/src/accessor/grib_accessor_class_position.cc @@ -0,0 +1,54 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_position.h" + +grib_accessor_class_position_t _grib_accessor_class_position{ "position" }; +grib_accessor_class* grib_accessor_class_position = &_grib_accessor_class_position; + + +void grib_accessor_class_position_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_gen_t::init(a, len, arg); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; +} + +int grib_accessor_class_position_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_LONG; +} + +void grib_accessor_class_position_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_position_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + *val = a->offset; + *len = 1; + return GRIB_SUCCESS; +} + +// static int compare(grib_accessor* a, grib_accessor* b) +// { +// if (a->offset != b->offset) +// return GRIB_OFFSET_MISMATCH; +// return GRIB_SUCCESS; +// } diff --git a/src/accessor/grib_accessor_class_position.h b/src/accessor/grib_accessor_class_position.h new file mode 100644 index 000000000..58e5beb24 --- /dev/null +++ b/src/accessor/grib_accessor_class_position.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_position_t : public grib_accessor_gen_t +{ +public: + /* Members defined in position */ +}; + +class grib_accessor_class_position_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_position_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_position_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_proj_string.cc b/src/accessor/grib_accessor_class_proj_string.cc similarity index 65% rename from src/grib_accessor_class_proj_string.cc rename to src/accessor/grib_accessor_class_proj_string.cc index 7edfbf5be..03866753d 100644 --- a/src/grib_accessor_class_proj_string.cc +++ b/src/accessor/grib_accessor_class_proj_string.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,103 +9,17 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init - IMPLEMENTS = unpack_string - MEMBERS = const char* grid_type - MEMBERS = int endpoint - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_proj_string -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in proj_string */ - const char* grid_type; - int endpoint; -} grib_accessor_proj_string; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_proj_string = { - &grib_accessor_class_gen, /* super */ - "proj_string", /* name */ - sizeof(grib_accessor_proj_string), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_proj_string.h" +grib_accessor_class_proj_string_t _grib_accessor_class_proj_string{ "proj_string" }; grib_accessor_class* grib_accessor_class_proj_string = &_grib_accessor_class_proj_string; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) +void grib_accessor_class_proj_string_t::init(grib_accessor* a, const long len, grib_arguments* arg) { - grib_accessor_proj_string* self = (grib_accessor_proj_string*)a; - grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_class_gen_t::init(a, len, arg); + grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a; + grib_handle* h = grib_handle_of_accessor(a); self->grid_type = grib_arguments_get_name(h, arg, 0); self->endpoint = grib_arguments_get_long(h, arg, 1); @@ -113,7 +28,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_proj_string_t::get_native_type(grib_accessor* a) { return GRIB_TYPE_STRING; } @@ -122,8 +37,8 @@ static int get_native_type(grib_accessor* a) typedef int (*proj_func)(grib_handle*, char*); struct proj_mapping { - const char* gridType; // key gridType - proj_func func; // function to compute proj string + const char* gridType; // key gridType + proj_func func; // function to compute proj string }; typedef struct proj_mapping proj_mapping; @@ -151,9 +66,9 @@ static int get_earth_shape(grib_handle* h, char* result) if ((err = get_major_minor_axes(h, &major, &minor)) != GRIB_SUCCESS) return err; if (major == minor) - snprintf(result, 128, "+R=%lf", major); // spherical + snprintf(result, 128, "+R=%lf", major); // spherical else - snprintf(result, 128, "+a=%lf +b=%lf", major, minor); // oblate + snprintf(result, 128, "+a=%lf +b=%lf", major, minor); // oblate return err; } @@ -189,7 +104,7 @@ static int proj_equatorial_azimuthal_equidistant(grib_handle* h, char* result) static int proj_lambert_conformal(grib_handle* h, char* result) { - int err = 0; + int err = 0; char shape[128] = {0,}; double LoVInDegrees = 0, LaDInDegrees = 0, Latin1InDegrees = 0, Latin2InDegrees = 0; @@ -204,13 +119,13 @@ static int proj_lambert_conformal(grib_handle* h, char* result) if ((err = grib_get_double_internal(h, "LaDInDegrees", &LaDInDegrees)) != GRIB_SUCCESS) return err; snprintf(result, 1024, "+proj=lcc +lon_0=%lf +lat_0=%lf +lat_1=%lf +lat_2=%lf %s", - LoVInDegrees, LaDInDegrees, Latin1InDegrees, Latin2InDegrees, shape); + LoVInDegrees, LaDInDegrees, Latin1InDegrees, Latin2InDegrees, shape); return err; } static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result) { - int err = 0; + int err = 0; char shape[128] = {0,}; double standardParallel = 0, centralLongitude = 0; @@ -221,7 +136,7 @@ static int proj_lambert_azimuthal_equal_area(grib_handle* h, char* result) if ((err = grib_get_double_internal(h, "centralLongitudeInDegrees", ¢ralLongitude)) != GRIB_SUCCESS) return err; snprintf(result, 1024, "+proj=laea +lon_0=%lf +lat_0=%lf %s", - centralLongitude, standardParallel, shape); + centralLongitude, standardParallel, shape); return err; } @@ -243,7 +158,7 @@ static int proj_polar_stereographic(grib_handle* h, char* result) return err; has_northPole = ((projectionCentreFlag & 128) == 0); snprintf(result, 1024, "+proj=stere +lat_ts=%lf +lat_0=%s +lon_0=%lf +k_0=1 +x_0=0 +y_0=0 %s", - centralLatitude, has_northPole ? "90" : "-90", centralLongitude, shape); + centralLatitude, has_northPole ? "90" : "-90", centralLongitude, shape); return err; } @@ -252,9 +167,9 @@ static int proj_polar_stereographic(grib_handle* h, char* result) static int proj_unprojected(grib_handle* h, char* result) { int err = 0; - //char shape[128] = {0,}; - //if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err; - //snprintf(result, 1024, "+proj=longlat %s", shape); + // char shape[128] = {0,}; + // if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err; + // snprintf(result, 1024, "+proj=longlat %s", shape); snprintf(result, 1024, "+proj=longlat +datum=WGS84 +no_defs +type=crs"); return err; @@ -264,14 +179,14 @@ static int proj_mercator(grib_handle* h, char* result) { int err = 0; double LaDInDegrees = 0; - char shape[128] = {0,}; + char shape[128] = {0,}; if ((err = grib_get_double_internal(h, "LaDInDegrees", &LaDInDegrees)) != GRIB_SUCCESS) return err; if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS) return err; snprintf(result, 1024, "+proj=merc +lat_ts=%lf +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 %s", - LaDInDegrees, shape); + LaDInDegrees, shape); return err; } @@ -293,18 +208,18 @@ static proj_mapping proj_mappings[] = { #define ENDPOINT_SOURCE 0 #define ENDPOINT_TARGET 1 -static int unpack_string(grib_accessor* a, char* v, size_t* len) +int grib_accessor_class_proj_string_t::unpack_string(grib_accessor* a, char* v, size_t* len) { - grib_accessor_proj_string* self = (grib_accessor_proj_string*)a; + grib_accessor_proj_string_t* self = (grib_accessor_proj_string_t*)a; int err = 0, found = 0; - size_t i = 0; + size_t i = 0; char grid_type[64] = {0,}; grib_handle* h = grib_handle_of_accessor(a); - size_t size = sizeof(grid_type) / sizeof(*grid_type); + size_t size = sizeof(grid_type) / sizeof(*grid_type); Assert(self->endpoint == ENDPOINT_SOURCE || self->endpoint == ENDPOINT_TARGET); - size_t l = 100; // Safe bet + size_t l = 100; // Safe bet if (*len < l) { const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, diff --git a/src/accessor/grib_accessor_class_proj_string.h b/src/accessor/grib_accessor_class_proj_string.h new file mode 100644 index 000000000..e214c32a9 --- /dev/null +++ b/src/accessor/grib_accessor_class_proj_string.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_proj_string_t : public grib_accessor_gen_t +{ +public: + /* Members defined in proj_string */ + const char* grid_type; + int endpoint; +}; + +class grib_accessor_class_proj_string_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_proj_string_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_proj_string_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_raw.cc b/src/accessor/grib_accessor_class_raw.cc new file mode 100644 index 000000000..cf1f502c7 --- /dev/null +++ b/src/accessor/grib_accessor_class_raw.cc @@ -0,0 +1,126 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_raw.h" + +grib_accessor_class_raw_t _grib_accessor_class_raw{ "raw" }; +grib_accessor_class* grib_accessor_class_raw = &_grib_accessor_class_raw; + + +void grib_accessor_class_raw_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_gen_t::init(a, len, arg); + int n = 0; + int err = 0; + long sectionLength; + grib_accessor_raw_t* self = (grib_accessor_raw_t*)a; + grib_expression* e; + grib_handle* hand = grib_handle_of_accessor(a); + + a->length = 0; + self->totalLength = grib_arguments_get_name(hand, arg, n++); + self->sectionLength = grib_arguments_get_name(hand, arg, n++); + + e = grib_arguments_get_expression(hand, arg, n++); + err = grib_expression_evaluate_long(hand, e, &(self->relativeOffset)); + if (err) + grib_context_log(hand->context, GRIB_LOG_ERROR, "Unable to evaluate relativeOffset"); + + grib_get_long(hand, self->sectionLength, §ionLength); + + a->length = sectionLength - self->relativeOffset; + if (a->length < 0) + a->length = 0; + + /* Assert(a->length>=0); */ +} + +int grib_accessor_class_raw_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_BYTES; +} + + +int grib_accessor_class_raw_t::compare(grib_accessor* a, grib_accessor* b) +{ + int retval = GRIB_SUCCESS; + + size_t alen = (size_t)a->byte_count(); + size_t blen = (size_t)b->byte_count(); + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + return retval; +} + +long grib_accessor_class_raw_t::byte_count(grib_accessor* a) +{ + return a->length; +} + +int grib_accessor_class_raw_t::value_count(grib_accessor* a, long* len) +{ + *len = a->length; + return 0; +} + +int grib_accessor_class_raw_t::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); + + return GRIB_SUCCESS; +} + +void grib_accessor_class_raw_t::update_size(grib_accessor* a, size_t s) +{ + grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); + a->length = s; + Assert(a->length >= 0); +} + +void accessor_raw_set_length(grib_accessor* a, size_t len) +{ + a->length = len; +} + +long accessor_raw_get_offset(grib_accessor* a) +{ + return a->offset; +} + +int grib_accessor_class_raw_t::pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) +{ + size_t length = *len; + long totalLength; + long sectionLength; + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_raw_t* self = (grib_accessor_raw_t*)a; + long dlen = length - a->length; + + grib_get_long(h, self->totalLength, &totalLength); + totalLength += dlen; + grib_get_long(h, self->sectionLength, §ionLength); + sectionLength += dlen; + + grib_buffer_replace(a, val, length, 1, 1); + + grib_set_long(h, self->totalLength, totalLength); + grib_set_long(h, self->sectionLength, sectionLength); + a->length = length; + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_raw.h b/src/accessor/grib_accessor_class_raw.h new file mode 100644 index 000000000..8a588ac61 --- /dev/null +++ b/src/accessor/grib_accessor_class_raw.h @@ -0,0 +1,38 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_raw_t : public grib_accessor_gen_t +{ +public: + /* Members defined in raw */ + const char* totalLength; + const char* sectionLength; + long relativeOffset; +}; + +class grib_accessor_class_raw_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_raw_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_raw_t{}; } + int get_native_type(grib_accessor*) override; + int pack_bytes(grib_accessor*, const unsigned char*, size_t* len) override; + int unpack_bytes(grib_accessor*, unsigned char*, size_t* len) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc new file mode 100644 index 000000000..f4b317daa --- /dev/null +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc @@ -0,0 +1,78 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_rdbtime_guess_date.h" + +grib_accessor_class_rdbtime_guess_date_t _grib_accessor_class_rdbtime_guess_date{"rdbtime_guess_date"}; +grib_accessor_class* grib_accessor_class_rdbtime_guess_date = &_grib_accessor_class_rdbtime_guess_date; + + +void grib_accessor_class_rdbtime_guess_date_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a; + int n = 0; + + self->typicalYear = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->typicalMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->typicalDay = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->rdbDay = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->yearOrMonth = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + + /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ +} + +int grib_accessor_class_rdbtime_guess_date_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_rdbtime_guess_date_t* self = (grib_accessor_rdbtime_guess_date_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + long typicalYear, typicalMonth, typicalDay, rdbDay; + long rdbYear, rdbMonth; + + int ret = grib_get_long(h, self->typicalYear, &typicalYear); + if (ret) + return ret; + ret = grib_get_long(h, self->typicalMonth, &typicalMonth); + if (ret) + return ret; + ret = grib_get_long(h, self->typicalDay, &typicalDay); + if (ret) + return ret; + ret = grib_get_long(h, self->rdbDay, &rdbDay); + if (ret) + return ret; + + if (rdbDay < typicalDay) { + if (typicalDay == 31 && typicalMonth == 12) { + rdbYear = typicalYear + 1; + rdbMonth = 1; + } + else { + rdbYear = typicalYear; + rdbMonth = typicalMonth + 1; + } + } + else { + rdbYear = typicalYear; + rdbMonth = typicalMonth; + } + + *val = self->yearOrMonth == 1 ? rdbYear : rdbMonth; + *len = 1; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_rdbtime_guess_date_t::pack_long(grib_accessor* a, const long* v, size_t* len) +{ + /* do nothing*/ + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.h b/src/accessor/grib_accessor_class_rdbtime_guess_date.h new file mode 100644 index 000000000..739c95e8d --- /dev/null +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_rdbtime_guess_date_t : public grib_accessor_long_t +{ +public: + /* Members defined in rdbtime_guess_date */ + const char* typicalYear; + const char* typicalMonth; + const char* typicalDay; + const char* rdbDay; + long yearOrMonth; +}; + +class grib_accessor_class_rdbtime_guess_date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_rdbtime_guess_date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_rdbtime_guess_date_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_reference_value_error.cc b/src/accessor/grib_accessor_class_reference_value_error.cc new file mode 100644 index 000000000..fbf1a1c1b --- /dev/null +++ b/src/accessor/grib_accessor_class_reference_value_error.cc @@ -0,0 +1,52 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_reference_value_error.h" + +grib_accessor_class_reference_value_error_t _grib_accessor_class_reference_value_error{ "reference_value_error" }; +grib_accessor_class* grib_accessor_class_reference_value_error = &_grib_accessor_class_reference_value_error; + + +void grib_accessor_class_reference_value_error_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a; + int n = 0; + + self->referenceValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->floatType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_reference_value_error_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_accessor_reference_value_error_t* self = (grib_accessor_reference_value_error_t*)a; + int ret = GRIB_SUCCESS; + double referenceValue = 0; + + if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), + self->referenceValue, &referenceValue)) != GRIB_SUCCESS) + return ret; + + if (!strcmp(self->floatType, "ibm")) + *val = grib_ibmfloat_error(referenceValue); + else if (!strcmp(self->floatType, "ieee")) + *val = grib_ieeefloat_error(referenceValue); + else + Assert(1 == 0); + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_reference_value_error.h b/src/accessor/grib_accessor_class_reference_value_error.h new file mode 100644 index 000000000..2a470562e --- /dev/null +++ b/src/accessor/grib_accessor_class_reference_value_error.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_reference_value_error_t : public grib_accessor_double_t +{ +public: + /* Members defined in reference_value_error */ + const char* referenceValue; + const char* floatType; +}; + +class grib_accessor_class_reference_value_error_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_reference_value_error_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_reference_value_error_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_round.cc b/src/accessor/grib_accessor_class_round.cc new file mode 100644 index 000000000..e1d6aaeda --- /dev/null +++ b/src/accessor/grib_accessor_class_round.cc @@ -0,0 +1,70 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_round.h" + +grib_accessor_class_round_t _grib_accessor_class_round{ "round" }; +grib_accessor_class* grib_accessor_class_round = &_grib_accessor_class_round; + + +int grib_accessor_class_round_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_accessor_round_t* self = (grib_accessor_round_t*)a; + + int ret = GRIB_SUCCESS; + + size_t replen = 0; + double rounding_precision = 0; + double rounded = 0; + double toround = 0; + + const char* oval = NULL; + oval = grib_arguments_get_name(grib_handle_of_accessor(a), self->arg, 0); + + if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), oval, &toround)) != 0) + return ret; + + rounding_precision = grib_arguments_get_long(grib_handle_of_accessor(a), self->arg, 1); + + rounded = floor(rounding_precision * toround + 0.5) / rounding_precision; + + *len = replen; + + *val = rounded; + + return ret; +} + +int grib_accessor_class_round_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + char result[1024]; + int ret = GRIB_SUCCESS; + size_t replen = 1; + + double value = 0; + + ret = unpack_double(a, &value, &replen); + + snprintf(result, sizeof(result), "%.3f", value); + + replen = strlen(result) + 1; + + if (*len < replen) { + *len = replen; + return GRIB_ARRAY_TOO_SMALL; + } + + *len = replen; + + snprintf(val, 1024, "%s", result); + + return ret; +} diff --git a/src/accessor/grib_accessor_class_round.h b/src/accessor/grib_accessor_class_round.h new file mode 100644 index 000000000..364e24b34 --- /dev/null +++ b/src/accessor/grib_accessor_class_round.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_evaluate.h" + +class grib_accessor_round_t : public grib_accessor_evaluate_t +{ +public: + /* Members defined in round */ +}; + +class grib_accessor_class_round_t : public grib_accessor_class_evaluate_t +{ +public: + grib_accessor_class_round_t(const char* name) : grib_accessor_class_evaluate_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_round_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; +}; diff --git a/src/accessor/grib_accessor_class_scale.cc b/src/accessor/grib_accessor_class_scale.cc new file mode 100644 index 000000000..59ab7bfb4 --- /dev/null +++ b/src/accessor/grib_accessor_class_scale.cc @@ -0,0 +1,139 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_scale.h" + +grib_accessor_class_scale_t _grib_accessor_class_scale{ "scale" }; +grib_accessor_class* grib_accessor_class_scale = &_grib_accessor_class_scale; + + +void grib_accessor_class_scale_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; + int n = 0; + + self->value = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->multiplier = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->divisor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->truncating = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); +} + +int grib_accessor_class_scale_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; + int ret = 0; + long value = 0; + long multiplier = 0; + long divisor = 0; + + if (*len < 1) { + ret = GRIB_ARRAY_TOO_SMALL; + grib_context_log(a->context, GRIB_LOG_ERROR, + "Accessor %s cannot gather value for %s and/or %s", + a->name, self->multiplier, self->divisor); + return ret; + } + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->divisor, &divisor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->multiplier, &multiplier)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->value, &value)) != GRIB_SUCCESS) + return ret; + + if (value == GRIB_MISSING_LONG) + *val = GRIB_MISSING_DOUBLE; + else + *val = ((double)(value * multiplier)) / divisor; + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} + +int grib_accessor_class_scale_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + const double dval = (double)*val; + return pack_double(a, &dval, len); +} + +int grib_accessor_class_scale_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; + int ret = 0; + + long value = 0; + long divisor = 0; + long multiplier = 0; + long truncating = 0; + double x; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->divisor, &divisor); + if (ret != GRIB_SUCCESS) return ret; + + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->multiplier, &multiplier); + if (ret != GRIB_SUCCESS) return ret; + + if (self->truncating) { + ret = grib_get_long_internal(grib_handle_of_accessor(a), self->truncating, &truncating); + if (ret != GRIB_SUCCESS) return ret; + } + + if (multiplier == 0) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s: cannot divide by a zero multiplier %s", + a->name, self->multiplier); + return GRIB_ENCODING_ERROR; + } + + x = *val * (double)divisor / (double)multiplier; + if (*val == GRIB_MISSING_DOUBLE) + value = GRIB_MISSING_LONG; + else if (truncating) { + value = (long)x; + } + else { + value = x > 0 ? (long)(x + 0.5) : (long)(x - 0.5); + } + + ret = grib_set_long_internal(grib_handle_of_accessor(a), self->value, value); + if (ret) + grib_context_log(a->context, GRIB_LOG_ERROR, + "Accessor %s: cannot pack value for %s (%s)\n", + a->name, self->value, grib_get_error_message(ret)); + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} + +int grib_accessor_class_scale_t::is_missing(grib_accessor* a) +{ + grib_accessor_scale_t* self = (grib_accessor_scale_t*)a; + grib_accessor* av = grib_find_accessor(grib_handle_of_accessor(a), self->value); + + if (!av) + return GRIB_NOT_FOUND; + return av->is_missing_internal(); + // int ret=0; + // long value=0; + // if((ret = grib_get_long_internal(grib_handle_of_accessor(a),self->value, &value))!= GRIB_SUCCESS){ + // grib_context_log(a->context, GRIB_LOG_ERROR, + // "Accessor %s cannot gather value for %s error %d \n", a->name, + // self->value, ret); + // return 0; + // } + // return (value == GRIB_MISSING_LONG); +} diff --git a/src/accessor/grib_accessor_class_scale.h b/src/accessor/grib_accessor_class_scale.h new file mode 100644 index 000000000..29b65f34b --- /dev/null +++ b/src/accessor/grib_accessor_class_scale.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_scale_t : public grib_accessor_double_t +{ +public: + /* Members defined in scale */ + const char* value; + const char* multiplier; + const char* divisor; + const char* truncating; +}; + +class grib_accessor_class_scale_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_scale_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_scale_t{}; } + int is_missing(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_scale_values.cc b/src/accessor/grib_accessor_class_scale_values.cc new file mode 100644 index 000000000..03072311d --- /dev/null +++ b/src/accessor/grib_accessor_class_scale_values.cc @@ -0,0 +1,88 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_scale_values.h" + +grib_accessor_class_scale_values_t _grib_accessor_class_scale_values{ "scale_values" }; +grib_accessor_class* grib_accessor_class_scale_values = &_grib_accessor_class_scale_values; + + +void grib_accessor_class_scale_values_t::init(grib_accessor* a, const long l, grib_arguments* args) +{ + grib_accessor_class_double_t::init(a, l, args); + int n = 0; + grib_accessor_scale_values_t* self = (grib_accessor_scale_values_t*)a; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_scale_values_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + int ret = GRIB_SUCCESS; + *val = 1; + *len = 1; + return ret; +} + +int grib_accessor_class_scale_values_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + double* values = NULL; + double missingValue = 0; + long missingValuesPresent = 0; + size_t size = 0; + int ret = 0, i = 0; + grib_accessor_scale_values_t* self = (grib_accessor_scale_values_t*)a; + const grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (*val == 1) + return GRIB_SUCCESS; + + if ((ret = grib_get_double_internal(h, self->missingValue, &missingValue)) != GRIB_SUCCESS) { + return ret; + } + if ((ret = grib_get_long_internal(h, "missingValuesPresent", &missingValuesPresent)) != GRIB_SUCCESS) { + return ret; + } + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + for (i = 0; i < size; i++) { + if (missingValuesPresent) { + if (values[i] != missingValue) + values[i] *= *val; + } + else { + values[i] *= *val; + } + } + + if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + grib_context_free(c, values); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_scale_values.h b/src/accessor/grib_accessor_class_scale_values.h new file mode 100644 index 000000000..f004db30e --- /dev/null +++ b/src/accessor/grib_accessor_class_scale_values.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_scale_values_t : public grib_accessor_double_t +{ +public: + /* Members defined in scale_values */ + const char* values; + const char* missingValue; +}; + +class grib_accessor_class_scale_values_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_scale_values_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_scale_values_t{}; } + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_second_order_bits_per_value.cc b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc similarity index 50% rename from src/grib_accessor_class_second_order_bits_per_value.cc rename to src/accessor/grib_accessor_class_second_order_bits_per_value.cc index 74c4b4c05..ea7c4c931 100644 --- a/src/grib_accessor_class_second_order_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,108 +9,12 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/********************************** - * Enrico Fucile - **********************************/ - +#include "grib_accessor_class_second_order_bits_per_value.h" #include "grib_scaling.h" -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* binaryScaleFactor - MEMBERS = const char* decimalScaleFactor - MEMBERS = long bitsPerValue - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_second_order_bits_per_value -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in second_order_bits_per_value */ - const char* values; - const char* binaryScaleFactor; - const char* decimalScaleFactor; - long bitsPerValue; -} grib_accessor_second_order_bits_per_value; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_second_order_bits_per_value = { - &grib_accessor_class_long, /* super */ - "second_order_bits_per_value", /* name */ - sizeof(grib_accessor_second_order_bits_per_value), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_second_order_bits_per_value_t _grib_accessor_class_second_order_bits_per_value{"second_order_bits_per_value"}; grib_accessor_class* grib_accessor_class_second_order_bits_per_value = &_grib_accessor_class_second_order_bits_per_value; -/* END_CLASS_IMP */ static const size_t nbits[64] = { 0x1, 0x2, 0x4, 0x8, @@ -130,8 +35,7 @@ static const size_t nbits[64] = { 0x1000000000000000, 0x2000000000000000, 0x4000000000000000, 0x8000000000000000 }; -static int number_of_bits(size_t x, long* result) -{ +static int number_of_bits(size_t x, long* result){ const size_t* n = nbits; const int count = sizeof(nbits) / sizeof(nbits[0]); *result = 0; @@ -145,10 +49,10 @@ static int number_of_bits(size_t x, long* result) return GRIB_SUCCESS; } -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ +void grib_accessor_class_second_order_bits_per_value_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); int n = 0; - grib_accessor_second_order_bits_per_value* self = (grib_accessor_second_order_bits_per_value*)a; + grib_accessor_second_order_bits_per_value_t* self = (grib_accessor_second_order_bits_per_value_t*)a; self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->binaryScaleFactor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->decimalScaleFactor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -157,17 +61,15 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->length = 0; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_second_order_bits_per_value* self = (grib_accessor_second_order_bits_per_value*)a; +int grib_accessor_class_second_order_bits_per_value_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_second_order_bits_per_value_t* self = (grib_accessor_second_order_bits_per_value_t*)a; self->bitsPerValue = (long)*val; *len = 1; return 0; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_second_order_bits_per_value_t::unpack_long(grib_accessor* a, long* val, size_t* len){ int ret = GRIB_SUCCESS; size_t size = 0; size_t i; @@ -175,7 +77,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) double* values = 0; long binaryScaleFactor, decimalScaleFactor; - grib_accessor_second_order_bits_per_value* self = (grib_accessor_second_order_bits_per_value*)a; + grib_accessor_second_order_bits_per_value_t* self = (grib_accessor_second_order_bits_per_value_t*)a; if (self->bitsPerValue) { *val = self->bitsPerValue; return GRIB_SUCCESS; diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.h b/src/accessor/grib_accessor_class_second_order_bits_per_value.h new file mode 100644 index 000000000..c3459db41 --- /dev/null +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_second_order_bits_per_value_t : public grib_accessor_long_t +{ +public: + /* Members defined in second_order_bits_per_value */ + const char* values; + const char* binaryScaleFactor; + const char* decimalScaleFactor; + long bitsPerValue; +}; + +class grib_accessor_class_second_order_bits_per_value_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_second_order_bits_per_value_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_second_order_bits_per_value_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_section.cc b/src/accessor/grib_accessor_class_section.cc new file mode 100644 index 000000000..ec6e14c2b --- /dev/null +++ b/src/accessor/grib_accessor_class_section.cc @@ -0,0 +1,96 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_section.h" + +grib_accessor_class_section_t _grib_accessor_class_section{"section"}; +grib_accessor_class* grib_accessor_class_section = &_grib_accessor_class_section; + + +void grib_accessor_class_section_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + a->sub_section = grib_section_create(grib_handle_of_accessor(a), a); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_section_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_section(dumper, a, a->sub_section->block); +} + +long grib_accessor_class_section_t::byte_count(grib_accessor* a){ + if (!a->length || grib_handle_of_accessor(a)->loader) { + if (a->name[1] == '_') + return 0; + + /* printf("adjusting sizes SECTION %s is %ld %ld\n",a->name,(long)a->offset,(long)a->length); */ + grib_section_adjust_sizes(a->sub_section, grib_handle_of_accessor(a)->loader != NULL, 0); + /* printf(" SECTION %s is %ld %ld\n",a->name,(long)a->offset,(long)a->length); */ + } + + /* printf("SECTION %s is %ld %d\n",a->name,a->length,a->sub_section->aclength != NULL); */ + return a->length; +} + +long grib_accessor_class_section_t::next_offset(grib_accessor* a){ + return a->offset + a->byte_count(); +} + +void grib_accessor_class_section_t::destroy(grib_context* ct, grib_accessor* a){ + grib_section_delete(ct, a->sub_section); + grib_accessor_class_gen_t::destroy(ct, a); +} + +int grib_accessor_class_section_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_SECTION; +} + +grib_section* grib_accessor_class_section_t::sub_section(grib_accessor* a) +{ + return a->sub_section; +} + +void grib_accessor_class_section_t::update_size(grib_accessor* a, size_t length){ + size_t size = 1; + long len = length; + Assert(length <= 0x7fffffff); + if (a->sub_section->aclength) { + int e = a->sub_section->aclength->pack_long(&len, &size); Assert(e == GRIB_SUCCESS); + // printf("update_length %s %ld %ld\n", a->sub_section->aclength->name, + // (long)a->sub_section->aclength->offset, + // (long)a->sub_section->aclength->length); + } + + a->sub_section->length = a->length = length; + a->sub_section->padding = 0; + + // printf("update_size %s %ld\n", a->name, a->length); + + Assert(a->length >= 0); +} + +grib_accessor* grib_accessor_class_section_t::next(grib_accessor* a, int explore) +{ + grib_accessor* next = NULL; + if (explore) { + next = a->sub_section->block->first; + if (!next) + next = a->next_; + } + else { + next = a->next_; + } + if (!next) { + if (a->parent->owner) + next = a->parent->owner->cclass->next(a->parent->owner, 0); + } + return next; +} diff --git a/src/accessor/grib_accessor_class_section.h b/src/accessor/grib_accessor_class_section.h new file mode 100644 index 000000000..8dbd831cc --- /dev/null +++ b/src/accessor/grib_accessor_class_section.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_section_t : public grib_accessor_gen_t {}; + +class grib_accessor_class_section_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_section_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_t{}; } + int get_native_type(grib_accessor*) override; + long byte_count(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + grib_section* sub_section(grib_accessor*) override; + grib_accessor* next(grib_accessor*, int) override; +}; diff --git a/src/accessor/grib_accessor_class_section_length.cc b/src/accessor/grib_accessor_class_section_length.cc new file mode 100644 index 000000000..bcc75cc2b --- /dev/null +++ b/src/accessor/grib_accessor_class_section_length.cc @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_section_length.h" + +grib_accessor_class_section_length_t _grib_accessor_class_section_length{"section_length"}; +grib_accessor_class* grib_accessor_class_section_length = &_grib_accessor_class_section_length; + + +void grib_accessor_class_section_length_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_unsigned_t::init(a, len, arg); + a->parent->aclength = a; + a->length = len; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + Assert(a->length >= 0); +} + +void grib_accessor_class_section_length_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_section_length_t::value_count(grib_accessor* a, long* c){ + *c = 1; + return 0; +} diff --git a/src/accessor/grib_accessor_class_section_length.h b/src/accessor/grib_accessor_class_section_length.h new file mode 100644 index 000000000..e7965b9b1 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_length.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_section_length_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in section_length */ +}; + +class grib_accessor_class_section_length_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_section_length_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_length_t{}; } + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_section_padding.cc b/src/accessor/grib_accessor_class_section_padding.cc new file mode 100644 index 000000000..c3457898f --- /dev/null +++ b/src/accessor/grib_accessor_class_section_padding.cc @@ -0,0 +1,70 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_section_padding.h" + +grib_accessor_class_section_padding_t _grib_accessor_class_section_padding{"section_padding"}; +grib_accessor_class* grib_accessor_class_section_padding = &_grib_accessor_class_section_padding; + + +size_t grib_accessor_class_section_padding_t::preferred_size(grib_accessor* a, int from_handle){ + grib_accessor_section_padding_t* self = (grib_accessor_section_padding_t*)a; + grib_accessor* b = a; + grib_accessor* section_length = 0; + long length = 0; + size_t size = 1; + + long alength = 0; + + if (!from_handle) { + if (self->preserve) + return a->length; + else + return 0; + } + + /* The section length should be a parameter */ + while (section_length == NULL && b != NULL) { + section_length = b->parent->aclength; + b = b->parent->owner; + } + + if (!section_length) { + /* printf("PADDING is no !section_length\n"); */ + return 0; + } + + if (section_length->unpack_long(&length, &size) == GRIB_SUCCESS) { + if (length) + alength = length - a->offset + section_length->parent->owner->offset; + else + alength = 0; + + /*Assert(a->length>=0);*/ + + if (alength < 0) + alength = 0; + + /* printf("PADDING is %ld\n",a->length); */ + } + else { + /* printf("PADDING unpack fails\n"); */ + } + + return alength; +} + +void grib_accessor_class_section_padding_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_padding_t::init(a, len, arg); + grib_accessor_section_padding_t* self = (grib_accessor_section_padding_t*)a; + self->preserve = 1; /* This should be a parameter */ + a->length = preferred_size(a, 1); +} diff --git a/src/accessor/grib_accessor_class_section_padding.h b/src/accessor/grib_accessor_class_section_padding.h new file mode 100644 index 000000000..f35da4977 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_padding.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_padding.h" + +class grib_accessor_section_padding_t : public grib_accessor_padding_t +{ +public: + /* Members defined in section_padding */ + int preserve; +}; + +class grib_accessor_class_section_padding_t : public grib_accessor_class_padding_t +{ +public: + grib_accessor_class_section_padding_t(const char* name) : grib_accessor_class_padding_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_padding_t{}; } + void init(grib_accessor*, const long, grib_arguments*) override; + size_t preferred_size(grib_accessor*, int) override; +}; diff --git a/src/accessor/grib_accessor_class_section_pointer.cc b/src/accessor/grib_accessor_class_section_pointer.cc new file mode 100644 index 000000000..72eb78d6d --- /dev/null +++ b/src/accessor/grib_accessor_class_section_pointer.cc @@ -0,0 +1,97 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_section_pointer.h" + +grib_accessor_class_section_pointer_t _grib_accessor_class_section_pointer{"section_pointer"}; +grib_accessor_class* grib_accessor_class_section_pointer = &_grib_accessor_class_section_pointer; + + +void grib_accessor_class_section_pointer_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + int n = 0; + grib_accessor_section_pointer_t* self = (grib_accessor_section_pointer_t*)a; + + self->sectionOffset = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->sectionLength = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); + self->sectionNumber = grib_arguments_get_long(grib_handle_of_accessor(a), arg, n++); + + Assert(self->sectionNumber < MAX_NUM_SECTIONS); + + grib_handle_of_accessor(a)->section_offset[self->sectionNumber] = (char*)self->sectionOffset; + grib_handle_of_accessor(a)->section_length[self->sectionNumber] = (char*)self->sectionLength; + + /* printf("++++++++++++++ GRIB_API: creating section_pointer%d %s %s\n", */ + /* self->sectionNumber,self->sectionLength,self->sectionLength); */ + + if (grib_handle_of_accessor(a)->sections_count < self->sectionNumber) + grib_handle_of_accessor(a)->sections_count = self->sectionNumber; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; + a->length = 0; +} + +int grib_accessor_class_section_pointer_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_BYTES; +} + +int grib_accessor_class_section_pointer_t::unpack_string(grib_accessor* a, char* v, size_t* len){ + /* + unsigned char* p=NULL; + char* s=v; + int i; + long length=a->byte_count(); + if (*len < length) return GRIB_ARRAY_TOO_SMALL; + + p = grib_handle_of_accessor(a)->buffer->data + a->byte_offset(); + for (i = 0; i < length; i++) { + snprintf (s,64,"%02x", *(p++)); + s+=2; + } + *len=length; + */ + snprintf(v, 64, "%ld_%ld", a->byte_offset(), a->byte_count()); return GRIB_SUCCESS; +} + +long grib_accessor_class_section_pointer_t::byte_count(grib_accessor* a){ + grib_accessor_section_pointer_t* self = (grib_accessor_section_pointer_t*)a; + long sectionLength = 0; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->sectionLength, §ionLength); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Unable to get %s %s", + self->sectionLength, grib_get_error_message(ret)); + return -1; + } + + return sectionLength; +} + +long grib_accessor_class_section_pointer_t::byte_offset(grib_accessor* a){ + grib_accessor_section_pointer_t* self = (grib_accessor_section_pointer_t*)a; + long sectionOffset = 0; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->sectionOffset, §ionOffset); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Unable to get %s %s", + self->sectionOffset, grib_get_error_message(ret)); + return -1; + } + + return sectionOffset; +} diff --git a/src/accessor/grib_accessor_class_section_pointer.h b/src/accessor/grib_accessor_class_section_pointer.h new file mode 100644 index 000000000..569e20201 --- /dev/null +++ b/src/accessor/grib_accessor_class_section_pointer.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_section_pointer_t : public grib_accessor_gen_t +{ +public: + /* Members defined in section_pointer */ + const char* sectionOffset; + const char* sectionLength; + long sectionNumber; +}; + +class grib_accessor_class_section_pointer_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_section_pointer_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_section_pointer_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_select_step_template.cc b/src/accessor/grib_accessor_class_select_step_template.cc similarity index 60% rename from src/grib_accessor_class_select_step_template.cc rename to src/accessor/grib_accessor_class_select_step_template.cc index 7a0e76c23..bc72a5220 100644 --- a/src/grib_accessor_class_select_step_template.cc +++ b/src/accessor/grib_accessor_class_select_step_template.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,108 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=int instant - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_select_step_template -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in select_step_template */ - const char* productDefinitionTemplateNumber; - int instant; -} grib_accessor_select_step_template; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_select_step_template = { - &grib_accessor_class_unsigned, /* super */ - "select_step_template", /* name */ - sizeof(grib_accessor_select_step_template), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_select_step_template.h" +grib_accessor_class_select_step_template_t _grib_accessor_class_select_step_template{"select_step_template"}; grib_accessor_class* grib_accessor_class_select_step_template = &_grib_accessor_class_select_step_template; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_select_step_template* self = (grib_accessor_select_step_template*)a; +void grib_accessor_class_select_step_template_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_unsigned_t::init(a, l, c); + grib_accessor_select_step_template_t* self = (grib_accessor_select_step_template_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -117,15 +25,13 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->instant = grib_arguments_get_long(hand, c, n++); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ +int grib_accessor_class_select_step_template_t::unpack_long(grib_accessor* a, long* val, size_t* len){ *val = 1; return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_select_step_template* self = (grib_accessor_select_step_template*)a; +int grib_accessor_class_select_step_template_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_select_step_template_t* self = (grib_accessor_select_step_template_t*)a; grib_handle* hand = grib_handle_of_accessor(a); long productDefinitionTemplateNumber = 0; long productDefinitionTemplateNumberNew = 0; @@ -266,8 +172,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* c) -{ +int grib_accessor_class_select_step_template_t::value_count(grib_accessor* a, long* c){ *c = 1; return 0; } diff --git a/src/accessor/grib_accessor_class_select_step_template.h b/src/accessor/grib_accessor_class_select_step_template.h new file mode 100644 index 000000000..e327a99da --- /dev/null +++ b/src/accessor/grib_accessor_class_select_step_template.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" + +class grib_accessor_select_step_template_t : public grib_accessor_unsigned_t +{ +public: + /* Members defined in select_step_template */ + const char* productDefinitionTemplateNumber; + int instant; +}; + +class grib_accessor_class_select_step_template_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_select_step_template_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_select_step_template_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.cc b/src/accessor/grib_accessor_class_sexagesimal2decimal.cc new file mode 100644 index 000000000..e1920c1b9 --- /dev/null +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.cc @@ -0,0 +1,146 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_sexagesimal2decimal.h" + +grib_accessor_class_sexagesimal2decimal_t _grib_accessor_class_sexagesimal2decimal{"sexagesimal2decimal"}; +grib_accessor_class* grib_accessor_class_sexagesimal2decimal = &_grib_accessor_class_sexagesimal2decimal; + + +void grib_accessor_class_sexagesimal2decimal_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_to_double_t::init(a, len, arg); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_sexagesimal2decimal_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_double(dumper, a, NULL); +} + +int grib_accessor_class_sexagesimal2decimal_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_DOUBLE; +} + +int grib_accessor_class_sexagesimal2decimal_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + int err = 0; + grib_accessor_sexagesimal2decimal_t* self = (grib_accessor_sexagesimal2decimal_t*)a; + char buff[512] = {0,}; + size_t length = 0; + size_t size = 512; + char* p; + char* q; + double dd, mm = 0, ss = 0; + int dd_sign = 1; + + err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); + if (err) + return err; + q = buff + self->start; + if (self->length) + q[length] = 0; + p = q; + + while (*p != '-' && *p != ':' && *p != ' ' && *p != 0) { + p++; + } + + if (*p == 0) { + return GRIB_WRONG_CONVERSION; + } + *p = 0; + + dd = atoi(q); + p++; + q = p; + while (*p != '-' && *p != ':' && *p != ' ' && *p != 'N' && *p != 'S' && *p != 'E' && *p != 'W' && *p != 0) { + p++; + } + switch (*p) { + case ' ': + case '-': + case ':': + *p = 0; + mm = atoi(q) / 60.0; + dd += mm; + p++; + q = p; + break; + case 'N': + case 'E': + *p = 0; + dd_sign = 1; + mm = atoi(q) / 60.0; + dd += mm; + p++; + q = p; + break; + case 'S': + case 'W': + *p = 0; + mm = atoi(q) / 60.0; + dd += mm; + dd_sign = -1; + p++; + q = p; + break; + case 0: + break; + default: + return GRIB_WRONG_CONVERSION; + } + if (*p) { + while (*p != '-' && *p != ':' && *p != ' ' && *p != 'N' && *p != 'S' && *p != 'E' && *p != 'W' && *p != 0) { + p++; + } + switch (*p) { + case ' ': + case '-': + case ':': + *p = 0; + ss = atof(q) / 60.0; + dd += ss; + break; + case 'N': + case 'E': + *p = 0; + ss = atof(q) / 60.0; + dd += ss; + dd_sign = 1; + break; + case 'S': + case 'W': + *p = 0; + ss = atof(q) / 60.0; + dd += ss; + dd_sign = -1; + break; + case 0: + break; + default: + return GRIB_WRONG_CONVERSION; + } + } + dd *= dd_sign; + + snprintf(buff, sizeof(buff), "%.2f", dd); + length = strlen(buff); + + if (len[0] < length + 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", + len[0], a->name, a->length + 1); + len[0] = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + strcpy(val, buff); + + len[0] = length; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_sexagesimal2decimal.h b/src/accessor/grib_accessor_class_sexagesimal2decimal.h new file mode 100644 index 000000000..d9051bca9 --- /dev/null +++ b/src/accessor/grib_accessor_class_sexagesimal2decimal.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_to_double.h" + +class grib_accessor_sexagesimal2decimal_t : public grib_accessor_to_double_t +{ +public: + /* Members defined in sexagesimal2decimal */ +}; + +class grib_accessor_class_sexagesimal2decimal_t : public grib_accessor_class_to_double_t +{ +public: + grib_accessor_class_sexagesimal2decimal_t(const char* name) : grib_accessor_class_to_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sexagesimal2decimal_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_signed.cc b/src/accessor/grib_accessor_class_signed.cc new file mode 100644 index 000000000..36c20bd59 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed.cc @@ -0,0 +1,219 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_signed.h" + +grib_accessor_class_signed_t _grib_accessor_class_signed{ "signed" }; +grib_accessor_class* grib_accessor_class_signed = &_grib_accessor_class_signed; + + +void grib_accessor_class_signed_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_long_t::init(a, len, arg); + grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; + long count = 0; + + self->arg = arg; + a->value_count(&count); + a->length = len * count; + self->nbytes = len; + Assert(a->length >= 0); +} + +void grib_accessor_class_signed_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + long rlen = 0; + a->value_count(&rlen); + if (rlen == 1) + grib_dump_long(dumper, a, NULL); + else + grib_dump_values(dumper, a); +} + +static const long ones[] = { + 0, + -0x7f, + -0x7fff, + -0x7fffff, + -0x7fffffff, +}; + +int grib_accessor_class_signed_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; + unsigned long rlen = 0; + int err = 0; + long count = 0; + unsigned long i = 0; + grib_handle* hand = grib_handle_of_accessor(a); + long pos = a->offset; + long missing = 0; + + err = a->value_count(&count); + if (err) + return err; + rlen = count; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %lu values", a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { + Assert(self->nbytes <= 4); + missing = ones[self->nbytes]; + } + + for (i = 0; i < rlen; i++) { + val[i] = (long)grib_decode_signed_long(hand->buffer->data, pos, self->nbytes); + if (missing) + if (val[i] == missing) + val[i] = GRIB_MISSING_LONG; + pos += self->nbytes; + } + + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_signed_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; + + int ret = 0; + long off = 0; + unsigned long rlen = 0; + long count = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + long missing = 0; + + int err = a->value_count(&count); + if (err) + return err; + rlen = count; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); + len[0] = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { + Assert(self->nbytes <= 4); + missing = ones[self->nbytes]; + } + + if (rlen == 1) { + long v = val[0]; + if (missing) { + if (v == GRIB_MISSING_LONG) + v = missing; + } + else { + // ECC-1605: Check overflow/underflow + const int nbits = self->nbytes * 8; + const long minval = -(1L << (nbits - 1)) + 1; + const long maxval = (1L << (nbits - 1)) - 1; + // printf(" key=%s: v=%ld (minval=%ld maxval=%ld)\n", a->name, v, minval, maxval); + if (v > maxval || v < minval) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Key \"%s\": Trying to encode value of %ld but the allowable range is %ld to %ld (number of bits=%d)", + a->name, v, minval, maxval, nbits); + return GRIB_ENCODING_ERROR; + } + } + + off = a->offset; + ret = grib_encode_signed_long(grib_handle_of_accessor(a)->buffer->data, v, off, a->length); + if (ret == GRIB_SUCCESS) + len[0] = 1; + if (*len > 1) + grib_context_log(a->context, GRIB_LOG_WARNING, "grib_accessor_signed_t : Trying to pack %d values in a scalar %s, packing first value", *len, a->name); + len[0] = 1; + return ret; + } + + /* TODO: We assume that there are no missing values if there are more that 1 value */ + + buflen = *len * a->length; + + buf = (unsigned char*)grib_context_malloc(a->context, buflen); + + for (i = 0; i < *len; i++) { + grib_encode_signed_long(buf, val[i], off, a->length); + off += a->length; + } + ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), *len); + + if (ret == GRIB_SUCCESS) + grib_buffer_replace(a, buf, buflen, 1, 1); + else + *len = 0; + + grib_context_free(a->context, buf); + return ret; +} + +long grib_accessor_class_signed_t::byte_count(grib_accessor* a) +{ + return a->length; +} + +int grib_accessor_class_signed_t::value_count(grib_accessor* a, long* len) +{ + grib_accessor_signed_t* self = (grib_accessor_signed_t*)a; + *len = 0; + if (!self->arg) { + *len = 1; + return 0; + } + return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); +} + +long grib_accessor_class_signed_t::byte_offset(grib_accessor* a) +{ + return a->offset; +} + +void grib_accessor_class_signed_t::update_size(grib_accessor* a, size_t s) +{ + a->length = s; + Assert(a->length >= 0); +} + +long grib_accessor_class_signed_t::next_offset(grib_accessor* a) +{ + return a->byte_offset() + a->byte_count(); +} + +int grib_accessor_class_signed_t::is_missing(grib_accessor* a) +{ + int i = 0; + unsigned char ff = 0xff; + unsigned long offset = a->offset; + grib_handle* hand = grib_handle_of_accessor(a); + + if (a->length == 0) { + Assert(a->vvalue != NULL); + return a->vvalue->missing; + } + + for (i = 0; i < a->length; i++) { + if (hand->buffer->data[offset] != ff) + return 0; + offset++; + } + + return 1; +} diff --git a/src/accessor/grib_accessor_class_signed.h b/src/accessor/grib_accessor_class_signed.h new file mode 100644 index 000000000..9fbb6f8d2 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed.h @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_signed_t : public grib_accessor_long_t +{ +public: + /* Members defined in signed */ + grib_arguments* arg; + int nbytes; +}; + +class grib_accessor_class_signed_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_signed_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_signed_t{}; } + int is_missing(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; diff --git a/src/accessor/grib_accessor_class_signed_bits.cc b/src/accessor/grib_accessor_class_signed_bits.cc new file mode 100644 index 000000000..3da4d03c2 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed_bits.cc @@ -0,0 +1,152 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_signed_bits.h" + +grib_accessor_class_signed_bits_t _grib_accessor_class_signed_bits{"signed_bits"}; +grib_accessor_class* grib_accessor_class_signed_bits = &_grib_accessor_class_signed_bits; + + +long grib_accessor_class_signed_bits_t::byte_count(grib_accessor* a){ + return a->length; +} + +static long compute_byte_count(grib_accessor* a){ + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + long numberOfBits; + long numberOfElements; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfBits); + return 0; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + return 0; + } + + return (numberOfBits * numberOfElements + 7) / 8; +} + +void grib_accessor_class_signed_bits_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + int n = 0; + self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->length = compute_byte_count(a); +} + +int grib_accessor_class_signed_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +#if 0 + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + int i; + int ret = 0; + long pos = a->offset * 8; + long rlen = 0; + long numberOfBits = 0; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + + if (numberOfBits == 0) { + for (i = 0; i < rlen; i++) + val[i] = 0; + return GRIB_SUCCESS; + } + + for (i = 0; i < rlen; i++) + val[i] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); + + *len = rlen; + + return GRIB_SUCCESS; +#endif +} + +int grib_accessor_class_signed_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +#if 0 + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + int ret = 0; + long off = 0; + long numberOfBits = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + unsigned long rlen = 0; + long count = 0; + + ret = value_count(a, &count); + if (ret) + return ret; + rlen = count; + if (*len != rlen) { + ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, rlen); + if (ret) + return ret; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + + buflen = compute_byte_count(a); + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen + sizeof(long)); + + for (i = 0; i < rlen; i++) + grib_encode_signed_longb(buf, val[i], &off, numberOfBits); + + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_free(a->context, buf); + + return ret; +#endif +} + +int grib_accessor_class_signed_bits_t::value_count(grib_accessor* a, long* numberOfElements){ + grib_accessor_signed_bits_t* self = (grib_accessor_signed_bits_t*)a; + *numberOfElements = 0; + + return grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); +} + +long grib_accessor_class_signed_bits_t::byte_offset(grib_accessor* a){ + return a->offset; +} + +void grib_accessor_class_signed_bits_t::update_size(grib_accessor* a, size_t s){ + a->length = s; +} + +long grib_accessor_class_signed_bits_t::next_offset(grib_accessor* a){ + return a->byte_offset() + a->byte_count(); +} diff --git a/src/accessor/grib_accessor_class_signed_bits.h b/src/accessor/grib_accessor_class_signed_bits.h new file mode 100644 index 000000000..dd49c5c75 --- /dev/null +++ b/src/accessor/grib_accessor_class_signed_bits.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_signed_bits_t : public grib_accessor_long_t +{ +public: + /* Members defined in signed_bits */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_signed_bits_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_signed_bits_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_signed_bits_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; diff --git a/src/accessor/grib_accessor_class_simple_packing_error.cc b/src/accessor/grib_accessor_class_simple_packing_error.cc new file mode 100644 index 000000000..5f713a950 --- /dev/null +++ b/src/accessor/grib_accessor_class_simple_packing_error.cc @@ -0,0 +1,70 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_simple_packing_error.h" +#include "grib_scaling.h" + +grib_accessor_class_simple_packing_error_t _grib_accessor_class_simple_packing_error{"simple_packing_error"}; +grib_accessor_class* grib_accessor_class_simple_packing_error = &_grib_accessor_class_simple_packing_error; + + +void grib_accessor_class_simple_packing_error_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_simple_packing_error_t* self = (grib_accessor_simple_packing_error_t*)a; + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); + + self->bitsPerValue = grib_arguments_get_name(h, c, n++); + self->binaryScaleFactor = grib_arguments_get_name(h, c, n++); + self->decimalScaleFactor = grib_arguments_get_name(h, c, n++); + self->referenceValue = grib_arguments_get_name(h, c, n++); + self->floatType = grib_arguments_get_name(h, c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_simple_packing_error_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_simple_packing_error_t* self = (grib_accessor_simple_packing_error_t*)a; + + int ret = 0; + long binaryScaleFactor = 0; + long bitsPerValue = 0; + long decimalScaleFactor = 0; + double referenceValue = 0; + grib_handle* h = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(h, self->binaryScaleFactor, &binaryScaleFactor)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(h, self->bitsPerValue, &bitsPerValue)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(h, self->decimalScaleFactor, &decimalScaleFactor)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_double_internal(h, self->referenceValue, &referenceValue)) != GRIB_SUCCESS) + return ret; + + if (!strcmp(self->floatType, "ibm")) + *val = grib_ibmfloat_error(referenceValue); + else if (!strcmp(self->floatType, "ieee")) + *val = grib_ieeefloat_error(referenceValue); + else + Assert(1 == 0); + + if (bitsPerValue != 0) + *val = (*val + codes_power(binaryScaleFactor, 2)) * codes_power(-decimalScaleFactor, 10) * 0.5; + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_simple_packing_error.h b/src/accessor/grib_accessor_class_simple_packing_error.h new file mode 100644 index 000000000..f0c005e03 --- /dev/null +++ b/src/accessor/grib_accessor_class_simple_packing_error.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_simple_packing_error_t : public grib_accessor_double_t +{ +public: + /* Members defined in simple_packing_error */ + const char* binaryScaleFactor; + const char* bitsPerValue; + const char* decimalScaleFactor; + const char* referenceValue; + const char* floatType; +}; + +class grib_accessor_class_simple_packing_error_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_simple_packing_error_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_simple_packing_error_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_size.cc b/src/accessor/grib_accessor_class_size.cc new file mode 100644 index 000000000..71c0dd947 --- /dev/null +++ b/src/accessor/grib_accessor_class_size.cc @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_size.h" + +grib_accessor_class_size_t _grib_accessor_class_size{ "size" }; +grib_accessor_class* grib_accessor_class_size = &_grib_accessor_class_size; + + +void grib_accessor_class_size_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_size_t* self = (grib_accessor_size_t*)a; + self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_size_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_size_t* self = (grib_accessor_size_t*)a; + + size_t size = 0; + int ret = grib_get_size(grib_handle_of_accessor(a), self->accessor, &size); + *val = (long)size; + *len = 1; + return ret; +} diff --git a/src/accessor/grib_accessor_class_size.h b/src/accessor/grib_accessor_class_size.h new file mode 100644 index 000000000..9901c479e --- /dev/null +++ b/src/accessor/grib_accessor_class_size.h @@ -0,0 +1,30 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_size_t : public grib_accessor_long_t +{ +public: + /* Members defined in size */ + const char* accessor; +}; + +class grib_accessor_class_size_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_size_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_size_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_smart_table.cc b/src/accessor/grib_accessor_class_smart_table.cc similarity index 59% rename from src/grib_accessor_class_smart_table.cc rename to src/accessor/grib_accessor_class_smart_table.cc index dd6cfcd41..1c49f2ab0 100644 --- a/src/grib_accessor_class_smart_table.cc +++ b/src/accessor/grib_accessor_class_smart_table.cc @@ -8,131 +8,12 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/***************************************** - * Enrico Fucile - ****************************************/ - -#include "grib_api_internal.h" +#include "grib_accessor_class_smart_table.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = init;dump;unpack_string;unpack_long - IMPLEMENTS = value_count; destroy; get_native_type; - MEMBERS = const char* values - MEMBERS = const char* tablename - MEMBERS = const char* masterDir - MEMBERS = const char* localDir - MEMBERS = const char* extraDir - MEMBERS = const char* extraTable - MEMBERS = int widthOfCode - MEMBERS = long* tableCodes - MEMBERS = size_t tableCodesSize - MEMBERS = grib_smart_table* table - MEMBERS = int dirty - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_smart_table -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in smart_table */ - const char* values; - const char* tablename; - const char* masterDir; - const char* localDir; - const char* extraDir; - const char* extraTable; - int widthOfCode; - long* tableCodes; - size_t tableCodesSize; - grib_smart_table* table; - int dirty; -} grib_accessor_smart_table; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_smart_table = { - &grib_accessor_class_unsigned, /* super */ - "smart_table", /* name */ - sizeof(grib_accessor_smart_table), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - +grib_accessor_class_smart_table_t _grib_accessor_class_smart_table{"smart_table"}; grib_accessor_class* grib_accessor_class_smart_table = &_grib_accessor_class_smart_table; -/* END_CLASS_IMP */ - #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; @@ -149,7 +30,7 @@ static void thread_init() static int once = 0; static omp_nest_lock_t mutex; -static void thread_init() +void thread_init() { GRIB_OMP_CRITICAL(lock_grib_accessor_class_smart_table_c) { @@ -163,11 +44,13 @@ static void thread_init() static int grib_load_smart_table(grib_context* c, const char* filename, const char* recomposed_name, size_t size, grib_smart_table* t); -static void init(grib_accessor* a, const long len, grib_arguments* params) +void grib_accessor_class_smart_table_t::init(grib_accessor* a, const long len, grib_arguments* params) { - int n = 0; - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; - grib_handle* hand = grib_handle_of_accessor(a); + grib_accessor_class_unsigned_t::init(a, len, params); + + int n = 0; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); self->values = grib_arguments_get_name(hand, params, n++); self->tablename = grib_arguments_get_string(hand, params, n++); @@ -179,25 +62,25 @@ static void init(grib_accessor* a, const long len, grib_arguments* params) a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - self->dirty = 1; + self->dirty = 1; self->tableCodesSize = 0; - self->tableCodes = 0; + self->tableCodes = 0; } -static grib_smart_table* load_table(grib_accessor* a) +grib_smart_table* load_table(grib_accessor* a) { - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; - size_t size = 0; - grib_handle* h = ((grib_accessor*)self)->parent->h; - grib_context* c = h->context; - grib_smart_table* t = NULL; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; + size_t size = 0; + grib_handle* h = ((grib_accessor*)self)->parent->h; + grib_context* c = h->context; + grib_smart_table* t = NULL; grib_smart_table* next = NULL; - char* filename = 0; + char* filename = 0; char recomposed[1024] = {0,}; char localRecomposed[1024] = {0,}; - char* localFilename = 0; + char* localFilename = 0; char extraRecomposed[1024] = {0,}; - char* extraFilename = 0; + char* extraFilename = 0; char masterDir[1024] = {0,}; char localDir[1024] = {0,}; char extraDir[1024] = {0,}; @@ -253,13 +136,13 @@ static grib_smart_table* load_table(grib_accessor* a) next = next->next; } - /* Note: self->widthOfCode is chosen so that 2^width is bigger than the maximum descriptor code, - * which for BUFR4 is the Table C operator 243255 - */ - size = (1ULL << self->widthOfCode); /* = 2^self->widthOfCode (as a 64 bit number) */ + // Note: self->widthOfCode is chosen so that 2^width is bigger than the maximum descriptor code, + // which for BUFR4 is the Table C operator 243255 + // + size = (1ULL << self->widthOfCode); // = 2^self->widthOfCode (as a 64 bit number) - 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)); + 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)); t->numberOfEntries = size; if (filename != 0) @@ -296,21 +179,21 @@ static int grib_load_smart_table(grib_context* c, const char* filename, Assert(t != NULL); if (t->filename[0] == NULL) { - t->filename[0] = grib_context_strdup_persistent(c, filename); + t->filename[0] = grib_context_strdup_persistent(c, filename); t->recomposed_name[0] = grib_context_strdup_persistent(c, recomposed_name); - t->next = c->smart_table; - t->numberOfEntries = size; + t->next = c->smart_table; + t->numberOfEntries = size; GRIB_MUTEX_INIT_ONCE(&once, &thread_init); GRIB_MUTEX_LOCK(&mutex); c->smart_table = t; GRIB_MUTEX_UNLOCK(&mutex); } else if (t->filename[1] == NULL) { - t->filename[1] = grib_context_strdup_persistent(c, filename); + t->filename[1] = grib_context_strdup_persistent(c, filename); t->recomposed_name[1] = grib_context_strdup_persistent(c, recomposed_name); } else { - t->filename[2] = grib_context_strdup_persistent(c, filename); + t->filename[2] = grib_context_strdup_persistent(c, filename); t->recomposed_name[2] = grib_context_strdup_persistent(c, recomposed_name); } @@ -344,7 +227,7 @@ static int grib_load_smart_table(grib_context* c, const char* filename, *p = 0; numberOfColumns = 0; - /* The highest possible descriptor code must fit into t->numberOfEntries */ + // The highest possible descriptor code must fit into t->numberOfEntries DEBUG_ASSERT(code < t->numberOfEntries); while (*s) { char* tcol = t->entries[code].column[numberOfColumns]; @@ -397,15 +280,15 @@ void grib_smart_table_delete(grib_context* c) } } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_smart_table_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_long(dumper, a, NULL); } -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) +int grib_accessor_class_smart_table_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) { - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; - grib_smart_table* table = NULL; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; + grib_smart_table* table = NULL; size_t size = 1; long value; @@ -413,7 +296,7 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) char tmp[1024]; size_t l = 0; - if ((err = grib_unpack_long(a, &value, &size)) != GRIB_SUCCESS) + if ((err = a->unpack_long(&value, &size)) != GRIB_SUCCESS) return err; if (!self->table) @@ -435,7 +318,7 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) } strcpy(buffer, tmp); - *len = l; + *len = l; self->dirty = 0; return GRIB_SUCCESS; @@ -443,10 +326,10 @@ static int unpack_string(grib_accessor* a, char* buffer, size_t* len) static int get_table_codes(grib_accessor* a) { - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; - size_t size = 0; - long* v = 0; - int err = 0; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; + size_t size = 0; + long* v = 0; + int err = 0; int count, j; size_t i; @@ -455,7 +338,7 @@ static int get_table_codes(grib_accessor* a) if (!self->dirty) return 0; - table_size = (1 << self->widthOfCode); /* 2 ^ self->widthOfCode */ + table_size = (1 << self->widthOfCode); // 2 ^ self->widthOfCode if (!self->table) self->table = load_table(a); @@ -479,7 +362,7 @@ static int get_table_codes(grib_accessor* a) if (self->tableCodes) grib_context_free(a->context, self->tableCodes); self->tableCodes = (long*)grib_context_malloc_clear(a->context, count * sizeof(long)); - j = 0; + j = 0; for (i = 0; i < size; i++) { if (v[i] < table_size) self->tableCodes[j++] = v[i]; @@ -488,16 +371,16 @@ static int get_table_codes(grib_accessor* a) grib_context_free(a->context, v); self->tableCodesSize = count; - self->dirty = 0; + self->dirty = 0; return 0; } -static int value_count(grib_accessor* a, long* count) +int grib_accessor_class_smart_table_t::value_count(grib_accessor* a, long* count) { - int err = 0; - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; - *count = 0; + int err = 0; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; + *count = 0; if (!self->values) return 0; @@ -509,31 +392,33 @@ static int value_count(grib_accessor* a, long* count) return GRIB_SUCCESS; } -static void destroy(grib_context* context, grib_accessor* a) +void grib_accessor_class_smart_table_t::destroy(grib_context* context, grib_accessor* a) { - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; if (a->vvalue != NULL) { grib_context_free(context, a->vvalue); a->vvalue = NULL; } if (self->tableCodes) grib_context_free(a->context, self->tableCodes); + + grib_accessor_class_unsigned_t::destroy(context, a); } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_smart_table_t::get_native_type(grib_accessor* a) { int type = GRIB_TYPE_LONG; - /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", - a->name,a->flags,GRIB_ACCESSOR_FLAG_STRING_TYPE);*/ + //printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", + // a->name,a->flags,GRIB_ACCESSOR_FLAG_STRING_TYPE); if (a->flags & GRIB_ACCESSOR_FLAG_STRING_TYPE) type = GRIB_TYPE_STRING; return type; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_smart_table_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - int err = 0; - grib_accessor_smart_table* self = (grib_accessor_smart_table*)a; + int err = 0; + grib_accessor_smart_table_t* self = (grib_accessor_smart_table_t*)a; size_t i; if (!self->values) @@ -545,8 +430,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) if (*len < self->tableCodesSize) { grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size (%lu) for %s it contains %lu values", *len, a->name, self->tableCodesSize); - *len = 0; + "Wrong size (%zu) for %s, it contains %zu values", *len, a->name, self->tableCodesSize); + *len = self->tableCodesSize; return GRIB_ARRAY_TOO_SMALL; } diff --git a/src/accessor/grib_accessor_class_smart_table.h b/src/accessor/grib_accessor_class_smart_table.h new file mode 100644 index 000000000..c7aaf0827 --- /dev/null +++ b/src/accessor/grib_accessor_class_smart_table.h @@ -0,0 +1,44 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_unsigned.h" +#include + +class grib_accessor_smart_table_t : public grib_accessor_unsigned_t +{ +public: + const char* values; + const char* tablename; + const char* masterDir; + const char* localDir; + const char* extraDir; + const char* extraTable; + int widthOfCode; + long* tableCodes; + size_t tableCodesSize; + grib_smart_table* table; + int dirty; +}; + +class grib_accessor_class_smart_table_t : public grib_accessor_class_unsigned_t +{ +public: + grib_accessor_class_smart_table_t(const char* name) : grib_accessor_class_unsigned_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_smart_table_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_smart_table_column.cc b/src/accessor/grib_accessor_class_smart_table_column.cc new file mode 100644 index 000000000..7d352471d --- /dev/null +++ b/src/accessor/grib_accessor_class_smart_table_column.cc @@ -0,0 +1,179 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_smart_table_column.h" +#include "grib_accessor_class_smart_table.h" + +grib_accessor_class_smart_table_column_t _grib_accessor_class_smart_table_column{"smart_table_column"}; +grib_accessor_class* grib_accessor_class_smart_table_column = &_grib_accessor_class_smart_table_column; + + + +void grib_accessor_class_smart_table_column_t::init(grib_accessor* a, const long len, grib_arguments* params){ + grib_accessor_class_gen_t::init(a, len, params); + int n = 0; + grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; + + self->smartTable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), params, n++); + + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_smart_table_column_t::dump(grib_accessor* a, grib_dumper* dumper){ + int type = get_native_type(a); + + switch (type) { + case GRIB_TYPE_LONG: + grib_dump_long(dumper, a, NULL); + break; + case GRIB_TYPE_STRING: + grib_dump_string_array(dumper, a, NULL); + break; + } +} + +int grib_accessor_class_smart_table_column_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ + grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; + grib_accessor_smart_table_t* tableAccessor = NULL; + grib_smart_table* table = NULL; + + size_t size = 1; + long* code; + int err = GRIB_SUCCESS; + char tmp[1024] = {0,}; + int i = 0; + + tableAccessor = (grib_accessor_smart_table_t*)grib_find_accessor(grib_handle_of_accessor(a), self->smartTable); + if (!tableAccessor) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Unable to find accessor %s", self->smartTable); + return GRIB_NOT_FOUND; + } + + err = grib_get_size_acc(grib_handle_of_accessor(a), (grib_accessor*)tableAccessor, &size); + if (err) + return err; + if (*len < size) { + return GRIB_BUFFER_TOO_SMALL; + } + + code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); + if (!code) { + grib_context_log(a->context, GRIB_LOG_FATAL, "%s: Memory allocation error: %zu bytes", a->name, size); + return GRIB_OUT_OF_MEMORY; + } + + if ((err = ((grib_accessor*)tableAccessor)->unpack_long(code, &size)) != GRIB_SUCCESS) + return err; + + table = tableAccessor->table; + + for (i = 0; i < size; i++) { + if (table && (code[i] >= 0) && + (code[i] < table->numberOfEntries) && + table->entries[code[i]].column[self->index]) { + strcpy(tmp, table->entries[code[i]].column[self->index]); + } + else { + snprintf(tmp, sizeof(tmp), "%d", (int)code[i]); + } + + buffer[i] = grib_context_strdup(a->context, tmp); + } + *len = size; + grib_context_free(a->context, code); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_smart_table_column_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; + grib_accessor_smart_table_t* tableAccessor = NULL; + grib_smart_table* table = NULL; + + size_t size = 1; + long* code; + int err = GRIB_SUCCESS; + int i = 0; + + for (i = 0; i < *len; i++) + val[i] = GRIB_MISSING_LONG; + + tableAccessor = (grib_accessor_smart_table_t*)grib_find_accessor(grib_handle_of_accessor(a), self->smartTable); + if (!tableAccessor) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Unable to find accessor %s", self->smartTable); + return GRIB_NOT_FOUND; + } + + err = grib_get_size_acc(grib_handle_of_accessor(a), (grib_accessor*)tableAccessor, &size); + if (err) + return err; + if (*len < size) { + return GRIB_BUFFER_TOO_SMALL; + } + + code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); + if (!code) return GRIB_OUT_OF_MEMORY; + + if ((err = ((grib_accessor*)tableAccessor)->unpack_long(code, &size)) != GRIB_SUCCESS) { + grib_context_free(a->context, code); + return err; + } + + table = tableAccessor->table; + + for (i = 0; i < size; i++) { + if (table && (code[i] >= 0) && + (code[i] < table->numberOfEntries) && + table->entries[code[i]].column[self->index]) { + val[i] = atol(table->entries[code[i]].column[self->index]); + } + } + *len = size; + grib_context_free(a->context, code); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_smart_table_column_t::value_count(grib_accessor* a, long* count){ + grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; + size_t size = 0; + int err = 0; + *count = 0; + + if (!self->smartTable) + return 0; + + err = grib_get_size(grib_handle_of_accessor(a), self->smartTable, &size); + *count = size; + return err; +} + +void grib_accessor_class_smart_table_column_t::destroy(grib_context* context, grib_accessor* a){ + if (a->vvalue != NULL) { + grib_context_free(context, a->vvalue); + a->vvalue = NULL; + } + + grib_accessor_class_gen_t::destroy(context, a); +} + +int grib_accessor_class_smart_table_column_t::get_native_type(grib_accessor* a){ + int type = GRIB_TYPE_LONG; + /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", + a->name,a->flags,GRIB_ACCESSOR_FLAG_STRING_TYPE);*/ + if (a->flags & GRIB_ACCESSOR_FLAG_STRING_TYPE) + type = GRIB_TYPE_STRING; + return type; +} diff --git a/src/accessor/grib_accessor_class_smart_table_column.h b/src/accessor/grib_accessor_class_smart_table_column.h new file mode 100644 index 000000000..9e1edcd2a --- /dev/null +++ b/src/accessor/grib_accessor_class_smart_table_column.h @@ -0,0 +1,35 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_smart_table_column_t : public grib_accessor_gen_t +{ +public: + const char* smartTable; + int index; +}; + +class grib_accessor_class_smart_table_column_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_smart_table_column_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_smart_table_column_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_spd.cc b/src/accessor/grib_accessor_class_spd.cc new file mode 100644 index 000000000..dd717ba3c --- /dev/null +++ b/src/accessor/grib_accessor_class_spd.cc @@ -0,0 +1,155 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_spd.h" + +grib_accessor_class_spd_t _grib_accessor_class_spd{"spd"}; +grib_accessor_class* grib_accessor_class_spd = &_grib_accessor_class_spd; + + +long grib_accessor_class_spd_t::byte_count(grib_accessor* a){ + return a->length; +} + +static long compute_byte_count(grib_accessor* a){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + long numberOfBits = 0; + long numberOfElements = 0; + + int ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfBits); + return 0; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + return 0; + } + numberOfElements++; + + return (numberOfBits * numberOfElements + 7) / 8; +} + +void grib_accessor_class_spd_t::init(grib_accessor* a, const long len, grib_arguments* args){ + grib_accessor_class_long_t::init(a, len, args); + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + int n = 0; + self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->length = compute_byte_count(a); +} + +int grib_accessor_class_spd_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + long pos = a->offset * 8; + long rlen = 0; + long numberOfBits = 0; + + int ret = value_count(a, &rlen); + if (ret) + return ret; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); + *len = rlen; + return GRIB_ARRAY_TOO_SMALL; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + if (numberOfBits > 64) { + grib_context_log(a->context, GRIB_LOG_ERROR,"Invalid number of bits: %ld",numberOfBits); + return GRIB_DECODING_ERROR; + } + + for (long i = 0; i < rlen - 1; i++) + val[i] = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); + + val[rlen - 1] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); + + *len = rlen; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_spd_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + int ret = 0; + long off = 0; + long numberOfBits = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + long rlen = 0; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (*len != rlen) { + ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, (*len) - 1); + if (ret) return ret; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + + buflen = compute_byte_count(a); + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); + + for (i = 0; i < rlen - 1; i++) { + grib_encode_unsigned_longb(buf, val[i], &off, numberOfBits); + } + + grib_encode_signed_longb(buf, val[rlen - 1], &off, numberOfBits); + + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_free(a->context, buf); + + *len = rlen; + return ret; +} + +int grib_accessor_class_spd_t::value_count(grib_accessor* a, long* numberOfElements){ + grib_accessor_spd_t* self = (grib_accessor_spd_t*)a; + int ret; + *numberOfElements = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + return ret; + } + (*numberOfElements)++; + + return ret; +} + +long grib_accessor_class_spd_t::byte_offset(grib_accessor* a){ + return a->offset; +} + +void grib_accessor_class_spd_t::update_size(grib_accessor* a, size_t s){ + a->length = s; +} + +long grib_accessor_class_spd_t::next_offset(grib_accessor* a){ + return a->byte_offset() + a->length; +} diff --git a/src/accessor/grib_accessor_class_spd.h b/src/accessor/grib_accessor_class_spd.h new file mode 100644 index 000000000..ee4fa5d12 --- /dev/null +++ b/src/accessor/grib_accessor_class_spd.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_spd_t : public grib_accessor_long_t +{ +public: + /* Members defined in spd */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_spd_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_spd_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_spd_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; diff --git a/src/accessor/grib_accessor_class_spectral_truncation.cc b/src/accessor/grib_accessor_class_spectral_truncation.cc new file mode 100644 index 000000000..2fc45511f --- /dev/null +++ b/src/accessor/grib_accessor_class_spectral_truncation.cc @@ -0,0 +1,81 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_spectral_truncation.h" + +grib_accessor_class_spectral_truncation_t _grib_accessor_class_spectral_truncation{"spectral_truncation"}; +grib_accessor_class* grib_accessor_class_spectral_truncation = &_grib_accessor_class_spectral_truncation; + + +void grib_accessor_class_spectral_truncation_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_spectral_truncation_t* self = (grib_accessor_spectral_truncation_t*)a; + int n = 0; + + self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->K = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->M = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->T = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_spectral_truncation_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_spectral_truncation_t* self = (grib_accessor_spectral_truncation_t*)a; + int ret = 0; + + long J, K, M, T, Tc; + + if (*len < 1) + return GRIB_ARRAY_TOO_SMALL; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->J, &J)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->K, &K)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->M, &M)) != GRIB_SUCCESS) + return ret; + + Tc = -1; + if (J == K && K == M) { + /* Triangular truncation */ + Tc = (M + 1) * (M + 2); + } + if (K == J + M) { + /* Rhomboidal truncation */ + Tc = 2 * J * M; + } + if (J == K && K > M) { + /* Trapezoidal truncation */ + Tc = M * (2 * J - M); + } + *val = Tc; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->T, &T)) != GRIB_SUCCESS) { + if (Tc == -1) + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s. Spectral Truncation Type Unknown: %s=%ld %s=%ld %s=%ld", + a->name, self->J, J, self->K, K, self->M, M); + Tc = 0; + grib_set_long(grib_handle_of_accessor(a), self->T, Tc); + } + else { + if (Tc != -1 && Tc != T) + grib_set_long(grib_handle_of_accessor(a), self->T, Tc); + } + + if (ret == GRIB_SUCCESS) + *len = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_spectral_truncation.h b/src/accessor/grib_accessor_class_spectral_truncation.h new file mode 100644 index 000000000..c9f85b9f8 --- /dev/null +++ b/src/accessor/grib_accessor_class_spectral_truncation.h @@ -0,0 +1,33 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_spectral_truncation_t : public grib_accessor_long_t +{ +public: + /* Members defined in spectral_truncation */ + const char* J; + const char* K; + const char* M; + const char* T; +}; + +class grib_accessor_class_spectral_truncation_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_spectral_truncation_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_spectral_truncation_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_sprintf.cc b/src/accessor/grib_accessor_class_sprintf.cc similarity index 54% rename from src/grib_accessor_class_sprintf.cc rename to src/accessor/grib_accessor_class_sprintf.cc index 106ce1e4d..cc9e37e6a 100644 --- a/src/grib_accessor_class_sprintf.cc +++ b/src/accessor/grib_accessor_class_sprintf.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,109 +9,21 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string;value_count - IMPLEMENTS = init;string_length - MEMBERS= grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_sprintf -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in sprintf */ - grib_arguments* args; -} grib_accessor_sprintf; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_sprintf = { - &grib_accessor_class_ascii, /* super */ - "sprintf", /* name */ - sizeof(grib_accessor_sprintf), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_sprintf.h" +grib_accessor_class_sprintf_t _grib_accessor_class_sprintf{"sprintf"}; grib_accessor_class* grib_accessor_class_sprintf = &_grib_accessor_class_sprintf; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_sprintf* self = (grib_accessor_sprintf*)a; +void grib_accessor_class_sprintf_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_ascii_t::init(a, l, c); + grib_accessor_sprintf_t* self = (grib_accessor_sprintf_t*)a; self->args = c; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_sprintf* self = (grib_accessor_sprintf*)a; +int grib_accessor_class_sprintf_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_sprintf_t* self = (grib_accessor_sprintf_t*)a; char result[1024]; char tempBuffer[2048]; char sres[1024]; @@ -148,8 +61,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), tempname, &ires)) != GRIB_SUCCESS) return ret; /* Bug GRIB-56: Check to see if the key is missing */ - is_missing = grib_is_missing(grib_handle_of_accessor(a), tempname, &ret); - if (ret != GRIB_SUCCESS) + is_missing = grib_is_missing(grib_handle_of_accessor(a), tempname, &ret); if (ret != GRIB_SUCCESS) return ret; if (is_missing) { snprintf(tempBuffer, sizeof(tempBuffer), "%sMISSING", result); @@ -205,13 +117,11 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int value_count(grib_accessor* a, long* count) -{ +int grib_accessor_class_sprintf_t::value_count(grib_accessor* a, long* count){ *count = 1; return 0; } -static size_t string_length(grib_accessor* a) -{ +size_t grib_accessor_class_sprintf_t::string_length(grib_accessor* a){ return 1024; } diff --git a/src/accessor/grib_accessor_class_sprintf.h b/src/accessor/grib_accessor_class_sprintf.h new file mode 100644 index 000000000..36d5f3e10 --- /dev/null +++ b/src/accessor/grib_accessor_class_sprintf.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_sprintf_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in sprintf */ + grib_arguments* args; +}; + +class grib_accessor_class_sprintf_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_sprintf_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sprintf_t{}; } + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_statistics.cc b/src/accessor/grib_accessor_class_statistics.cc similarity index 55% rename from src/grib_accessor_class_statistics.cc rename to src/accessor/grib_accessor_class_statistics.cc index 915701a3a..2d5cfd756 100644 --- a/src/grib_accessor_class_statistics.cc +++ b/src/accessor/grib_accessor_class_statistics.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,116 +9,15 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_vector - IMPLEMENTS = unpack_double; destroy - IMPLEMENTS = unpack_string - IMPLEMENTS = value_count;compare - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* missing_value - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_statistics -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; - /* Members defined in statistics */ - const char* values; - const char* missing_value; -} grib_accessor_statistics; - -extern grib_accessor_class* grib_accessor_class_abstract_vector; - -static grib_accessor_class _grib_accessor_class_statistics = { - &grib_accessor_class_abstract_vector, /* super */ - "statistics", /* name */ - sizeof(grib_accessor_statistics), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +#include "grib_accessor_class_statistics.h" +grib_accessor_class_statistics_t _grib_accessor_class_statistics{"statistics"}; grib_accessor_class* grib_accessor_class_statistics = &_grib_accessor_class_statistics; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_statistics* self = (grib_accessor_statistics*)a; +void grib_accessor_class_statistics_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_abstract_vector_t::init(a, l, c); + grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; int n = 0; self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -134,9 +34,8 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) a->dirty = 1; } -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_statistics* self = (grib_accessor_statistics*)a; +int grib_accessor_class_statistics_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; int ret = 0; double* values = NULL; size_t i = 0, size = 0, real_size = 0; @@ -157,7 +56,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_statistics: computing statistics for %d values", size); + "grib_accessor_statistics_t: computing statistics for %d values", size); if ((ret = grib_get_double(h, self->missing_value, &missing)) != GRIB_SUCCESS) return ret; @@ -267,21 +166,19 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len) return ret; } -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_statistics* self = (grib_accessor_statistics*)a; +int grib_accessor_class_statistics_t::value_count(grib_accessor* a, long* count){ + grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; *count = self->number_of_elements; return 0; } -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_statistics* self = (grib_accessor_statistics*)a; +void grib_accessor_class_statistics_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; grib_context_free(c, self->v); + grib_accessor_class_abstract_vector_t::destroy(c, a); } -static int compare(grib_accessor* a, grib_accessor* b) -{ +int grib_accessor_class_statistics_t::compare(grib_accessor* a, grib_accessor* b){ int retval = GRIB_SUCCESS; double* aval = 0; double* bval = 0; @@ -291,13 +188,11 @@ static int compare(grib_accessor* a, grib_accessor* b) int err = 0; long count = 0; - err = grib_value_count(a, &count); - if (err) + err = a->value_count(&count); if (err) return err; alen = count; - err = grib_value_count(b, &count); - if (err) + err = b->value_count(&count); if (err) return err; blen = count; @@ -310,9 +205,7 @@ static int compare(grib_accessor* a, grib_accessor* b) b->dirty = 1; a->dirty = 1; - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); retval = GRIB_SUCCESS; for (size_t i=0; ivalues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->K = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->M = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->JS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + + self->number_of_elements = 4; + self->v = (double*)grib_context_malloc(a->context, + sizeof(double) * self->number_of_elements); + + a->length = 0; + a->dirty = 1; +} + +int grib_accessor_class_statistics_spectral_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; + int ret = 0, i = 0; + double* values; + size_t size = 0; + long J, K, M, N; + double avg, enorm, sd; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); + + if (!a->dirty) + return GRIB_SUCCESS; + + if (*len != self->number_of_elements) + return GRIB_ARRAY_TOO_SMALL; + + if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long(grib_handle_of_accessor(a), self->J, &J)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long(grib_handle_of_accessor(a), self->K, &K)) != GRIB_SUCCESS) + return ret; + + if ((ret = grib_get_long(grib_handle_of_accessor(a), self->M, &M)) != GRIB_SUCCESS) + return ret; + + if (J != M || M != K) + return GRIB_NOT_IMPLEMENTED; + + N = (M + 1) * (M + 2) / 2; + + if (2 * N != size) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "wrong number of components for spherical harmonics %ld != %ld", 2 * N, size); + return GRIB_WRONG_ARRAY_SIZE; + } + + values = (double*)grib_context_malloc(c, size * sizeof(double)); + if (!values) + return GRIB_OUT_OF_MEMORY; + + if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { + grib_context_free(c, values); + return ret; + } + + avg = values[0]; + sd = 0; + + for (i = 2; i < 2 * J; i += 2) + sd += values[i] * values[i]; + + for (i = 2 * J; i < size; i += 2) + sd += 2 * values[i] * values[i] + 2 * values[i + 1] * values[i + 1]; + + enorm = sd + avg * avg; + + sd = sqrt(sd); + enorm = sqrt(enorm); + + a->dirty = 0; + + grib_context_free(c, values); + + self->v[0] = avg; + self->v[1] = enorm; + self->v[2] = sd; + self->v[3] = sd == 0 ? 1 : 0; + + for (i = 0; i < self->number_of_elements; i++) + val[i] = self->v[i]; + + return ret; +} + +int grib_accessor_class_statistics_spectral_t::value_count(grib_accessor* a, long* count){ + grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; + *count = self->number_of_elements; + return 0; +} + +void grib_accessor_class_statistics_spectral_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; + grib_context_free(c, self->v); + grib_accessor_class_abstract_vector_t::destroy(c, a); +} + +int grib_accessor_class_statistics_spectral_t::compare(grib_accessor* a, grib_accessor* b){ + int retval = GRIB_SUCCESS; + double* aval = 0; + double* bval = 0; + + size_t alen = 0; + size_t blen = 0; + int err = 0; + long count = 0; + + err = a->value_count(&count); if (err) + return err; + alen = count; + + err = b->value_count(&count); if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + b->dirty = 1; + a->dirty = 1; + + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + retval = GRIB_SUCCESS; + for (size_t i=0; icontext, aval); + grib_context_free(b->context, bval); + + return retval; +} diff --git a/src/accessor/grib_accessor_class_statistics_spectral.h b/src/accessor/grib_accessor_class_statistics_spectral.h new file mode 100644 index 000000000..41846c5c7 --- /dev/null +++ b/src/accessor/grib_accessor_class_statistics_spectral.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_statistics_spectral_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in statistics_spectral */ + const char* values; + const char* J; + const char* K; + const char* M; + const char* JS; +}; + +class grib_accessor_class_statistics_spectral_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_statistics_spectral_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_statistics_spectral_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_step_human_readable.cc b/src/accessor/grib_accessor_class_step_human_readable.cc new file mode 100644 index 000000000..18dec9c14 --- /dev/null +++ b/src/accessor/grib_accessor_class_step_human_readable.cc @@ -0,0 +1,87 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_step_human_readable.h" + +grib_accessor_class_step_human_readable_t _grib_accessor_class_step_human_readable{ "step_human_readable" }; +grib_accessor_class* grib_accessor_class_step_human_readable = &_grib_accessor_class_step_human_readable; + + +void grib_accessor_class_step_human_readable_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ + grib_accessor_class_gen_t::init(a, len, params); + grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; + int n = 0; + grib_handle* h = grib_handle_of_accessor(a); + + self->stepUnits = grib_arguments_get_name(h, params, n++); + self->step = grib_arguments_get_name(h, params, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_step_human_readable_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_STRING; +} + +static int get_step_human_readable(grib_handle* h, char* result, size_t* length) +{ + int err = 0; + size_t slen = 2; + long step, hour, minute, second; + + /* Change units to seconds (highest resolution) + * before computing the step value + */ + if ((err = grib_set_string(h, "stepUnits", "s", &slen)) != GRIB_SUCCESS) + return err; + if ((err = grib_get_long(h, "step", &step)) != GRIB_SUCCESS) + return err; + + hour = step / 3600; + minute = step / 60 % 60; + second = step % 60; + /* sprintf(result, "%ld:%ld:%ld", hour, minute, second); */ + + if (second) { + snprintf(result, 1024, "%ldh %ldm %lds", hour, minute, second); + } + else { + if (minute) + snprintf(result, 1024, "%ldh %ldm", hour, minute); + else + snprintf(result, 1024, "%ldh", hour); + } + + *length = strlen(result); + return GRIB_SUCCESS; +} + +int grib_accessor_class_step_human_readable_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ + grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; + + grib_handle* h = grib_handle_of_accessor(a); + long stepUnits = 0; + int err = 0; + + /* Save the current value of stepUnits */ + err = grib_get_long_internal(h, self->stepUnits, &stepUnits); + if (err) return err; + + /* This will change stepUnits to seconds for its calculation */ + err = get_step_human_readable(h, buffer, len); + + /* Restore stepUnits */ + grib_set_long(h, self->stepUnits, stepUnits); + return err; +} diff --git a/src/accessor/grib_accessor_class_step_human_readable.h b/src/accessor/grib_accessor_class_step_human_readable.h new file mode 100644 index 000000000..cbd61ed31 --- /dev/null +++ b/src/accessor/grib_accessor_class_step_human_readable.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_step_human_readable_t : public grib_accessor_gen_t +{ +public: + /* Members defined in step_human_readable */ + const char* stepUnits; + const char* step; +}; + +class grib_accessor_class_step_human_readable_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_step_human_readable_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_step_human_readable_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_step_in_units.cc b/src/accessor/grib_accessor_class_step_in_units.cc similarity index 63% rename from src/grib_accessor_class_step_in_units.cc rename to src/accessor/grib_accessor_class_step_in_units.cc index a25c85aec..52086d700 100644 --- a/src/grib_accessor_class_step_in_units.cc +++ b/src/accessor/grib_accessor_class_step_in_units.cc @@ -1,3 +1,4 @@ + /* * (C) Copyright 2005- ECMWF. * @@ -8,121 +9,18 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" +#include "grib_accessor_class_step_in_units.h" #include "step.h" #include "step_utilities.h" #include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = init;dump - IMPLEMENTS = get_native_type - MEMBERS = const char* forecast_time_value - MEMBERS = const char* forecast_time_unit - MEMBERS = const char* step_units - MEMBERS = const char* time_range_unit - MEMBERS = const char* time_range_value - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_step_in_units -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in step_in_units */ - const char* forecast_time_value; - const char* forecast_time_unit; - const char* step_units; - const char* time_range_unit; - const char* time_range_value; -} grib_accessor_step_in_units; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_step_in_units = { - &grib_accessor_class_long, /* super */ - "step_in_units", /* name */ - sizeof(grib_accessor_step_in_units), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - +grib_accessor_class_step_in_units_t _grib_accessor_class_step_in_units{"step_in_units"}; grib_accessor_class* grib_accessor_class_step_in_units = &_grib_accessor_class_step_in_units; -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) +void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, grib_arguments* c) { - grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* hand = grib_handle_of_accessor(a); int n = 0; @@ -133,14 +31,14 @@ static void init(grib_accessor* a, const long l, grib_arguments* c) self->time_range_value = grib_arguments_get_name(hand, c, n++); } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_step_in_units_t::dump(grib_accessor* a, grib_dumper* dumper) { grib_dump_double(dumper, a, NULL); } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_step_in_units_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - const grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; + const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; int err = 0; long forecast_time_value, forecast_time_unit, step_units; grib_handle* h = grib_handle_of_accessor(a); @@ -169,9 +67,9 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_double(grib_accessor* a, double * val, size_t* len) +int grib_accessor_class_step_in_units_t::unpack_double(grib_accessor* a, double * val, size_t* len) { - const grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; + const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; int err = 0; long forecast_time_value, forecast_time_unit, step_units; grib_handle* h = grib_handle_of_accessor(a); @@ -199,9 +97,9 @@ static int unpack_double(grib_accessor* a, double * val, size_t* len) return GRIB_SUCCESS; } -static int pack_long_new_(grib_accessor* a, const long start_step_value, const long start_step_unit, const long force_step_units) +int pack_long_new_(grib_accessor* a, const long start_step_value, const long start_step_unit, const long force_step_units) { - const grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; + const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); int err = 0; long forecast_time_unit; @@ -211,7 +109,7 @@ static int pack_long_new_(grib_accessor* a, const long start_step_value, const l if ((err = grib_get_long_internal(h, self->forecast_time_unit, &forecast_time_unit)) != GRIB_SUCCESS) return err; - if ((err = unpack_long(a, &start_step_value_old, &len)) != GRIB_SUCCESS) + if ((err = a->unpack_long(&start_step_value_old, &len)) != GRIB_SUCCESS) return err; if ((err = grib_get_long_internal(h, "startStepUnit", &start_step_unit_old)) != GRIB_SUCCESS) return err; @@ -249,7 +147,7 @@ static int pack_long_new_(grib_accessor* a, const long start_step_value, const l return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_step_in_units_t::pack_long(grib_accessor* a, const long* val, size_t* len) { grib_handle* h = grib_handle_of_accessor(a); int ret = GRIB_SUCCESS; @@ -281,7 +179,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len) return ret; } -static int pack_string(grib_accessor* a, const char* val, size_t* len) +int grib_accessor_class_step_in_units_t::pack_string(grib_accessor* a, const char* val, size_t* len) { grib_handle* h = grib_handle_of_accessor(a); //long force_step_units = eccodes::Unit(eccodes::Unit::Value::MISSING).value(); @@ -303,9 +201,9 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len) return GRIB_SUCCESS; } -static int unpack_string(grib_accessor* a, char* val, size_t* len) +int grib_accessor_class_step_in_units_t::unpack_string(grib_accessor* a, char* val, size_t* len) { - const grib_accessor_step_in_units* self = (grib_accessor_step_in_units*)a; + const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = GRIB_SUCCESS; long start_step_value = 0; @@ -347,7 +245,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len) return GRIB_SUCCESS; } -static int get_native_type(grib_accessor* a) +int grib_accessor_class_step_in_units_t::get_native_type(grib_accessor* a) { grib_handle* h = grib_handle_of_accessor(a); const int show_units_for_hours = a->context->grib_hourly_steps_with_units; diff --git a/src/accessor/grib_accessor_class_step_in_units.h b/src/accessor/grib_accessor_class_step_in_units.h new file mode 100644 index 000000000..66f4b2b44 --- /dev/null +++ b/src/accessor/grib_accessor_class_step_in_units.h @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_step_in_units_t : public grib_accessor_long_t +{ +public: + /* Members defined in step_in_units */ + const char* forecast_time_value; + const char* forecast_time_unit; + const char* step_units; + const char* time_range_unit; + const char* time_range_value; +}; + +class grib_accessor_class_step_in_units_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_step_in_units_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_step_in_units_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_sum.cc b/src/accessor/grib_accessor_class_sum.cc new file mode 100644 index 000000000..39b96854f --- /dev/null +++ b/src/accessor/grib_accessor_class_sum.cc @@ -0,0 +1,107 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_sum.h" + +grib_accessor_class_sum_t _grib_accessor_class_sum{"sum"}; +grib_accessor_class* grib_accessor_class_sum = &_grib_accessor_class_sum; + + +void grib_accessor_class_sum_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_double_t::init(a, l, c); + grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; + int n = 0; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_sum_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; + int ret = 0; + size_t size = 0; + long* values = 0; + long i; + long count = 0; + + ret = value_count(a, &count); + if (ret) + return ret; + size = count; + + if (size == 0) { + *val = 0; + return GRIB_SUCCESS; + } + values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); + if (!values) + return GRIB_OUT_OF_MEMORY; + + grib_get_long_array(grib_handle_of_accessor(a), self->values, values, &size); + + *val = 0; + for (i = 0; i < size; i++) + *val += values[i]; + + grib_context_free(a->context, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_sum_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; + int ret = 0; + size_t size = 0; + double* values = 0; + long i; + long count = 0; + + ret = value_count(a, &count); + if (ret) + return ret; + size = count; + + if (size == 0) { + *val = 0; + return GRIB_SUCCESS; + } + values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); + if (!values) + return GRIB_OUT_OF_MEMORY; + + ret = grib_get_double_array(grib_handle_of_accessor(a), self->values, values, &size); + if (ret) { + grib_context_free(a->context, values); + return ret; + } + *val = 0; + for (i = 0; i < size; i++) + *val += values[i]; + + grib_context_free(a->context, values); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_sum_t::value_count(grib_accessor* a, long* count){ + grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; + size_t n = 0; + int ret = 0; + + ret = grib_get_size(grib_handle_of_accessor(a), self->values, &n); + *count = n; + + if (ret) + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s is unable to get size of %s", a->name, self->values); + + return ret; +} diff --git a/src/accessor/grib_accessor_class_sum.h b/src/accessor/grib_accessor_class_sum.h new file mode 100644 index 000000000..5667d8da9 --- /dev/null +++ b/src/accessor/grib_accessor_class_sum.h @@ -0,0 +1,32 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_double.h" + +class grib_accessor_sum_t : public grib_accessor_double_t +{ +public: + /* Members defined in sum */ + const char* values; +}; + +class grib_accessor_class_sum_t : public grib_accessor_class_double_t +{ +public: + grib_accessor_class_sum_t(const char* name) : grib_accessor_class_double_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_sum_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_suppressed.cc b/src/accessor/grib_accessor_class_suppressed.cc new file mode 100644 index 000000000..10a99ee64 --- /dev/null +++ b/src/accessor/grib_accessor_class_suppressed.cc @@ -0,0 +1,72 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_suppressed.h" + +grib_accessor_class_suppressed_t _grib_accessor_class_suppressed{ "suppressed" }; +grib_accessor_class* grib_accessor_class_suppressed = &_grib_accessor_class_suppressed; + + +void grib_accessor_class_suppressed_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_suppressed_t* self = (grib_accessor_suppressed_t*)a; + self->args = c; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +static void log_message(grib_accessor* a) +{ + grib_accessor_suppressed_t* self = (grib_accessor_suppressed_t*)a; + int i = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_context_log(a->context, GRIB_LOG_ERROR, + "key '%s' is unavailable in this version.", a->name); + grib_context_log(a->context, GRIB_LOG_ERROR, + "Please use the following key(s):"); + while (grib_arguments_get_name(hand, self->args, i)) { + grib_context_log(a->context, GRIB_LOG_ERROR, "\t- %s", + grib_arguments_get_name(hand, self->args, i)); + i++; + } +} + +int grib_accessor_class_suppressed_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + log_message(a); + return GRIB_NOT_FOUND; +} + +int grib_accessor_class_suppressed_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + log_message(a); + return GRIB_NOT_FOUND; +} + +int grib_accessor_class_suppressed_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + log_message(a); + return GRIB_NOT_FOUND; +} + +int grib_accessor_class_suppressed_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +int grib_accessor_class_suppressed_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_STRING; +} diff --git a/src/accessor/grib_accessor_class_suppressed.h b/src/accessor/grib_accessor_class_suppressed.h new file mode 100644 index 000000000..5d764be35 --- /dev/null +++ b/src/accessor/grib_accessor_class_suppressed.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_suppressed_t : public grib_accessor_long_t +{ +public: + /* Members defined in suppressed */ + grib_arguments* args; +}; + +class grib_accessor_class_suppressed_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_suppressed_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_suppressed_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_time.cc b/src/accessor/grib_accessor_class_time.cc new file mode 100644 index 000000000..debb1a2f4 --- /dev/null +++ b/src/accessor/grib_accessor_class_time.cc @@ -0,0 +1,113 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_time.h" + +grib_accessor_class_time_t _grib_accessor_class_time{"time"}; +grib_accessor_class* grib_accessor_class_time = &_grib_accessor_class_time; + + +void grib_accessor_class_time_t::init(grib_accessor* a, const long l, grib_arguments* c){ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_time_t* self = (grib_accessor_time_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->hour = grib_arguments_get_name(hand, c, n++); + self->minute = grib_arguments_get_name(hand, c, n++); + self->second = grib_arguments_get_name(hand, c, n++); +} + +int grib_accessor_class_time_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + const grib_accessor_time_t* self = (grib_accessor_time_t*)a; + + int ret = 0; + long hour = 0, minute = 0, second = 0; + grib_handle* hand = grib_handle_of_accessor(a); + + if ((ret = grib_get_long_internal(hand, self->hour, &hour)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->minute, &minute)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->second, &second)) != GRIB_SUCCESS) + return ret; + + /* We ignore the 'seconds' in our time calculation! */ + if (second != 0) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Key %s (%s): Truncating time: non-zero seconds(%ld) ignored", a->name, __func__, second); + } + + if (*len < 1) + return GRIB_WRONG_ARRAY_SIZE; + + *val = hour * 100 + minute; + + if (hour == 255) { + *val = 12 * 100; + } + if (hour != 255 && minute == 255) { + *val = hour * 100; + } + return GRIB_SUCCESS; +} + +int grib_accessor_class_time_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + const grib_accessor_time_t* self = (grib_accessor_time_t*)a; + + int ret = 0; + long v = val[0]; + grib_handle* hand = grib_handle_of_accessor(a); + long hour = 0, minute = 0, second = 0; + + if (*len != 1) + return GRIB_WRONG_ARRAY_SIZE; + + if (!is_time_valid(v)) { + // ECC-1777: For now just a warning. Will later change to an error + fprintf(stderr, "ECCODES WARNING : %s:%s: Time is not valid! hour=%ld min=%ld sec=%ld\n", + a->cclass->name, __func__, hour, minute, second); + // return GRIB_ENCODING_ERROR; + } + + hour = v / 100; + minute = v % 100; + second = 0; /* We ignore the 'seconds' in our time calculation! */ + + if ((ret = grib_set_long_internal(hand, self->hour, hour)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(hand, self->minute, minute)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_set_long_internal(hand, self->second, second)) != GRIB_SUCCESS) + return ret; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_time_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + long v = 0; + size_t lsize = 1, lmin = 5; + + unpack_long(a, &v, &lsize); + + if (*len < lmin) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + a->cclass->name, a->name, lmin, *len); + *len = lmin; + return GRIB_BUFFER_TOO_SMALL; + } + + snprintf(val, 64, "%04ld", v); + + len[0] = lmin; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_time.h b/src/accessor/grib_accessor_class_time.h new file mode 100644 index 000000000..dee0325a9 --- /dev/null +++ b/src/accessor/grib_accessor_class_time.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_time_t : public grib_accessor_long_t +{ +public: + /* Members defined in time */ + const char* hour; + const char* minute; + const char* second; +}; + +class grib_accessor_class_time_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_time_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_time_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_to_double.cc b/src/accessor/grib_accessor_class_to_double.cc new file mode 100644 index 000000000..854a32ffc --- /dev/null +++ b/src/accessor/grib_accessor_class_to_double.cc @@ -0,0 +1,130 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_to_double.h" + +grib_accessor_class_to_double_t _grib_accessor_class_to_double{"to_double"}; +grib_accessor_class* grib_accessor_class_to_double = &_grib_accessor_class_to_double; + + +void grib_accessor_class_to_double_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + + self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); + self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); + self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); + self->scale = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 3); + if (!self->scale) + self->scale = 1; + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_to_double_t::value_count(grib_accessor* a, long* count){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + size_t size = 0; + + int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); + *count = size; + + return err; +} + +size_t grib_accessor_class_to_double_t::string_length(grib_accessor* a){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + size_t size = 0; + + if (self->length) + return self->length; + + grib_get_string_length_acc(a, &size); + return size; +} + +void grib_accessor_class_to_double_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_to_double_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_to_double_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + + int err = 0; + char buff[512] = {0,}; + size_t size = 512; + size_t length = string_length(a); + + if (*len < length + 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", + *len, a->name, a->length + 1); + *len = length + 1; + return GRIB_ARRAY_TOO_SMALL; + } + + err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); + if (err) + return err; + if (length > size) { + err = GRIB_STRING_TOO_SMALL; + length = size; + } + + memcpy(val, buff + self->start, length); + + val[length] = 0; + *len = length; + return err; +} + +int grib_accessor_class_to_double_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + char val[1024] = {0,}; + size_t l = sizeof(val); + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + *v = strtol(val, &last, 10); + if (*last) { + err = GRIB_WRONG_CONVERSION; + } + *v /= self->scale; + + return err; +} + +int grib_accessor_class_to_double_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; + char val[1024] = {0,}; + size_t l = sizeof(val); + char* last = NULL; + int err = a->unpack_string(val, &l); + if (err) + return err; + + *v = strtod(val, &last); + if (*last) { + err = GRIB_WRONG_CONVERSION; + } + *v /= self->scale; + + return err; +} + +long grib_accessor_class_to_double_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_to_double.h b/src/accessor/grib_accessor_class_to_double.h new file mode 100644 index 000000000..c8755c90f --- /dev/null +++ b/src/accessor/grib_accessor_class_to_double.h @@ -0,0 +1,40 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_double_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_double */ + const char* key; + long start; + size_t length; + long scale; +}; + +class grib_accessor_class_to_double_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_double_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_double_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_to_integer.cc b/src/accessor/grib_accessor_class_to_integer.cc new file mode 100644 index 000000000..bc58f31c6 --- /dev/null +++ b/src/accessor/grib_accessor_class_to_integer.cc @@ -0,0 +1,132 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_to_integer.h" + +grib_accessor_class_to_integer_t _grib_accessor_class_to_integer{"to_integer"}; +grib_accessor_class* grib_accessor_class_to_integer = &_grib_accessor_class_to_integer; + + +void grib_accessor_class_to_integer_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; + + self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); + self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); + self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_to_integer_t::value_count(grib_accessor* a, long* count){ + grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; + size_t size = 0; + + int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); + *count = size; + + return err; +} + +size_t grib_accessor_class_to_integer_t::string_length(grib_accessor* a){ + grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; + size_t size = 0; + + if (self->length) + return self->length; + + grib_get_string_length(grib_handle_of_accessor(a), self->key, &size); + return size; +} + +void grib_accessor_class_to_integer_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_long(dumper, a, NULL); +} + +int grib_accessor_class_to_integer_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} + +int grib_accessor_class_to_integer_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; + + int err = 0; + char buff[512] = {0,}; + size_t size = 512; + + size_t length = string_length(a); + + if (*len < length + 1) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, length+1, *len); + *len = length + 1; + return GRIB_BUFFER_TOO_SMALL; + } + + err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); + if (err) + return err; + if (length > size) { + /*err=GRIB_STRING_TOO_SMALL;*/ + length = size; + } + + memcpy(val, buff + self->start, length); + + val[length] = 0; + *len = length; + return GRIB_SUCCESS; +} + +int grib_accessor_class_to_integer_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_to_integer_t::pack_long(grib_accessor* a, const long* v, size_t* len){ + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as an integer", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_to_integer_t::pack_double(grib_accessor* a, const double* v, size_t* len){ + grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as a double", a->name); + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_to_integer_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + char* last = NULL; + int err = unpack_string(a, val, &l); + + if (err) + return err; + + *v = strtol(val, &last, 10); + /* if (*last) {err=GRIB_WRONG_CONVERSION;} */ + + return GRIB_SUCCESS; +} + +int grib_accessor_class_to_integer_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + size_t l = 1; + long val = 0; + int err = unpack_long(a, &val, &l); + + *v = (double)val; + return err; +} + +long grib_accessor_class_to_integer_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_to_integer.h b/src/accessor/grib_accessor_class_to_integer.h new file mode 100644 index 000000000..da8334e4f --- /dev/null +++ b/src/accessor/grib_accessor_class_to_integer.h @@ -0,0 +1,42 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_integer_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_integer */ + const char* key; + long start; + size_t length; +}; + +class grib_accessor_class_to_integer_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_integer_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_integer_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_to_string.cc b/src/accessor/grib_accessor_class_to_string.cc new file mode 100644 index 000000000..4f1150ffb --- /dev/null +++ b/src/accessor/grib_accessor_class_to_string.cc @@ -0,0 +1,120 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_to_string.h" + +grib_accessor_class_to_string_t _grib_accessor_class_to_string{"to_string"}; +grib_accessor_class* grib_accessor_class_to_string = &_grib_accessor_class_to_string; + + +void grib_accessor_class_to_string_t::init(grib_accessor* a, const long len, grib_arguments* arg){ + grib_accessor_class_gen_t::init(a, len, arg); + grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; + + self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); + self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); + self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->length = 0; +} + +int grib_accessor_class_to_string_t::value_count(grib_accessor* a, long* count){ + grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; + size_t size = 0; + + int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); + *count = size; + + return err; +} + +size_t grib_accessor_class_to_string_t::string_length(grib_accessor* a){ + grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; + + if (self->length) + return self->length; + + size_t size = 0; + grib_get_string_length(grib_handle_of_accessor(a), self->key, &size); + return size; +} + +void grib_accessor_class_to_string_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_string(dumper, a, NULL); +} + +int grib_accessor_class_to_string_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_STRING; +} + +int grib_accessor_class_to_string_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; + + int err = 0; + char buff[512] = {0,}; + + size_t length = string_length(a); + + if (*len < length + 1) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, length+1, *len); + *len = length + 1; + return GRIB_BUFFER_TOO_SMALL; + } + + size_t size = sizeof(buff); + err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); + if (err) + return err; + if (length > size) { + /*err=GRIB_STRING_TOO_SMALL;*/ + length = size; + } + + memcpy(val, buff + self->start, length); + + val[length] = 0; + *len = length; + return GRIB_SUCCESS; +} + +int grib_accessor_class_to_string_t::unpack_long(grib_accessor* a, long* v, size_t* len){ + char val[1024] = {0,}; + size_t l = sizeof(val); + char* last = NULL; + int err = unpack_string(a, val, &l); + + if (err) + return err; + + *v = strtol(val, &last, 10); + if (*last) { + err = GRIB_WRONG_CONVERSION; + } + + return err; +} + +int grib_accessor_class_to_string_t::unpack_double(grib_accessor* a, double* v, size_t* len){ + size_t l = 1; + long val = 0; + int err = unpack_long(a, &val, &l); + + *v = (double)val; + return err; +} + +long grib_accessor_class_to_string_t::next_offset(grib_accessor* a){ + return a->offset + a->length; +} diff --git a/src/accessor/grib_accessor_class_to_string.h b/src/accessor/grib_accessor_class_to_string.h new file mode 100644 index 000000000..ea6981276 --- /dev/null +++ b/src/accessor/grib_accessor_class_to_string.h @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_to_string_t : public grib_accessor_gen_t +{ +public: + /* Members defined in to_string */ + const char* key; + long start; + size_t length; +}; + +class grib_accessor_class_to_string_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_to_string_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_to_string_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_transient.cc b/src/accessor/grib_accessor_class_transient.cc new file mode 100644 index 000000000..0cda763d0 --- /dev/null +++ b/src/accessor/grib_accessor_class_transient.cc @@ -0,0 +1,20 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_transient.h" + +grib_accessor_class_transient_t _grib_accessor_class_transient{"transient"}; +grib_accessor_class* grib_accessor_class_transient = &_grib_accessor_class_transient; + + +void grib_accessor_class_transient_t::init(grib_accessor* a, const long l, grib_arguments* args) { + grib_accessor_class_variable_t::init(a, l, args); +} + diff --git a/src/accessor/grib_accessor_class_transient.h b/src/accessor/grib_accessor_class_transient.h new file mode 100644 index 000000000..e330ad686 --- /dev/null +++ b/src/accessor/grib_accessor_class_transient.h @@ -0,0 +1,25 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_variable.h" + +class grib_accessor_transient_t : public grib_accessor_variable_t { +public: +}; + +class grib_accessor_class_transient_t : public grib_accessor_class_variable_t { +public: + void init(grib_accessor* a, const long l, grib_arguments* args) override; + grib_accessor_class_transient_t(const char* name) : grib_accessor_class_variable_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_transient_t{}; } +}; + diff --git a/src/accessor/grib_accessor_class_transient_darray.cc b/src/accessor/grib_accessor_class_transient_darray.cc new file mode 100644 index 000000000..d45ec3478 --- /dev/null +++ b/src/accessor/grib_accessor_class_transient_darray.cc @@ -0,0 +1,112 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_transient_darray.h" + +grib_accessor_class_transient_darray_t _grib_accessor_class_transient_darray{"transient_darray"}; +grib_accessor_class* grib_accessor_class_transient_darray = &_grib_accessor_class_transient_darray; + + +void grib_accessor_class_transient_darray_t::init(grib_accessor* a, const long length, grib_arguments* args){ + grib_accessor_class_gen_t::init(a, length, args); + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + self->arr = NULL; + self->type = GRIB_TYPE_DOUBLE; + a->length = 0; +} + +void grib_accessor_class_transient_darray_t::dump(grib_accessor* a, grib_dumper* dumper){ + grib_dump_double(dumper, a, NULL); +} + +int grib_accessor_class_transient_darray_t::pack_double(grib_accessor* a, const double* val, size_t* len){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + + if (self->arr) + grib_darray_delete(a->context, self->arr); + self->arr = grib_darray_new(a->context, *len, 10); + + for (size_t i = 0; i < *len; i++) + grib_darray_push(a->context, self->arr, val[i]); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_transient_darray_t::pack_long(grib_accessor* a, const long* val, size_t* len){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + + if (self->arr) + grib_darray_delete(a->context, self->arr); + self->arr = grib_darray_new(a->context, *len, 10); + + for (size_t i = 0; i < *len; i++) + grib_darray_push(a->context, self->arr, (double)val[i]); + + return GRIB_SUCCESS; +} + +int grib_accessor_class_transient_darray_t::unpack_double(grib_accessor* a, double* val, size_t* len){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + long count = 0; + + value_count(a, &count); + + if (*len < count) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %ld, required %ld) ", a->name, *len, count); + return GRIB_ARRAY_TOO_SMALL; + } + + *len = count; + for (size_t i = 0; i < *len; i++) + val[i] = self->arr->v[i]; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_transient_darray_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + long count = 0; + + value_count(a, &count); + + if (*len < count) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %ld, required %ld) ", a->name, *len, count); + return GRIB_ARRAY_TOO_SMALL; + } + + *len = count; + for (size_t i = 0; i < *len; i++) + val[i] = (long)self->arr->v[i]; + + return GRIB_SUCCESS; +} + +void grib_accessor_class_transient_darray_t::destroy(grib_context* c, grib_accessor* a){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + if (self->arr) + grib_darray_delete(a->context, self->arr); + grib_accessor_class_gen_t::destroy(c, a); +} + +int grib_accessor_class_transient_darray_t::value_count(grib_accessor* a, long* count){ + grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + if (self->arr) + *count = grib_darray_used_size(self->arr); + else + *count = 0; + + return 0; +} + +int grib_accessor_class_transient_darray_t::get_native_type(grib_accessor* a){ + const grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; + return self->type; +} diff --git a/src/accessor/grib_accessor_class_transient_darray.h b/src/accessor/grib_accessor_class_transient_darray.h new file mode 100644 index 000000000..230dfa1a1 --- /dev/null +++ b/src/accessor/grib_accessor_class_transient_darray.h @@ -0,0 +1,38 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_transient_darray_t : public grib_accessor_gen_t +{ +public: + /* Members defined in transient_darray */ + grib_darray* arr; + int type; +}; + +class grib_accessor_class_transient_darray_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_transient_darray_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_transient_darray_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_trim.cc b/src/accessor/grib_accessor_class_trim.cc new file mode 100644 index 000000000..a7db4f3ff --- /dev/null +++ b/src/accessor/grib_accessor_class_trim.cc @@ -0,0 +1,76 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_trim.h" + +grib_accessor_class_trim_t _grib_accessor_class_trim{"trim"}; +grib_accessor_class* grib_accessor_class_trim = &_grib_accessor_class_trim; + + +void grib_accessor_class_trim_t::init(grib_accessor* a, const long l, grib_arguments* arg){ + grib_accessor_class_ascii_t::init(a, l, arg); + int n = 0; + grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + + self->input = grib_arguments_get_name(h, arg, n++); + self->trim_left = grib_arguments_get_long(h, arg, n++); + self->trim_right= grib_arguments_get_long(h, arg, n++); + DEBUG_ASSERT(self->trim_left == 0 || self->trim_left == 1); + DEBUG_ASSERT(self->trim_right == 0 || self->trim_right == 1); +} + +int grib_accessor_class_trim_t::unpack_string(grib_accessor* a, char* val, size_t* len){ + grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; + + int err = 0; + grib_handle* h = grib_handle_of_accessor(a); + char input[256] = {0,}; + size_t size = sizeof(input) / sizeof(*input); + char* pInput = input; + + err = grib_get_string(h, self->input, input, &size); + if (err) return err; + + string_lrtrim(&pInput, self->trim_left, self->trim_right); + snprintf(val, 1024, "%s", pInput); + size = strlen(val); + *len = size + 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_trim_t::pack_string(grib_accessor* a, const char* val, size_t* len){ + char input[256] = {0,}; + + size_t inputLen = 256; + char buf[256] = {0,}; + char* pBuf = NULL; + int err; + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; + grib_accessor* inputAccesstor = grib_find_accessor(h, self->input); + if (!inputAccesstor) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor for %s not found", self->input); + return GRIB_NOT_FOUND; + } + + if ((err = grib_get_string(h, self->input, input, &inputLen)) != GRIB_SUCCESS) + return err; + + snprintf(buf, sizeof(buf), "%s", val); + pBuf = buf; + string_lrtrim(&pBuf, self->trim_left, self->trim_right); + + return inputAccesstor->pack_string(pBuf, len);} + +size_t grib_accessor_class_trim_t::string_length(grib_accessor* a){ + return 1024; +} diff --git a/src/accessor/grib_accessor_class_trim.h b/src/accessor/grib_accessor_class_trim.h new file mode 100644 index 000000000..d5c029a78 --- /dev/null +++ b/src/accessor/grib_accessor_class_trim.h @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_ascii.h" + +class grib_accessor_trim_t : public grib_accessor_ascii_t +{ +public: + /* Members defined in trim */ + const char* input; + int trim_left; + int trim_right; +}; + +class grib_accessor_class_trim_t : public grib_accessor_class_ascii_t +{ +public: + grib_accessor_class_trim_t(const char* name) : grib_accessor_class_ascii_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_trim_t{}; } + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_uint16.cc b/src/accessor/grib_accessor_class_uint16.cc new file mode 100644 index 000000000..1d9158ac0 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint16.cc @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_uint16.h" + +grib_accessor_class_uint16_t _grib_accessor_class_uint16{"uint16"}; +grib_accessor_class* grib_accessor_class_uint16 = &_grib_accessor_class_uint16; + + +int grib_accessor_class_uint16_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + /*long pos = a->offset;*/ + /*unsigned char* data = grib_handle_of_accessor(a)->buffer->data;*/ + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + *val = value; + *len = 1; + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_uint16_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint16.h b/src/accessor/grib_accessor_class_uint16.h new file mode 100644 index 000000000..05818ebbd --- /dev/null +++ b/src/accessor/grib_accessor_class_uint16.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint16_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint16 */ +}; + +class grib_accessor_class_uint16_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint16_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint16_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; diff --git a/src/accessor/grib_accessor_class_uint32.cc b/src/accessor/grib_accessor_class_uint32.cc new file mode 100644 index 000000000..7518cb68c --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32.cc @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_uint32.h" + +grib_accessor_class_uint32_t _grib_accessor_class_uint32{"uint32"}; +grib_accessor_class* grib_accessor_class_uint32 = &_grib_accessor_class_uint32; + + +int grib_accessor_class_uint32_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + /* long pos = a->offset; */ + /* unsigned char* data = grib_handle_of_accessor(a)->buffer->data; */ + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + *val = value; + *len = 1; + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_uint32_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint32.h b/src/accessor/grib_accessor_class_uint32.h new file mode 100644 index 000000000..143dfc809 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint32_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint32 */ +}; + +class grib_accessor_class_uint32_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint32_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint32_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.cc b/src/accessor/grib_accessor_class_uint32_little_endian.cc new file mode 100644 index 000000000..b8733bd0a --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32_little_endian.cc @@ -0,0 +1,34 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_uint32_little_endian.h" + +grib_accessor_class_uint32_little_endian_t _grib_accessor_class_uint32_little_endian{"uint32_little_endian"}; +grib_accessor_class* grib_accessor_class_uint32_little_endian = &_grib_accessor_class_uint32_little_endian; + + +int grib_accessor_class_uint32_little_endian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + /* long pos = a->offset; */ + /* unsigned char* data = grib_handle_of_accessor(a)->buffer->data; */ + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + *val = value; + *len = 1; + return GRIB_NOT_IMPLEMENTED; +} + +int grib_accessor_class_uint32_little_endian_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint32_little_endian.h b/src/accessor/grib_accessor_class_uint32_little_endian.h new file mode 100644 index 000000000..83e808bc5 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint32_little_endian.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint32_little_endian_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint32_little_endian */ +}; + +class grib_accessor_class_uint32_little_endian_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint32_little_endian_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint32_little_endian_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; diff --git a/src/accessor/grib_accessor_class_uint64.cc b/src/accessor/grib_accessor_class_uint64.cc new file mode 100644 index 000000000..4c79f7bb4 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64.cc @@ -0,0 +1,50 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_uint64.h" + +grib_accessor_class_uint64_t _grib_accessor_class_uint64{"uint64"}; +grib_accessor_class* grib_accessor_class_uint64 = &_grib_accessor_class_uint64; + + +int grib_accessor_class_uint64_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + long pos = a->offset; + unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + unsigned long long result = 0, tmp; + int i; + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < 8; i++) { + result <<= 8; + result |= data[pos + i]; + } + + value = result; + tmp = value; + + /* Result does not fit in long */ + if (tmp != result) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name, result); + return GRIB_DECODING_ERROR; + } + + *val = value; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_uint64_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint64.h b/src/accessor/grib_accessor_class_uint64.h new file mode 100644 index 000000000..d442b736d --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint64_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint64 */ +}; + +class grib_accessor_class_uint64_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint64_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint64_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.cc b/src/accessor/grib_accessor_class_uint64_little_endian.cc new file mode 100644 index 000000000..81d0fed37 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64_little_endian.cc @@ -0,0 +1,50 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_uint64_little_endian.h" + +grib_accessor_class_uint64_little_endian_t _grib_accessor_class_uint64_little_endian{"uint64_little_endian"}; +grib_accessor_class* grib_accessor_class_uint64_little_endian = &_grib_accessor_class_uint64_little_endian; + + +int grib_accessor_class_uint64_little_endian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + long pos = a->offset; + unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + unsigned long long result = 0, tmp; + int i; + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 7; i >= 0; i--) { + result <<= 8; + result |= data[pos + i]; + } + + value = result; + tmp = value; + + /* Result does not fit in long */ + if (tmp != result) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name, result); + return GRIB_DECODING_ERROR; + } + + *val = value; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_uint64_little_endian_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint64_little_endian.h b/src/accessor/grib_accessor_class_uint64_little_endian.h new file mode 100644 index 000000000..9e8f4327e --- /dev/null +++ b/src/accessor/grib_accessor_class_uint64_little_endian.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint64_little_endian_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint64_little_endian */ +}; + +class grib_accessor_class_uint64_little_endian_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint64_little_endian_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint64_little_endian_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; diff --git a/src/accessor/grib_accessor_class_uint8.cc b/src/accessor/grib_accessor_class_uint8.cc new file mode 100644 index 000000000..ce5d88f98 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint8.cc @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_uint8.h" + +grib_accessor_class_uint8_t _grib_accessor_class_uint8{"uint8"}; +grib_accessor_class* grib_accessor_class_uint8 = &_grib_accessor_class_uint8; + + +int grib_accessor_class_uint8_t::unpack_long(grib_accessor* a, long* val, size_t* len){ + long value = 0; + long pos = a->offset; + unsigned char* data = grib_handle_of_accessor(a)->buffer->data; + + if (*len < 1) { + return GRIB_ARRAY_TOO_SMALL; + } + + value = data[pos]; + + *val = value; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_uint8_t::get_native_type(grib_accessor* a){ + return GRIB_TYPE_LONG; +} diff --git a/src/accessor/grib_accessor_class_uint8.h b/src/accessor/grib_accessor_class_uint8.h new file mode 100644 index 000000000..8a58b27f3 --- /dev/null +++ b/src/accessor/grib_accessor_class_uint8.h @@ -0,0 +1,29 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_uint8_t : public grib_accessor_gen_t +{ +public: + /* Members defined in uint8 */ +}; + +class grib_accessor_class_uint8_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_uint8_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_uint8_t{}; } + int get_native_type(grib_accessor*) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; +}; diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc new file mode 100644 index 000000000..5c9402360 --- /dev/null +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -0,0 +1,142 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_unexpanded_descriptors.h" + +grib_accessor_class_unexpanded_descriptors_t _grib_accessor_class_unexpanded_descriptors{ "unexpanded_descriptors" }; +grib_accessor_class* grib_accessor_class_unexpanded_descriptors = &_grib_accessor_class_unexpanded_descriptors; + + +void grib_accessor_class_unexpanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ + grib_accessor_class_long_t::init(a, len, args); + grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; + + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + self->unexpandedDescriptorsEncoded = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); + self->createNewData = grib_arguments_get_name(hand, args, n++); + a->length = 0; +} + +int grib_accessor_class_unexpanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; + int ret = 0; + long pos = 0; + long rlen = 0; + long f, x, y; + long* v = val; + long i; + grib_handle* hand = grib_handle_of_accessor(a); + + pos = accessor_raw_get_offset(self->unexpandedDescriptorsEncoded) * 8; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (rlen == 0) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "No descriptors in section 3. Malformed message."); + return GRIB_MESSAGE_MALFORMED; + } + + if (*len < rlen) { + /* grib_context_log(a->context, GRIB_LOG_ERROR, */ + /* " wrong size (%ld) for %s it contains %d values ",*len, a->name , rlen); */ + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + + for (i = 0; i < rlen; i++) { + f = grib_decode_unsigned_long(hand->buffer->data, &pos, 2); + x = grib_decode_unsigned_long(hand->buffer->data, &pos, 6); + y = grib_decode_unsigned_long(hand->buffer->data, &pos, 8); + *v++ = f * 100000 + x * 1000 + y; + } + *len = rlen; + return GRIB_SUCCESS; +} + +int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; + int ret = 0; + long pos = 0; + unsigned long f, x, y; + unsigned char* buf = NULL; + grib_accessor* expanded = NULL; + size_t buflen = *len * 2; + size_t i = 0, length = *len; + long createNewData = 1; + grib_handle* hand = grib_handle_of_accessor(a); + + grib_get_long(hand, self->createNewData, &createNewData); + + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); + + for (i = 0; i < length; i++) { + const long tmp = val[i] % 100000; + f = val[i] / 100000; + x = tmp / 1000; + y = tmp % 1000; + grib_encode_unsigned_longb(buf, f, &pos, 2); + grib_encode_unsigned_longb(buf, x, &pos, 6); + grib_encode_unsigned_longb(buf, y, &pos, 8); + } + + self->unexpandedDescriptorsEncoded->pack_bytes(buf, &buflen); + grib_context_free(hand->context, buf); + + if (createNewData == 0) + return ret; + + expanded = grib_find_accessor(hand, "expandedCodes"); + Assert(expanded != NULL); + ret = grib_accessor_class_expanded_descriptors_set_do_expand(expanded, 1); + if (ret != GRIB_SUCCESS) + return ret; + + ret = grib_set_long(hand, "unpack", 3); /* BUFR new data */ + if (ret != GRIB_SUCCESS) + return ret; + + ret = grib_set_long(hand, "unpack", 1); /* Unpack structure */ + + return ret; +} + +int grib_accessor_class_unexpanded_descriptors_t::value_count(grib_accessor* a, long* numberOfUnexpandedDescriptors) +{ + grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; + long n = 0; + + self->unexpandedDescriptorsEncoded->value_count(&n); + *numberOfUnexpandedDescriptors = n / 2; + + return 0; +} + +long grib_accessor_class_unexpanded_descriptors_t::byte_offset(grib_accessor* a) +{ + return a->offset; +} + +void grib_accessor_class_unexpanded_descriptors_t::update_size(grib_accessor* a, size_t s) +{ + a->length = s; +} + +long grib_accessor_class_unexpanded_descriptors_t::next_offset(grib_accessor* a) +{ + return a->byte_offset() + a->length; +} diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.h b/src/accessor/grib_accessor_class_unexpanded_descriptors.h new file mode 100644 index 000000000..f9a016c1e --- /dev/null +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_unexpanded_descriptors_t : public grib_accessor_long_t +{ +public: + /* Members defined in unexpanded_descriptors */ + grib_accessor* unexpandedDescriptorsEncoded; + const char* createNewData; +}; + +class grib_accessor_class_unexpanded_descriptors_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unexpanded_descriptors_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unexpanded_descriptors_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/grib_accessor_class_unpack_bufr_values.cc new file mode 100644 index 000000000..3497bbbe2 --- /dev/null +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.cc @@ -0,0 +1,113 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_unpack_bufr_values.h" +#include "grib_accessor_class_bufr_data_array.h" + +grib_accessor_class_unpack_bufr_values_t _grib_accessor_class_unpack_bufr_values{ "unpack_bufr_values" }; +grib_accessor_class* grib_accessor_class_unpack_bufr_values = &_grib_accessor_class_unpack_bufr_values; + +void grib_accessor_class_unpack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ + grib_accessor_class_gen_t::init(a, len, params); + char* key; + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); + self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); + + a->length = 0; +} + +void grib_accessor_class_unpack_bufr_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ +} + +int grib_accessor_class_unpack_bufr_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +{ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->unpack_double(0, 0); +} + +int grib_accessor_class_unpack_bufr_values_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + strcpy(buffer, "0"); + *len = 1; + + return data->unpack_double(0, 0); +} + +int grib_accessor_class_unpack_bufr_values_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->unpack_double(0, 0); +} + +int grib_accessor_class_unpack_bufr_values_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->unpack_double(0, 0); +} + +int grib_accessor_class_unpack_bufr_values_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +void grib_accessor_class_unpack_bufr_values_t::destroy(grib_context* context, grib_accessor* a) +{ + grib_accessor_class_gen_t::destroy(context, a); +} + +int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_LONG; +} + +// static const char* mode_to_str(int p) +// { +// if (p==CODES_BUFR_UNPACK_STRUCTURE) return "CODES_BUFR_UNPACK_STRUCTURE"; +// if (p==CODES_BUFR_UNPACK_FLAT) return "CODES_BUFR_UNPACK_FLAT"; +// if (p==CODES_BUFR_NEW_DATA) return "CODES_BUFR_NEW_DATA"; +// return "unknown proc flag"; +// } + +int grib_accessor_class_unpack_bufr_values_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + int unpackMode = CODES_BUFR_UNPACK_STRUCTURE; + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + if (*val == 2) + unpackMode = CODES_BUFR_UNPACK_FLAT; + if (*val == 3) + unpackMode = CODES_BUFR_NEW_DATA; + + accessor_bufr_data_array_set_unpackMode(data, unpackMode); + + return data->unpack_double(0, 0); +} + +int grib_accessor_class_unpack_bufr_values_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; + grib_accessor* data = (grib_accessor*)self->data_accessor; + + return data->unpack_double(0, 0); +} diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.h b/src/accessor/grib_accessor_class_unpack_bufr_values.h new file mode 100644 index 000000000..46dd91ec5 --- /dev/null +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.h @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_unpack_bufr_values_t : public grib_accessor_gen_t +{ +public: + /* Members defined in unpack_bufr_values */ + grib_accessor* data_accessor; +}; + +class grib_accessor_class_unpack_bufr_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_unpack_bufr_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unpack_bufr_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + int unpack_string_array(grib_accessor*, char**, size_t* len) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc similarity index 50% rename from src/grib_accessor_class_unsigned.cc rename to src/accessor/grib_accessor_class_unsigned.cc index f1202b0d0..8093e3a6a 100644 --- a/src/grib_accessor_class_unsigned.cc +++ b/src/accessor/grib_accessor_class_unsigned.cc @@ -8,119 +8,19 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump;is_missing - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size; destroy - MEMBERS = long nbytes - MEMBERS = grib_arguments* arg - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_unsigned -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; -} grib_accessor_unsigned; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_unsigned = { - &grib_accessor_class_long, /* super */ - "unsigned", /* name */ - sizeof(grib_accessor_unsigned), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; +#include "grib_accessor_class_unsigned.h" +grib_accessor_class_unsigned_t _grib_accessor_class_unsigned("unsigned"); grib_accessor_class* grib_accessor_class_unsigned = &_grib_accessor_class_unsigned; -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long len, grib_arguments* arg) +void grib_accessor_class_unsigned_t::init(grib_accessor* a, const long len, grib_arguments* arg) { - grib_accessor_unsigned* self = (grib_accessor_unsigned*)a; - self->arg = NULL; - self->arg = arg; - self->nbytes = len; + grib_accessor_class_long_t::init(a, len, arg); + grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; + self->arg = arg; + self->nbytes = len; if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { a->length = 0; @@ -131,17 +31,17 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg) } else { long count = 0; - grib_value_count(a, &count); + a->value_count(&count); a->length = len * count; a->vvalue = NULL; } } -static void dump(grib_accessor* a, grib_dumper* dumper) +void grib_accessor_class_unsigned_t::dump(grib_accessor* a, grib_dumper* dumper) { long rlen = 0; - grib_value_count(a, &rlen); + a->value_count(&rlen); if (rlen == 1) grib_dump_long(dumper, a, NULL); else @@ -158,25 +58,26 @@ static const unsigned long ones[] = { /* See GRIB-490 */ static const unsigned long all_ones = -1; -static int value_is_missing(long val) + +int value_is_missing(long val) { return (val == GRIB_MISSING_LONG || val == all_ones); } int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, int check) { - grib_accessor_unsigned* self = (grib_accessor_unsigned*)a; - int ret = 0; - long off = 0; - long rlen = 0; - int err = 0; + grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; + int ret = 0; + long off = 0; + long rlen = 0; + int err = 0; size_t buflen = 0; unsigned char* buf = NULL; unsigned long i = 0; unsigned long missing = 0; - err = grib_value_count(a, &rlen); + err = a->value_count(&rlen); if (err) return err; @@ -213,7 +114,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in if (check) { if (val[0] < 0) { grib_context_log(a->context, GRIB_LOG_ERROR, - "Key \"%s\": Trying to encode a negative value of %ld for key of type unsigned", a->name, val[0]); + "Key \"%s\": Trying to encode a negative value of %ld for key of type unsigned", a->name, val[0]); return GRIB_ENCODING_ERROR; } /* See GRIB-23 and GRIB-262 */ @@ -223,8 +124,8 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in unsigned long maxval = (1UL << nbits) - 1; 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 %lu (number of bits=%ld)", - a->name, v, maxval, nbits); + "Key \"%s\": Trying to encode value of %ld but the maximum allowable value is %lu (number of bits=%ld)", + a->name, v, maxval, nbits); return GRIB_ENCODING_ERROR; } } @@ -260,18 +161,18 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in return ret; } -static int unpack_long(grib_accessor* a, long* val, size_t* len) +int grib_accessor_class_unsigned_t::unpack_long(grib_accessor* a, long* val, size_t* len) { - grib_accessor_unsigned* self = (grib_accessor_unsigned*)a; - long rlen = 0; - unsigned long i = 0; - unsigned long missing = 0; - long count = 0; - int err = 0; - long pos = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); + grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; + long rlen = 0; + unsigned long i = 0; + unsigned long missing = 0; + long count = 0; + int err = 0; + long pos = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; rlen = count; @@ -304,20 +205,20 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) return GRIB_SUCCESS; } -static int pack_long(grib_accessor* a, const long* val, size_t* len) +int grib_accessor_class_unsigned_t::pack_long(grib_accessor* a, const long* val, size_t* len) { /* See GRIB-262 as example of why we do the checks */ return pack_long_unsigned_helper(a, val, len, /*check=*/1); } -static long byte_count(grib_accessor* a) +long grib_accessor_class_unsigned_t::byte_count(grib_accessor* a) { return a->length; } -static int value_count(grib_accessor* a, long* len) +int grib_accessor_class_unsigned_t::value_count(grib_accessor* a, long* len) { - grib_accessor_unsigned* self = (grib_accessor_unsigned*)a; + grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; if (!self->arg) { *len = 1; return 0; @@ -325,22 +226,22 @@ static int value_count(grib_accessor* a, long* len) return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); } -static long byte_offset(grib_accessor* a) +long grib_accessor_class_unsigned_t::byte_offset(grib_accessor* a) { return a->offset; } -static void update_size(grib_accessor* a, size_t s) +void grib_accessor_class_unsigned_t::update_size(grib_accessor* a, size_t s) { a->length = s; } -static long next_offset(grib_accessor* a) +long grib_accessor_class_unsigned_t::next_offset(grib_accessor* a) { - return grib_byte_offset(a) + grib_byte_count(a); + return a->byte_offset() + a->byte_count(); } -static int is_missing(grib_accessor* a) +int grib_accessor_class_unsigned_t::is_missing(grib_accessor* a) { int i = 0; unsigned char ff = 0xff; @@ -361,10 +262,12 @@ static int is_missing(grib_accessor* a) return 1; } -static void destroy(grib_context* context, grib_accessor* a) +void grib_accessor_class_unsigned_t::destroy(grib_context* context, grib_accessor* a) { if (a->vvalue != NULL) grib_context_free(context, a->vvalue); a->vvalue = NULL; + + grib_accessor_class_long_t::destroy(context, a); } diff --git a/src/accessor/grib_accessor_class_unsigned.h b/src/accessor/grib_accessor_class_unsigned.h new file mode 100644 index 000000000..50f3cfb16 --- /dev/null +++ b/src/accessor/grib_accessor_class_unsigned.h @@ -0,0 +1,39 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_unsigned_t : public grib_accessor_long_t +{ +public: + long nbytes; + grib_arguments* arg; +}; + + +class grib_accessor_class_unsigned_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unsigned_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unsigned_t{}; } + void init(grib_accessor* a, const long len, grib_arguments* arg) override; + void dump(grib_accessor* a, grib_dumper* dumper) override; + int unpack_long(grib_accessor* a, long* val, size_t* len) override; + int pack_long(grib_accessor* a, const long* val, size_t* len) override; + long byte_count(grib_accessor* a) override; + int value_count(grib_accessor* a, long* len) override; + long byte_offset(grib_accessor* a) override; + void update_size(grib_accessor* a, size_t s) override; + long next_offset(grib_accessor* a) override; + int is_missing(grib_accessor* a) override; + void destroy(grib_context* context, grib_accessor* a) override; +}; diff --git a/src/accessor/grib_accessor_class_unsigned_bits.cc b/src/accessor/grib_accessor_class_unsigned_bits.cc new file mode 100644 index 000000000..44873938a --- /dev/null +++ b/src/accessor/grib_accessor_class_unsigned_bits.cc @@ -0,0 +1,167 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_unsigned_bits.h" + +grib_accessor_class_unsigned_bits_t _grib_accessor_class_unsigned_bits{ "unsigned_bits" }; +grib_accessor_class* grib_accessor_class_unsigned_bits = &_grib_accessor_class_unsigned_bits; + + +static long compute_byte_count(grib_accessor* a) +{ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + long numberOfBits; + long numberOfElements; + int ret = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfBits); + return 0; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + return 0; + } + + return (numberOfBits * numberOfElements + 7) / 8; +} + + +void grib_accessor_class_unsigned_bits_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ + grib_accessor_class_long_t::init(a, len, args); + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + int n = 0; + self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->length = compute_byte_count(a); +} + +int grib_accessor_class_unsigned_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + int ret = 0; + long pos = a->offset * 8; + long rlen = 0; + long numberOfBits = 0; + + ret = value_count(a, &rlen); + if (ret) + return ret; + + if (*len < rlen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Wrong size (%ld) for %s, it contains %ld values", *len, a->name, rlen); + *len = rlen; + return GRIB_ARRAY_TOO_SMALL; + } + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) + return ret; + if (numberOfBits == 0) { + int i; + for (i = 0; i < rlen; i++) + val[i] = 0; + return GRIB_SUCCESS; + } + + grib_decode_long_array(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits, rlen, val); + + *len = rlen; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_unsigned_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + int ret = 0; + long off = 0; + long numberOfBits = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + long rlen = 0; + ret = value_count(a, &rlen); + if (ret) return ret; + + /* + if(*len < rlen) + { + grib_context_log(a->context, GRIB_LOG_ERROR, + "Wrong size for %s it contains %d values ", a->name , rlen ); + return GRIB_ARRAY_TOO_SMALL; + } + */ + if (*len != rlen) + ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, *len); + if (ret) return ret; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); + if (ret) return ret; + if (numberOfBits == 0) { + grib_buffer_replace(a, NULL, 0, 1, 1); + return GRIB_SUCCESS; + } + + buflen = compute_byte_count(a); + buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen + sizeof(long)); + + for (i = 0; i < *len; i++) + grib_encode_unsigned_longb(buf, val[i], &off, numberOfBits); + + grib_buffer_replace(a, buf, buflen, 1, 1); + + grib_context_free(a->context, buf); + + return ret; +} + +long grib_accessor_class_unsigned_bits_t::byte_count(grib_accessor* a) +{ + return a->length; +} + +int grib_accessor_class_unsigned_bits_t::value_count(grib_accessor* a, long* numberOfElements) +{ + grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; + int ret; + *numberOfElements = 0; + + ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); + if (ret) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s unable to get %s to compute size", a->name, self->numberOfElements); + } + + return ret; +} + +long grib_accessor_class_unsigned_bits_t::byte_offset(grib_accessor* a) +{ + return a->offset; +} + +void grib_accessor_class_unsigned_bits_t::update_size(grib_accessor* a, size_t s) +{ + a->length = s; +} + +long grib_accessor_class_unsigned_bits_t::next_offset(grib_accessor* a) +{ + return a->byte_offset() + a->length; +} diff --git a/src/accessor/grib_accessor_class_unsigned_bits.h b/src/accessor/grib_accessor_class_unsigned_bits.h new file mode 100644 index 000000000..52528ab83 --- /dev/null +++ b/src/accessor/grib_accessor_class_unsigned_bits.h @@ -0,0 +1,37 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_unsigned_bits_t : public grib_accessor_long_t +{ +public: + /* Members defined in unsigned_bits */ + const char* numberOfBits; + const char* numberOfElements; +}; + +class grib_accessor_class_unsigned_bits_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_unsigned_bits_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_unsigned_bits_t{}; } + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; +}; diff --git a/src/accessor/grib_accessor_class_validity_date.cc b/src/accessor/grib_accessor_class_validity_date.cc new file mode 100644 index 000000000..331c4ec82 --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_date.cc @@ -0,0 +1,98 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_validity_date.h" +#include "shared_functions.h" + +grib_accessor_class_validity_date_t _grib_accessor_class_validity_date{ "validity_date" }; +grib_accessor_class* grib_accessor_class_validity_date = &_grib_accessor_class_validity_date; + +void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->date = grib_arguments_get_name(hand, c, n++); + self->time = grib_arguments_get_name(hand, c, n++); + self->step = grib_arguments_get_name(hand, c, n++); + self->stepUnits = grib_arguments_get_name(hand, c, n++); + self->year = grib_arguments_get_name(hand, c, n++); + self->month = grib_arguments_get_name(hand, c, n++); + self->day = grib_arguments_get_name(hand, c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_validity_date_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + long date = 0; + long time = 0; + long step = 0; + long stepUnits = 0; + long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs; + + if (self->year) { + long year, month, day; + if ((ret = grib_get_long_internal(hand, self->year, &year)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->month, &month)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->day, &day)) != GRIB_SUCCESS) + return ret; + *val = year * 10000 + month * 100 + day; + return GRIB_SUCCESS; + } + if ((ret = grib_get_long_internal(hand, self->date, &date)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->time, &time)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long(hand, self->step, &step)) != GRIB_SUCCESS) { + if ((ret = grib_get_long_internal(hand, "endStep", &step)) != GRIB_SUCCESS) { + return ret; /* See ECC-817 */ + } + } + + if (self->stepUnits) { + if ((ret = grib_get_long_internal(hand, self->stepUnits, &stepUnits)) != GRIB_SUCCESS) + return ret; + step_mins = convert_to_minutes(step, stepUnits); + } + + minutes = time % 100; + hours = time / 100; + tmp = minutes + step_mins; /* add the step to our minutes */ + tmp_hrs = tmp / 60; /* how many hours and mins is that? */ + hours += tmp_hrs; /* increment hours */ + + date = grib_date_to_julian(date); + /* does the new 'hours' exceed 24? if so increment julian */ + while (hours >= 24) { + date++; + hours -= 24; + } + /* GRIB-29: Negative forecast time */ + while (hours < 0) { + date--; + hours += 24; + } + + if (*len < 1) + return GRIB_ARRAY_TOO_SMALL; + + *val = grib_julian_to_date(date); + + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_validity_date.h b/src/accessor/grib_accessor_class_validity_date.h new file mode 100644 index 000000000..ca87b3282 --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_date.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_validity_date_t : public grib_accessor_long_t +{ +public: + /* Members defined in validity_date */ + const char* date; + const char* time; + const char* step; + const char* stepUnits; + const char* year; + const char* month; + const char* day; +}; + +class grib_accessor_class_validity_date_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_validity_date_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_validity_date_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_validity_time.cc b/src/accessor/grib_accessor_class_validity_time.cc new file mode 100644 index 000000000..350a19e92 --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_time.cc @@ -0,0 +1,119 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_validity_time.h" +#include "shared_functions.h" + +grib_accessor_class_validity_time_t _grib_accessor_class_validity_time{ "validity_time" }; +grib_accessor_class* grib_accessor_class_validity_time = &_grib_accessor_class_validity_time; + + +void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_long_t::init(a, l, c); + grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + + self->date = grib_arguments_get_name(hand, c, n++); + self->time = grib_arguments_get_name(hand, c, n++); + self->step = grib_arguments_get_name(hand, c, n++); + self->stepUnits = grib_arguments_get_name(hand, c, n++); + self->hours = grib_arguments_get_name(hand, c, n++); + self->minutes = grib_arguments_get_name(hand, c, n++); + + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +int grib_accessor_class_validity_time_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + long date = 0; + long time = 0; + long step = 0; + long stepUnits = 0; + long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs, tmp_mins; + + if (self->hours) { + if ((ret = grib_get_long_internal(hand, self->hours, &hours)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->minutes, &minutes)) != GRIB_SUCCESS) + return ret; + *val = hours * 100 + minutes; + return GRIB_SUCCESS; + } + if ((ret = grib_get_long_internal(hand, self->date, &date)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long_internal(hand, self->time, &time)) != GRIB_SUCCESS) + return ret; + if ((ret = grib_get_long(hand, self->step, &step)) != GRIB_SUCCESS) { + if ((ret = grib_get_long_internal(hand, "endStep", &step)) != GRIB_SUCCESS) { + return ret; /* See ECC-817 */ + } + } + + /* Seconds will always be zero. So convert to minutes */ + if (self->stepUnits) { + if ((ret = grib_get_long_internal(hand, self->stepUnits, &stepUnits)) != GRIB_SUCCESS) + return ret; + step_mins = convert_to_minutes(step, stepUnits); + } + + minutes = time % 100; + hours = time / 100; + tmp = minutes + step_mins; /* add the step to our minutes */ + tmp_hrs = tmp / 60; /* how many hours and mins is that? */ + tmp_mins = tmp % 60; + hours += tmp_hrs; /* increment hours */ + if (hours > 0) { + hours = hours % 24; /* wrap round if >= 24 */ + } + else { + /* GRIB-29: Negative forecast time */ + while (hours < 0) { + hours += 24; + } + } + time = hours * 100 + tmp_mins; + + if (*len < 1) + return GRIB_ARRAY_TOO_SMALL; + + *val = time; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_validity_time_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + int err = 0; + long v = 0; + size_t lsize = 1, lmin = 5; + + err = unpack_long(a, &v, &lsize); + if (err) return err; + + if (*len < lmin) { + const char* cclass_name = a->cclass->name; + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + cclass_name, a->name, lmin, *len); + *len = lmin; + return GRIB_BUFFER_TOO_SMALL; + } + + snprintf(val, 64, "%04ld", v); + + len[0] = lmin; + return GRIB_SUCCESS; +} diff --git a/src/accessor/grib_accessor_class_validity_time.h b/src/accessor/grib_accessor_class_validity_time.h new file mode 100644 index 000000000..023c3e30a --- /dev/null +++ b/src/accessor/grib_accessor_class_validity_time.h @@ -0,0 +1,36 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_long.h" + +class grib_accessor_validity_time_t : public grib_accessor_long_t +{ +public: + /* Members defined in validity_time */ + const char* date; + const char* time; + const char* step; + const char* stepUnits; + const char* hours; + const char* minutes; +}; + +class grib_accessor_class_validity_time_t : public grib_accessor_class_long_t +{ +public: + grib_accessor_class_validity_time_t(const char* name) : grib_accessor_class_long_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_validity_time_t{}; } + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_values.cc b/src/accessor/grib_accessor_class_values.cc new file mode 100644 index 000000000..cd2107559 --- /dev/null +++ b/src/accessor/grib_accessor_class_values.cc @@ -0,0 +1,149 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_values.h" + +grib_accessor_class_values_t _grib_accessor_class_values{"values"}; +grib_accessor_class* grib_accessor_class_values = &_grib_accessor_class_values; + +long init_length(grib_accessor* a) +{ + grib_accessor_values_t* self = (grib_accessor_values_t*)a; + int ret = 0; + + long seclen = 0; + long offsetsection = 0; + long offsetdata = 0; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->seclen, &seclen))) + return ret; + + if (seclen == 0) { + /* printf("init_length seclen=0\n"); */ + return 0; + } + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection))) + return ret; + + if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetdata, &offsetdata))) + return ret; + + /* When reparsing */ + if (offsetdata < offsetsection) { + /* printf("init_length offsetdata < offsetsection=0\n"); */ + Assert(grib_handle_of_accessor(a)->loader); + return 0; + } + + return seclen - (offsetdata - offsetsection); +} + +void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arguments* params) +{ + grib_accessor_class_gen_t::init(a, v, params); + grib_accessor_values_t* self = (grib_accessor_values_t*)a; + self->carg = 0; + + self->seclen = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); + self->offsetdata = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); + self->offsetsection = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); + self->dirty = 1; + + a->length = init_length(a); + /* Assert(a->length>=0); */ +} + +int grib_accessor_class_values_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_DOUBLE; +} + +void grib_accessor_class_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + grib_dump_values(dumper, a); +} + +long grib_accessor_class_values_t::byte_count(grib_accessor* a) +{ + grib_context_log(a->context, GRIB_LOG_DEBUG, "byte_count of %s = %ld", a->name, a->length); + return a->length; +} + +long grib_accessor_class_values_t::byte_offset(grib_accessor* a) +{ + return a->offset; +} + +long grib_accessor_class_values_t::next_offset(grib_accessor* a) +{ + return a->offset + a->length; +} + +void grib_accessor_class_values_t::update_size(grib_accessor* a, size_t s) +{ + grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); + a->length = s; + Assert(a->length >= 0); +} + +int grib_accessor_class_values_t::compare(grib_accessor* a, grib_accessor* b) +{ + int retval = 0; + double* aval = 0; + double* bval = 0; + + size_t alen = 0; + size_t blen = 0; + int err = 0; + long count = 0; + + err = a->value_count(&count); if (err) + return err; + alen = count; + + err = b->value_count(&count); if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + retval = GRIB_SUCCESS; + for (size_t i=0; icontext, aval); + grib_context_free(b->context, bval); + + return retval; +} + +int grib_accessor_class_values_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_values_t* self = (grib_accessor_values_t*)a; + double* dval = (double*)grib_context_malloc(a->context, *len * sizeof(double)); + + for (size_t i = 0; i < *len; i++) + dval[i] = (double)val[i]; + + int ret = a->pack_double(dval, len); + grib_context_free(a->context, dval); + + self->dirty = 1; + + return ret; +} diff --git a/src/accessor/grib_accessor_class_values.h b/src/accessor/grib_accessor_class_values.h new file mode 100644 index 000000000..5de50f2bd --- /dev/null +++ b/src/accessor/grib_accessor_class_values.h @@ -0,0 +1,39 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_values_t : public grib_accessor_gen_t +{ +public: + int carg; + const char* seclen; + const char* offsetdata; + const char* offsetsection; + int dirty; +}; + +class grib_accessor_class_values_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_values_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_values_t{}; } + int get_native_type(grib_accessor*) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + long byte_count(grib_accessor*) override; + long byte_offset(grib_accessor*) override; + long next_offset(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + void update_size(grib_accessor*, size_t) override; + int compare(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessor_class_variable.cc b/src/accessor/grib_accessor_class_variable.cc new file mode 100644 index 000000000..b87798663 --- /dev/null +++ b/src/accessor/grib_accessor_class_variable.cc @@ -0,0 +1,359 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_variable.h" +#include + + +grib_accessor_class_variable_t _grib_accessor_class_variable{"variable"}; +grib_accessor_class* grib_accessor_class_variable = &_grib_accessor_class_variable; + +// +// This accessor is used for: +// constant +// transient +// + +#define MAX_VARIABLE_STRING_LENGTH 255 + +void grib_accessor_class_variable_t::init(grib_accessor* a, const long length, grib_arguments* args) +{ + grib_accessor_class_gen_t::init(a, length, args); + + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + grib_handle* hand = grib_handle_of_accessor(a); + grib_expression* expression = grib_arguments_get_expression(hand, args, 0); + const char* p = 0; + size_t len = 1; + long l = 0; + int ret = 0; + double d = 0; + self->cname = NULL; + + a->length = 0; + if (self->type == GRIB_TYPE_UNDEFINED && expression) { + self->type = grib_expression_native_type(hand, expression); + + switch (self->type) { + case GRIB_TYPE_DOUBLE: + grib_expression_evaluate_double(hand, expression, &d); + a->pack_double(&d, &len); + break; + + case GRIB_TYPE_LONG: + grib_expression_evaluate_long(hand, expression, &l); + a->pack_long(&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: %s", + a->name, grib_get_error_message(ret)); + return; + } + len = strlen(p) + 1; + a->pack_string(p, &len); + break; + } + } + } +} + +void accessor_variable_set_type(grib_accessor* a, int type) +{ + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + self->type = type; +} + +void grib_accessor_class_variable_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + switch (self->type) { + case GRIB_TYPE_DOUBLE: + grib_dump_double(dumper, a, NULL); + break; + + case GRIB_TYPE_LONG: + grib_dump_long(dumper, a, NULL); + break; + + default: + grib_dump_string(dumper, a, NULL); + break; + } +} + +int grib_accessor_class_variable_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + const double dval = *val; + + if (*len != 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains 1 value", a->name); + *len = 1; + return GRIB_ARRAY_TOO_SMALL; + } + + //if (std::isnan(dval)) { + // grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Invalid number for %s: %g", __func__, a->name, dval); + // return GRIB_INVALID_ARGUMENT; + //} + + self->dval = dval; + if (dval < (double)LONG_MIN || dval > (double)LONG_MAX) + self->type = GRIB_TYPE_DOUBLE; + else + self->type = ((long)dval == dval) ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_variable_t::pack_float(grib_accessor* a, const float* val, size_t* len) +{ + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + const double fval = *val; + + if (*len != 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains 1 value", a->name); + *len = 1; + return GRIB_ARRAY_TOO_SMALL; + } + + self->fval = fval; + if (fval < (float)LONG_MIN || fval > (float)LONG_MAX) + self->type = GRIB_TYPE_DOUBLE; + else + self->type = ((long)fval == fval) ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_variable_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + + if (*len != 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains 1 value", a->name); + *len = 1; + return GRIB_ARRAY_TOO_SMALL; + } + + self->dval = *val; + self->fval = *val; + self->type = GRIB_TYPE_LONG; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_variable_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + *val = self->dval; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_variable_t::unpack_float(grib_accessor* a, float* val, size_t* len) +{ + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + *val = self->fval; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_variable_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + + if (*len < 1) { + grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); + *len = 0; + return GRIB_ARRAY_TOO_SMALL; + } + *val = (long)self->dval; + *len = 1; + return GRIB_SUCCESS; +} + +int grib_accessor_class_variable_t::get_native_type(grib_accessor* a) +{ + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + return self->type; +} + +void grib_accessor_class_variable_t::destroy(grib_context* c, grib_accessor* a) +{ + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + int i = 0; + + grib_context_free(c, self->cval); + if (self->cname) + grib_context_free(c, self->cname); /* ECC-765 */ + + /* Note: BUFR operator descriptors are variables and have attributes so need to free them */ + while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { + a->attributes[i]->destroy(c); + a->attributes[i] = NULL; + ++i; + } + + grib_accessor_class_gen_t::destroy(c, a); +} + +int grib_accessor_class_variable_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + + char buf[80]; + char* p = buf; + size_t slen = 0; + + if (self->type == GRIB_TYPE_STRING) { + p = self->cval; + } + else { + snprintf(p, 64, "%g", self->dval); + } + + slen = strlen(p) + 1; + if (*len < slen) { + grib_context_log(a->context, GRIB_LOG_ERROR, + "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", + a->cclass->name, a->name, slen, *len); + *len = slen; + return GRIB_BUFFER_TOO_SMALL; + } + strcpy(val, p); + *len = slen; + + return GRIB_SUCCESS; +} + +int grib_accessor_class_variable_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ + grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + const grib_context* c = a->context; + + grib_context_free(c, self->cval); + self->cval = grib_context_strdup(c, val); + self->dval = atof(val); + self->fval = atof(val); + self->type = GRIB_TYPE_STRING; + self->cname = NULL; + return GRIB_SUCCESS; +} + +int grib_accessor_class_variable_t::value_count(grib_accessor* a, long* count) +{ + *count = 1; + return 0; +} + +size_t grib_accessor_class_variable_t::string_length(grib_accessor* a) +{ + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + if (self->type == GRIB_TYPE_STRING) + return strlen(self->cval); + else + return MAX_VARIABLE_STRING_LENGTH; +} + +long grib_accessor_class_variable_t::byte_count(grib_accessor* a) +{ + return a->length; +} + +int grib_accessor_class_variable_t::compare(grib_accessor* a, grib_accessor* b) +{ + int retval = GRIB_SUCCESS; + double* aval = 0; + double* bval = 0; + + size_t alen = 0; + size_t blen = 0; + int err = 0; + long count = 0; + + err = a->value_count(&count); + if (err) + return err; + alen = count; + + err = b->value_count(&count); + if (err) + return err; + blen = count; + + if (alen != blen) + return GRIB_COUNT_MISMATCH; + + aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); + bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); + + a->unpack_double(aval, &alen); + b->unpack_double(bval, &blen); + + retval = GRIB_SUCCESS; + retval = GRIB_SUCCESS; + for (size_t i=0; icontext, aval); + grib_context_free(b->context, bval); + + return retval; +} + +grib_accessor* grib_accessor_class_variable_t::make_clone(grib_accessor* a, grib_section* s, int* err) +{ + grib_accessor* the_clone = NULL; + const grib_accessor_variable_t* self = (grib_accessor_variable_t*)a; + grib_accessor_variable_t* variableAccessor = NULL; + grib_action creator = {0,}; + creator.op = (char*)"variable"; + creator.name_space = (char*)""; + creator.set = 0; + + creator.name = grib_context_strdup(a->context, a->name); + the_clone = grib_accessor_factory(s, &creator, 0, NULL); + the_clone->parent = NULL; + the_clone->h = s->h; + the_clone->flags = a->flags; + variableAccessor = (grib_accessor_variable_t*)the_clone; + variableAccessor->cname = creator.name; /* ECC-765: Store for later freeing memory */ + + *err = 0; + variableAccessor->type = self->type; + if (self->type == GRIB_TYPE_STRING && self->cval != NULL) { + variableAccessor->cval = grib_context_strdup(a->context, self->cval); + } + else { + variableAccessor->dval = self->dval; + variableAccessor->fval = self->fval; + } + + return the_clone; +} diff --git a/src/accessor/grib_accessor_class_variable.h b/src/accessor/grib_accessor_class_variable.h new file mode 100644 index 000000000..90ff71238 --- /dev/null +++ b/src/accessor/grib_accessor_class_variable.h @@ -0,0 +1,49 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor.h" +#include "grib_accessor_class_gen.h" + + +class grib_accessor_variable_t : public grib_accessor_gen_t +{ +public: + double dval; + float fval; + char* cval; + char* cname; + int type; +}; + +class grib_accessor_class_variable_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_variable_t(const char* name) : grib_accessor_class_gen_t(name) {}; + grib_accessor* create_empty_accessor() override { return new grib_accessor_variable_t{}; } + int get_native_type(grib_accessor*) override; + int pack_double(grib_accessor*, const double* val, size_t* len) override; + int pack_float(grib_accessor*, const float* val, size_t* len) override; + int pack_long(grib_accessor*, const long* val, size_t* len) override; + int pack_string(grib_accessor*, const char*, size_t* len) override; + int unpack_double(grib_accessor*, double* val, size_t* len) override; + int unpack_float(grib_accessor*, float* val, size_t* len) override; + int unpack_long(grib_accessor*, long* val, size_t* len) override; + int unpack_string(grib_accessor*, char*, size_t* len) override; + size_t string_length(grib_accessor*) override; + long byte_count(grib_accessor*) override; + int value_count(grib_accessor*, long*) override; + void destroy(grib_context*, grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int compare(grib_accessor*, grib_accessor*) override; + grib_accessor* make_clone(grib_accessor*, grib_section*, int*) override; +}; diff --git a/src/accessor/grib_accessor_class_vector.cc b/src/accessor/grib_accessor_class_vector.cc new file mode 100644 index 000000000..f08809f6f --- /dev/null +++ b/src/accessor/grib_accessor_class_vector.cc @@ -0,0 +1,60 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_vector.h" +#include "grib_accessor_class_abstract_vector.h" + +grib_accessor_class_vector_t _grib_accessor_class_vector{ "vector" }; +grib_accessor_class* grib_accessor_class_vector = &_grib_accessor_class_vector; + + +void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ + grib_accessor_class_abstract_vector_t::init(a, l, c); + grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; + int n = 0; + + self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; + a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; + a->length = 0; +} + +int grib_accessor_class_vector_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ + int err = 0; + size_t size = 0; + double* stat; + grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; + grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + grib_accessor_abstract_vector_t* v = (grib_accessor_abstract_vector_t*)va; + + Assert(self->index >= 0); + + if (self->index >= v->number_of_elements) { + grib_context_log(a->context, GRIB_LOG_FATAL, "index=%d number_of_elements=%d for %s", self->index, v->number_of_elements, a->name); + Assert(self->index < v->number_of_elements); + } + + if (va->dirty) { + grib_get_size(grib_handle_of_accessor(a), self->vector, &size); + stat = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); + err = va->unpack_double(stat, &size); + grib_context_free(a->context, stat); + if (err) + return err; + } + + *val = v->v[self->index]; + + return err; +} diff --git a/src/accessor/grib_accessor_class_vector.h b/src/accessor/grib_accessor_class_vector.h new file mode 100644 index 000000000..92dc6a13e --- /dev/null +++ b/src/accessor/grib_accessor_class_vector.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_abstract_vector.h" + +class grib_accessor_vector_t : public grib_accessor_abstract_vector_t +{ +public: + /* Members defined in vector */ + const char* vector; + int index; +}; + +class grib_accessor_class_vector_t : public grib_accessor_class_abstract_vector_t +{ +public: + grib_accessor_class_vector_t(const char* name) : grib_accessor_class_abstract_vector_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_vector_t{}; } + int unpack_double(grib_accessor*, double* val, size_t* len) override; + void init(grib_accessor*, const long, grib_arguments*) override; +}; diff --git a/src/accessor/grib_accessor_class_when.cc b/src/accessor/grib_accessor_class_when.cc new file mode 100644 index 000000000..48db76803 --- /dev/null +++ b/src/accessor/grib_accessor_class_when.cc @@ -0,0 +1,39 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessor_class_when.h" + +grib_accessor_class_when_t _grib_accessor_class_when{ "when" }; +grib_accessor_class* grib_accessor_class_when = &_grib_accessor_class_when; + + +void grib_accessor_class_when_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ + grib_accessor_class_gen_t::init(a, len, arg); + a->length = 0; + a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; + a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; +} + +void grib_accessor_class_when_t::dump(grib_accessor* a, grib_dumper* dumper) +{ + /* grib_dump_when(dumper,a,NULL); */ +} + +int grib_accessor_class_when_t::notify_change(grib_accessor* a, grib_accessor* changed) +{ + return grib_action_notify_change(a->creator, a, changed); +} + +int grib_accessor_class_when_t::get_native_type(grib_accessor* a) +{ + return GRIB_TYPE_UNDEFINED; +} diff --git a/src/accessor/grib_accessor_class_when.h b/src/accessor/grib_accessor_class_when.h new file mode 100644 index 000000000..515afb4b1 --- /dev/null +++ b/src/accessor/grib_accessor_class_when.h @@ -0,0 +1,31 @@ + +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor_class_gen.h" + +class grib_accessor_when_t : public grib_accessor_gen_t +{ +public: + /* Members defined in when */ +}; + +class grib_accessor_class_when_t : public grib_accessor_class_gen_t +{ +public: + grib_accessor_class_when_t(const char* name) : grib_accessor_class_gen_t(name) {} + grib_accessor* create_empty_accessor() override { return new grib_accessor_when_t{}; } + int get_native_type(grib_accessor*) override; + void dump(grib_accessor*, grib_dumper*) override; + void init(grib_accessor*, const long, grib_arguments*) override; + int notify_change(grib_accessor*, grib_accessor*) override; +}; diff --git a/src/accessor/grib_accessors_list.cc b/src/accessor/grib_accessors_list.cc new file mode 100644 index 000000000..173077e69 --- /dev/null +++ b/src/accessor/grib_accessors_list.cc @@ -0,0 +1,150 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_accessors_list.h" + +grib_accessors_list* grib_accessors_list_create(grib_context* c) +{ + return (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); +} + +void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al) +{ + grib_accessors_list* tmp; + while (al) { + tmp = al->next_; + grib_context_free(c, al); + al = tmp; + } +} + +int grib_accessors_list::value_count(size_t* count) +{ + long lcount = 0; + *count = 0; + grib_accessors_list* al = this; + while (al) { + al->accessor->value_count(&lcount); + *count += lcount; + al = al->next_; + } + return 0; +} + +void grib_accessors_list::push(grib_accessor* a, int rank) +{ + grib_accessors_list* last; + const grib_context* c = a->context; + + last = this->last(); + if (last && last->accessor) { + last->next_ = (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); + last->next_->accessor = a; + last->next_->prev_ = last; + last->next_->rank_ = rank; + this->last_ = last->next_; + } + else { + this->accessor = a; + this->rank_ = rank; + this->last_ = this; + } +} + +grib_accessors_list* grib_accessors_list::last() +{ + return last_; +} + +grib_accessors_list::~grib_accessors_list() +{ + grib_accessors_list* tmp; + grib_context* c = grib_context_get_default(); + + grib_accessors_list* al = this; + while (al) { + tmp = al->next_; + // grib_accessor_delete(c, al->accessor); + grib_context_free(c, al); + al = tmp; + } +} + +int grib_accessors_list::unpack_long(long* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + grib_accessors_list* al = this; + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = al->accessor->unpack_long(val + unpacked_len, &len); + unpacked_len += len; + al = al->next_; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list::unpack_double(double* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + grib_accessors_list* al = this; + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = al->accessor->unpack_double(val + unpacked_len, &len); + unpacked_len += len; + al = al->next_; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list::unpack_float(float* val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + grib_accessors_list* al = this; + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = al->accessor->unpack_float(val + unpacked_len, &len); + unpacked_len += len; + al = al->next_; + } + + *buffer_len = unpacked_len; + return err; +} + +int grib_accessors_list::unpack_string(char** val, size_t* buffer_len) +{ + int err = GRIB_SUCCESS; + size_t unpacked_len = 0; + size_t len = 0; + + grib_accessors_list* al = this; + while (al && err == GRIB_SUCCESS) { + len = *buffer_len - unpacked_len; + err = al->accessor->unpack_string_array(val + unpacked_len, &len); + unpacked_len += len; + al = al->next_; + } + + *buffer_len = unpacked_len; + return err; +} diff --git a/src/accessor/grib_accessors_list.h b/src/accessor/grib_accessors_list.h new file mode 100644 index 000000000..e136d955a --- /dev/null +++ b/src/accessor/grib_accessors_list.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_accessor.h" + +class grib_accessors_list +{ +public: + grib_accessors_list(); + ~grib_accessors_list(); + + int value_count(size_t* count); + void push(grib_accessor* a, int rank); + grib_accessors_list* last(); + int unpack_long(long* val, size_t* buffer_len); + int unpack_double(double* val, size_t* buffer_len); + int unpack_float(float* val, size_t* buffer_len); + int unpack_string(char** val, size_t* buffer_len); + + int rank() const { return rank_; } + + grib_accessor* accessor = nullptr; + grib_accessors_list* next_ = nullptr; + grib_accessors_list* prev_ = nullptr; + grib_accessors_list* last_ = nullptr; +private: + int rank_ = 0; +}; + +grib_accessors_list* grib_accessors_list_create(grib_context* c); +void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al); diff --git a/src/action_class_gen.cc b/src/action_class_gen.cc index 641aa3c92..722391c7f 100644 --- a/src/action_class_gen.cc +++ b/src/action_class_gen.cc @@ -152,7 +152,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* loade static int notify_change(grib_action* act, grib_accessor* notified, grib_accessor* changed) { if (act->default_value) - return grib_pack_expression(notified, grib_arguments_get_expression(grib_handle_of_accessor(notified), act->default_value, 0)); + return notified->pack_expression(grib_arguments_get_expression(grib_handle_of_accessor(notified), act->default_value, 0)); return GRIB_SUCCESS; } diff --git a/src/action_class_hash_array.cc b/src/action_class_hash_array.cc index b01077870..430fdd92a 100644 --- a/src/action_class_hash_array.cc +++ b/src/action_class_hash_array.cc @@ -168,13 +168,14 @@ grib_action* grib_action_create_hash_array(grib_context* context, a->hash_array = hash_array; if (hash_array) { - grib_hash_array_value* ha = hash_array; - grib_trie* index = grib_trie_new(context); - while (ha) { - ha->index = index; - grib_trie_insert_no_replace(index, ha->name, ha); - ha = ha->next; - } + grib_context_log(context, GRIB_LOG_FATAL, "%s: 'hash_array_list' not implemented", __func__); + // grib_hash_array_value* ha = hash_array; + // grib_trie* index = grib_trie_new(context); + // while (ha) { + // ha->index = index; + // grib_trie_insert_no_replace(index, ha->name, ha); + // ha = ha->next; + // } } act->name = grib_context_strdup_persistent(context, name); @@ -185,17 +186,12 @@ grib_action* grib_action_create_hash_array(grib_context* context, static void dump(grib_action* act, FILE* f, int lvl) { - int i = 0; - - for (i = 0; i < lvl; i++) - grib_context_print(act->context, f, " "); - - printf("hash_array(%s) { ", act->name); - printf("\n"); - - for (i = 0; i < lvl; i++) - grib_context_print(act->context, f, " "); - printf("}\n"); + // for (int i = 0; i < lvl; i++) + // grib_context_print(act->context, f, " "); + // printf("hash_array(%s) { \n", act->name); + // for (int i = 0; i < lvl; i++) + // grib_context_print(act->context, f, " "); + // printf("}\n"); } @@ -203,14 +199,16 @@ static void destroy(grib_context* context, grib_action* act) { grib_action_hash_array* self = (grib_action_hash_array*)act; - grib_hash_array_value* v = self->hash_array; - if (v) - grib_trie_delete(v->index); - while (v) { - grib_hash_array_value* n = v->next; - grib_hash_array_value_delete(context, v); - v = n; - } + // This is currently unset. So assert that it is NULL + const grib_hash_array_value* v = self->hash_array; + Assert(v == NULL); + // if (v) + // grib_trie_delete(v->index); + // while (v) { + // grib_hash_array_value* n = v->next; + // grib_hash_array_value_delete(context, v); + // v = n; + // } grib_context_free_persistent(context, self->masterDir); grib_context_free_persistent(context, self->localDir); @@ -338,6 +336,6 @@ grib_hash_array_value* get_hash_array(grib_handle* h, grib_action* a) const char* get_hash_array_full_path(grib_action* a) { - grib_action_hash_array* self = (grib_action_hash_array*)a; + const grib_action_hash_array* self = (grib_action_hash_array*)a; return self->full_path; } diff --git a/src/action_class_list.cc b/src/action_class_list.cc index 0a4b8a630..163a6da55 100644 --- a/src/action_class_list.cc +++ b/src/action_class_list.cc @@ -10,7 +10,6 @@ /*************************************************************************** * Jean Baptiste Filippi - 01.11.2005 * - * Enrico Fucile * ***************************************************************************/ #include "grib_api_internal.h" /* @@ -107,7 +106,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) long val = 0; if ((ret = grib_expression_evaluate_long(p->h, a->expression, &val)) != GRIB_SUCCESS) { - grib_context_log(p->h->context, GRIB_LOG_DEBUG, "List %s creating %d values unable to evaluate long", act->name, val); + grib_context_log(p->h->context, GRIB_LOG_DEBUG, "List %s creating %ld values: Unable to evaluate long", act->name, val); return ret; } @@ -161,12 +160,12 @@ static grib_action* reparse(grib_action* a, grib_accessor* acc, int* doit) { grib_action_list* self = (grib_action_list*)a; - int ret = 0; long val = 0; - if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(acc), self->expression, &val)) != GRIB_SUCCESS) { + int ret = grib_expression_evaluate_long(grib_handle_of_accessor(acc), self->expression, &val); + if (ret != GRIB_SUCCESS) { grib_context_log(acc->context, GRIB_LOG_ERROR, - "List %s creating %ld values, unable to evaluate long", acc->name, val); + "List %s creating %ld values: Unable to evaluate long", acc->name, val); } *doit = (val != acc->loop); diff --git a/src/action_class_noop.cc b/src/action_class_noop.cc index a898da06a..aa5196a46 100644 --- a/src/action_class_noop.cc +++ b/src/action_class_noop.cc @@ -73,16 +73,15 @@ grib_action* grib_action_create_noop(grib_context* context, const char* fname) { char buf[1024]; - grib_action_noop* a; grib_action_class* c = grib_action_class_noop; 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_noop*)act; + grib_action_noop* a = (grib_action_noop*)act; act->context = context; - snprintf(buf, 1024, "_noop%p", (void*)a); + snprintf(buf, sizeof(buf), "_noop%p", (void*)a); act->name = grib_context_strdup_persistent(context, buf); diff --git a/src/action_class_remove.cc b/src/action_class_remove.cc index 26ab6760b..eff91cdce 100644 --- a/src/action_class_remove.cc +++ b/src/action_class_remove.cc @@ -94,7 +94,7 @@ static void remove_accessor(grib_accessor* a) grib_section* s = NULL; int id; - if (!a || !a->previous) + if (!a || !a->previous_) return; s = a->parent; @@ -103,25 +103,21 @@ static void remove_accessor(grib_accessor* a) grib_handle_of_accessor(a)->accessors[id] = NULL; } - if (a->next) - a->previous->next = a->next; + if (a->next_) + a->previous_->next_ = a->next_; else return; - a->next->previous = a->previous; + a->next_->previous_ = a->previous_; - grib_accessor_delete(s->h->context, a); - - return; + a->destroy(s->h->context); } static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) { grib_action_remove* a = (grib_action_remove*)act; - grib_accessor* ga = NULL; - - ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 0)); + grib_accessor* ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 0)); if (ga) { remove_accessor(ga); @@ -134,15 +130,15 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) static void dump(grib_action* act, FILE* f, int lvl) { - grib_action_remove* a = (grib_action_remove*)act; - - int i = 0; - - for (i = 0; i < lvl; i++) - grib_context_print(act->context, f, " "); - - grib_context_print(act->context, f, "remove %s as %s in %s\n", grib_arguments_get_name(0, a->args, 0), act->name, grib_arguments_get_name(0, a->args, 1)); + grib_context_log(act->context, GRIB_LOG_ERROR, "%s: dump not implemented", act->name); + // grib_action_remove* a = (grib_action_remove*)act; + // int i = 0; + // for (i = 0; i < lvl; i++) + // grib_context_print(act->context, f, " "); + // grib_context_print(act->context, f, "remove %s as %s in %s\n", + // grib_arguments_get_name(0, a->args, 0), act->name, grib_arguments_get_name(0, a->args, 1)); } + static void destroy(grib_context* context, grib_action* act) { grib_action_remove* a = (grib_action_remove*)act; @@ -151,4 +147,3 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } - diff --git a/src/action_class_set.cc b/src/action_class_set.cc index 1068181d5..fee2ca406 100644 --- a/src/action_class_set.cc +++ b/src/action_class_set.cc @@ -114,8 +114,8 @@ static int execute(grib_action* a, grib_handle* h) static void dump(grib_action* act, FILE* f, int lvl) { - int i = 0; - grib_action_set* self = (grib_action_set*)act; + int i = 0; + const grib_action_set* self = (grib_action_set*)act; for (i = 0; i < lvl; i++) grib_context_print(act->context, f, " "); grib_context_print(act->context, f, self->name); diff --git a/src/action_class_set_missing.cc b/src/action_class_set_missing.cc index 3a40038b5..03bd4ffc3 100644 --- a/src/action_class_set_missing.cc +++ b/src/action_class_set_missing.cc @@ -8,9 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/*************************************************************************** - * Enrico Fucile * - ***************************************************************************/ #include "grib_api_internal.h" /* This is used by make_class.pl @@ -103,12 +100,13 @@ static int execute(grib_action* a, grib_handle* h) static void dump(grib_action* act, FILE* f, int lvl) { - int i = 0; - const grib_action_set_missing* self = (grib_action_set_missing*)act; - for (i = 0; i < lvl; i++) - grib_context_print(act->context, f, " "); - grib_context_print(act->context, f, self->name); - printf("\n"); + grib_context_log(act->context, GRIB_LOG_ERROR, "%s %s(): Not implemented", __FILE__, __func__); + // int i = 0; + // const grib_action_set_missing* self = (grib_action_set_missing*)act; + // for (i = 0; i < lvl; i++) + // grib_context_print(act->context, f, " "); + // grib_context_print(act->context, f, self->name); + // printf("\n"); } static void destroy(grib_context* context, grib_action* act) diff --git a/src/action_class_template.cc b/src/action_class_template.cc index 8f240ea27..79fd2aeaf 100644 --- a/src/action_class_template.cc +++ b/src/action_class_template.cc @@ -10,7 +10,6 @@ /*************************************************************************** * Jean Baptiste Filippi - 01.11.2005 * - * Enrico Fucile * ***************************************************************************/ #include "grib_api_internal.h" @@ -115,19 +114,17 @@ static void dump(grib_action* act, FILE* f, int lvl) grib_context_print(act->context, f, "Template %s %s\n", act->name, a->arg); } -grib_action* get_empty_template(grib_context* c, int* err) +static grib_action* get_empty_template(grib_context* c, int* err) { char fname[] = "empty_template.def"; - char* path = 0; - - path = grib_context_full_defs_path(c, fname); + const char* path = grib_context_full_defs_path(c, fname); if (path) { *err = GRIB_SUCCESS; return grib_parse_file(c, path); } else { *err = GRIB_INTERNAL_ERROR; - grib_context_log(c, GRIB_LOG_ERROR, "get_empty_template: unable to get template %s", fname); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to get template %s", __func__, fname); return NULL; } } diff --git a/src/action_class_transient_darray.cc b/src/action_class_transient_darray.cc index 9990beb41..276dcf3fa 100644 --- a/src/action_class_transient_darray.cc +++ b/src/action_class_transient_darray.cc @@ -117,13 +117,13 @@ static int execute(grib_action* act, grib_handle* h) if (a->flags & GRIB_ACCESSOR_FLAG_CONSTRAINT) grib_dependency_observe_arguments(a, act->default_value); - return grib_pack_double(a, self->darray->v, &len); + return a->pack_double(self->darray->v, &len); } static void dump(grib_action* act, FILE* f, int lvl) { - int i = 0; - grib_action_transient_darray* self = (grib_action_transient_darray*)act; + int i = 0; + const grib_action_transient_darray* self = (grib_action_transient_darray*)act; for (i = 0; i < lvl; i++) grib_context_print(act->context, f, " "); grib_context_print(act->context, f, self->name); diff --git a/src/bufr_keys_iterator.cc b/src/bufr_keys_iterator.cc index e1ab89697..d22b0349b 100644 --- a/src/bufr_keys_iterator.cc +++ b/src/bufr_keys_iterator.cc @@ -176,7 +176,7 @@ int codes_bufr_keys_iterator_next(bufr_keys_iterator* kiter) return 1; } else { - kiter->current = grib_next_accessor(kiter->current); + kiter->current = kiter->current->next_accessor(); kiter->attributes = 0; if (kiter->prefix) { grib_context_free(kiter->current->context, kiter->prefix); @@ -187,7 +187,7 @@ int codes_bufr_keys_iterator_next(bufr_keys_iterator* kiter) } while (kiter->current && skip(kiter)) - kiter->current = grib_next_accessor(kiter->current); + kiter->current = kiter->current->next_accessor(); return kiter->current != NULL; } diff --git a/src/bufr_util.cc b/src/bufr_util.cc index 0b4ffb0e7..95ff8eeb2 100644 --- a/src/bufr_util.cc +++ b/src/bufr_util.cc @@ -220,7 +220,7 @@ static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2, DEBUG_ASSERT(hdr->ecmwfLocalSectionPresent); - if (hdr->rdbType == 2 || hdr->rdbType == 3 || hdr->rdbType == 8 || hdr->rdbType == 12) { + if (hdr->rdbType == 2 || hdr->rdbType == 3 || hdr->rdbType == 8 || hdr->rdbType == 12 || hdr->rdbType == 30) { isSatelliteType = true; } if (isSatelliteType || hdr->numberOfSubsets > 1) { diff --git a/src/codes_util.cc b/src/codes_util.cc index 1b73432f8..57613109a 100644 --- a/src/codes_util.cc +++ b/src/codes_util.cc @@ -213,6 +213,37 @@ int is_date_valid(long year, long month, long day, long hour, long minute, doubl return 1; } +// Return 1 if input date is valid. Otherwise 0 +// Note: In the 24-hour time notation, the day begins at midnight, 00:00 or 0:00, +// and the last minute of the day begins at 23:59. +// Where convenient, the notation 24:00 may also be used to refer to midnight +// at the end of a given date — that is, 24:00 of one day is the same time +// as 00:00 of the following day +int is_time_valid(long number) +{ + // Number should be 4 digits i.e., HHMM + if (number < 0 || number > 9999) { + return 0; + } + + // Extract hours and minutes + long hours = number / 100; // Get the first two digits as hours + long minutes = number % 100; // Get the last two digits as minutes + + // Check if hours are within the valid range (00-24) + if (hours < 0 || hours > 24) { + return 0; + } + + // Check if minutes are within the valid range (00-59) + if (minutes < 0 || minutes > 59) { + return 0; + } + + // All checks pass + return 1; +} + static float float_epsilon(void) { float floatEps = 1.0; diff --git a/src/grib_concept_index.cc b/src/deprecated/grib_concept_index.cc similarity index 66% rename from src/grib_concept_index.cc rename to src/deprecated/grib_concept_index.cc index 9cb8f0d1d..8ca1794a4 100644 --- a/src/grib_concept_index.cc +++ b/src/deprecated/grib_concept_index.cc @@ -1,30 +1,49 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/* - * Description: concept index - * - */ - #include "grib_api_internal.h" +typedef struct grib_concept_index_keys grib_concept_index_keys; +typedef struct grib_concept_index grib_concept_index; +typedef struct grib_conditions_tree grib_conditions_tree; +typedef struct grib_concept_index_entry grib_concept_index_entry; +typedef struct grib_concept_index_keys grib_concept_index_keys; + +struct grib_concept_index_entry { + char* name; + char* value; + int type; + grib_concept_index_entry* next; +}; + +struct grib_concept_index_keys { + char* name; + int type; + grib_concept_index_keys* next; +}; + +struct grib_concept_index { + grib_context* context; + grib_concept_index_keys* keys; + grib_conditions_tree* conditions; +}; + +struct grib_conditions_tree { + char* value; + void* object; + grib_conditions_tree* next; + grib_conditions_tree* next_key; +}; + + static grib_concept_index_entry* index_entry_new(grib_context* c, grib_concept_index_keys* keys) { grib_concept_index_entry* entry = NULL; + grib_concept_index_entry* e; Assert(keys); if (!c) c = grib_context_get_default(); - entry = grib_context_malloc_clear(c, sizeof(grib_concept_index_entry)); + entry = (grib_concept_index_entry*)grib_context_malloc_clear(c, sizeof(grib_concept_index_entry)); if (!entry) grib_context_log(c, GRIB_LOG_FATAL, "grib_concept_index_entry unable to allocate"); e = entry; @@ -32,7 +51,7 @@ static grib_concept_index_entry* index_entry_new(grib_context* c, grib_concept_i while (keys && keys->name) { e->name = grib_context_strdup(c, keys->name); e->type = keys->type; - e->next = grib_context_malloc_clear(c, sizeof(grib_concept_index_entry)); + e->next = (grib_concept_index_entry*)grib_context_malloc_clear(c, sizeof(grib_concept_index_entry)); if (!e->next) grib_context_log(c, GRIB_LOG_FATAL, "grib_concept_index_entry unable to allocate"); @@ -65,17 +84,17 @@ static int index_insert_entry(grib_concept_index* index, grib_concept_index_entr while (keys->name) { if (!cur) { - cur = grib_context_malloc_clear_persistent(index->context, sizeof(grib_conditions_tree)); + cur = (grib_conditions_tree*)grib_context_malloc_clear_persistent(index->context, sizeof(grib_conditions_tree)); if (!cur) grib_context_log(index->context, GRIB_LOG_FATAL, "index_insert_entry unable to allocate"); prev->next = cur; } - value = entry->value ? entry->value : "*"; + char* value = entry->value ? entry->value : (char*)"*"; while (cur && (!cur->value || (found = !strcmp(cur->value, value)) == 0)) cur = cur->next; if (!found) { - cur->next = grib_context_malloc_clear_persistent(index->context, sizeof(grib_conditions_tree)); + cur->next = (grib_conditions_tree*)grib_context_malloc_clear_persistent(index->context, sizeof(grib_conditions_tree)); Assert(cur->next); cur = cur->next; } @@ -103,6 +122,9 @@ static void index_add_conditions(grib_concept_index* index, grib_concept_conditi char s[512] = {0,}; grib_concept_index_entry* e; grib_concept_index_entry* entry = index_entry_new(index->context, index->keys); + long lres; + double dres; + int err = 0; while (c) { size_t size = 512; @@ -136,7 +158,7 @@ static void index_add_conditions(grib_concept_index* index, grib_concept_conditi e->value = grib_context_strdup(index->context, s); if (!e->name) { e->name = grib_context_strdup(index->context, c->name); - e->next = grib_context_malloc_clear_persistent(index->context, sizeof(grib_concept_index_entry)); + e->next = (grib_concept_index_entry*)grib_context_malloc_clear_persistent(index->context, sizeof(grib_concept_index_entry)); if (!e->next) grib_context_log(index->context, GRIB_LOG_FATAL, "index_add_conditions unable to allocate"); } @@ -156,14 +178,13 @@ grib_concept_index* grib_concept_index_new_from_concept(grib_context* c, grib_co if (!c) c = grib_context_get_default(); - index = grib_context_malloc_clear_persistent(c, sizeof(grib_concept_index)); - index->keys = grib_context_malloc_clear_persistent(c, sizeof(grib_concept_index_key)); - index->conditions = grib_context_malloc_clear_persistent(c, sizeof(grib_conditions_tree)); - index->conditions = grib_context_malloc_clear_persistent(c, sizeof(grib_conditions_tree)); + index = (grib_concept_index*)grib_context_malloc_clear_persistent(c, sizeof(grib_concept_index)); + index->keys = (grib_concept_index_keys*)grib_context_malloc_clear_persistent(c, sizeof(grib_concept_index_keys)); + index->conditions = (grib_conditions_tree*)grib_context_malloc_clear_persistent(c, sizeof(grib_conditions_tree)); index->context = c; while (concept) { - index_add_conditions(index, concept->conditions, err); + index_add_conditions(index, concept->conditions); concept = concept->next; } diff --git a/src/grib_expression_class_column.cc b/src/deprecated/grib_expression_class_column.cc similarity index 100% rename from src/grib_expression_class_column.cc rename to src/deprecated/grib_expression_class_column.cc diff --git a/src/grib_expression_class_constant.cc b/src/deprecated/grib_expression_class_constant.cc similarity index 93% rename from src/grib_expression_class_constant.cc rename to src/deprecated/grib_expression_class_constant.cc index e669a6049..bedacd013 100644 --- a/src/grib_expression_class_constant.cc +++ b/src/deprecated/grib_expression_class_constant.cc @@ -17,7 +17,7 @@ CLASS = expression IMPLEMENTS = destroy IMPLEMENTS = native_type - IMPLEMENTS = evaluate;print + IMPLEMENTS = print IMPLEMENTS = add_dependency MEMBERS = long value END_CLASS_DEF @@ -78,12 +78,6 @@ static void init_class(grib_expression_class* c) } /* END_CLASS_IMP */ -static long evaluate(grib_expression* g, grib_handle* h) -{ - const grib_expression_constant* e = (grib_expression_constant*)g; - return e->value; -} - static void print(grib_context* c, grib_expression* g, grib_handle* f) { const grib_expression_constant* e = (grib_expression_constant*)g; diff --git a/src/grib_loader_from_array.cc b/src/deprecated/grib_loader_from_array.cc similarity index 100% rename from src/grib_loader_from_array.cc rename to src/deprecated/grib_loader_from_array.cc diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 3537fc05f..ab2d4531e 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -26,155 +26,89 @@ grib_action* grib_action_create_if(grib_context* context, grib_expression* expre grib_action* grib_action_create_switch(grib_context* context, grib_arguments* args, grib_case* Case, grib_action* Default); grib_case* grib_case_new(grib_context* c, grib_arguments* values, grib_action* action); -/* grib_accessor_class_g1fcperiod.cc */ - -/* grib_accessor_class_g1end_of_interval_monthly.cc */ - -/* grib_accessor_class_mars_param.cc */ - -/* action_class_section.cc */ - -/* action_class_list.cc*/ +/* action_class_list.cc */ grib_action* grib_action_create_list(grib_context* context, const char* name, grib_expression* expression, grib_action* block); -/* action_class_while.cc*/ +/* action_class_while.cc */ grib_action* grib_action_create_while(grib_context* context, grib_expression* expression, grib_action* block); -/* action_class_put.cc*/ +/* action_class_put.cc */ grib_action* grib_action_create_put(grib_context* context, const char* name, grib_arguments* args); -/* action_class_meta.cc*/ +/* action_class_meta.cc */ grib_action* grib_action_create_meta(grib_context* context, const char* name, const char* op, grib_arguments* params, grib_arguments* default_value, unsigned long flags, const char* name_space); -/* action_class_remove.cc*/ +/* action_class_remove.cc */ grib_action* grib_action_create_remove(grib_context* context, grib_arguments* args); -/* action_class_rename.cc*/ +/* action_class_rename.cc */ grib_action* grib_action_create_rename(grib_context* context, char* the_old, char* the_new); -/* action_class_assert.cc*/ +/* action_class_assert.cc */ grib_action* grib_action_create_assert(grib_context* context, grib_expression* expression); -/* action_class_template.cc*/ +/* action_class_template.cc */ grib_action* grib_action_create_template(grib_context* context, int nofail, const char* name, const char* arg1); -grib_action* get_empty_template(grib_context* c, int* err); -/* action_class_trigger.cc*/ +/* action_class_trigger.cc */ grib_action* grib_action_create_trigger(grib_context* context, grib_arguments* args, grib_action* block); -/* action_class_when.cc*/ +/* action_class_when.cc */ grib_action* grib_action_create_when(grib_context* context, grib_expression* expression, grib_action* block_true, grib_action* block_false); -/* action_class_concept.cc*/ +/* action_class_concept.cc */ grib_concept_value* action_concept_get_concept(grib_accessor* a); int action_concept_get_nofail(grib_accessor* a); grib_action* grib_action_create_concept(grib_context* context, const char* name, grib_concept_value* concept_value, const char* basename, const char* name_space, const char* defaultkey, const char* masterDir, const char* localDir, const char* ecmfDir, int flags, int nofail); int get_concept_condition_string(grib_handle* h, const char* key, const char* value, char* result); -/* action_class_hash_array.cc*/ +/* action_class_hash_array.cc */ grib_action* grib_action_create_hash_array(grib_context* context, const char* name, grib_hash_array_value* hash_array, const char* basename, const char* name_space, const char* defaultkey, const char* masterDir, const char* localDir, const char* ecmfDir, int flags, int nofail); grib_hash_array_value* get_hash_array(grib_handle* h, grib_action* a); const char* get_hash_array_full_path(grib_action* a); -/* action_class_set.cc*/ +/* action_class_set.cc */ grib_action* grib_action_create_set(grib_context* context, const char* name, grib_expression* expression, int nofail); -/* action_class_set_darray.cc*/ +/* action_class_set_darray.cc */ grib_action* grib_action_create_set_darray(grib_context* context, const char* name, grib_darray* darray); -/* action_class_set_sarray.cc*/ +/* action_class_set_sarray.cc */ grib_action* grib_action_create_set_sarray(grib_context* context, const char* name, grib_sarray* sarray); -/* action_class_noop.cc*/ +/* action_class_noop.cc */ grib_action* grib_action_create_noop(grib_context* context, const char* fname); -/* action_class_write.cc*/ +/* action_class_write.cc */ grib_action* grib_action_create_write(grib_context* context, const char* name, int append, int padtomultiple); -/* action_class_print.cc*/ +/* action_class_print.cc */ grib_action* grib_action_create_print(grib_context* context, const char* name, char* outname); -/* action_class_close.cc*/ +/* action_class_close.cc */ grib_action* grib_action_create_close(grib_context* context, char* filename); -/* action_class_variable.cc*/ +/* action_class_variable.cc */ grib_action* grib_action_create_variable(grib_context* context, const char* name, const char* op, const long len, grib_arguments* params, grib_arguments* default_value, int flags, const char* name_space); -/* action_class_modify.cc*/ +/* action_class_modify.cc */ grib_action* grib_action_create_modify(grib_context* context, const char* name, long flags); -/* action_class_transient_darray.cc*/ +/* action_class_transient_darray.cc */ grib_action* grib_action_create_transient_darray(grib_context* context, const char* name, grib_darray* darray, int flags); /* grib_accessor.cc*/ -void grib_accessor_dump(grib_accessor* a, grib_dumper* f); -int grib_pack_missing(grib_accessor* a); -int grib_pack_zero(grib_accessor* a); -int grib_is_missing_internal(grib_accessor* a); -int grib_pack_double(grib_accessor* a, const double* v, size_t* len); -int grib_pack_float(grib_accessor* a, const float* v, size_t* len); -int grib_pack_expression(grib_accessor* a, grib_expression* e); -int grib_pack_string(grib_accessor* a, const char* v, size_t* len); -int grib_pack_string_array(grib_accessor* a, const char** v, size_t* len); -int grib_pack_long(grib_accessor* a, const long* v, size_t* len); -int grib_pack_bytes(grib_accessor* a, const unsigned char* v, size_t* len); -int grib_unpack_bytes(grib_accessor* a, unsigned char* v, size_t* len); -int grib_unpack_double_subarray(grib_accessor* a, double* v, size_t start, size_t len); -int grib_unpack_double(grib_accessor* a, double* v, size_t* len); -int grib_unpack_float(grib_accessor* a, float* v, size_t* len); -int grib_unpack_double_element(grib_accessor* a, size_t i, double* v); -int grib_unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array); -int grib_unpack_float_element(grib_accessor* a, size_t i, float* v); -int grib_unpack_float_element_set(grib_accessor* a, const size_t* index_array, size_t len, float* val_array); -int grib_unpack_string(grib_accessor* a, char* v, size_t* len); -int grib_unpack_string_array(grib_accessor* a, char** v, size_t* len); -int grib_accessors_list_unpack_long(grib_accessors_list* al, long* val, size_t* buffer_len); -int grib_accessors_list_unpack_double(grib_accessors_list* al, double* val, size_t* buffer_len); -int grib_accessors_list_unpack_float(grib_accessors_list* al, float* val, size_t* buffer_len); -int grib_accessors_list_unpack_string(grib_accessors_list* al, char** val, size_t* buffer_len); -int grib_unpack_long(grib_accessor* a, long* v, size_t* len); -long grib_accessor_get_native_type(grib_accessor* a); -long grib_get_next_position_offset(grib_accessor* a); -long grib_string_length(grib_accessor* a); -long grib_byte_offset(grib_accessor* a); -long grib_byte_count(grib_accessor* a); -int grib_value_count(grib_accessor* a, long* count); -int grib_accessors_list_value_count(grib_accessors_list* al, size_t* count); -int grib_accessor_notify_change(grib_accessor* a, grib_accessor* changed); -void grib_init_accessor(grib_accessor* a, const long len, grib_arguments* args); -void grib_accessor_delete(grib_context* ct, grib_accessor* a); -grib_accessor* grib_accessor_clone(grib_accessor* a, grib_section* s, int* err); -void grib_update_size(grib_accessor* a, size_t len); -int grib_nearest_smaller_value(grib_accessor* a, double val, double* nearest); -size_t grib_preferred_size(grib_accessor* a, int from_handle); -grib_accessor* grib_next_accessor(grib_accessor* a); -void grib_resize(grib_accessor* a, size_t new_size); -int grib_compare_accessors(grib_accessor* a1, grib_accessor* a2, int compare_flags); -int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_if_clash); -int grib_accessor_replace_attribute(grib_accessor* a, grib_accessor* attr); -int grib_accessor_delete_attribute(grib_accessor* a, const char* name); -grib_accessor* grib_accessor_get_attribute_by_index(grib_accessor* a, int index); -const char* grib_accessor_get_name(grib_accessor* a); -grib_accessor* grib_accessor_get_attribute_index(grib_accessor* a, const char* name, int* index); -int grib_accessor_has_attributes(grib_accessor* a); -grib_accessor* grib_accessor_get_attribute(grib_accessor* a, const char* name); -grib_accessors_list* grib_accessors_list_create(grib_context* c); -void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank); -grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al); -grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a); -void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al); -/* grib_concept.cc*/ +/* grib_concept.cc */ grib_concept_value* grib_concept_value_new(grib_context* c, const char* name, grib_concept_condition* conditions); void grib_concept_value_delete(grib_context* c, grib_concept_value* v); grib_concept_condition* grib_concept_condition_new(grib_context* c, const char* name, grib_expression* expression, grib_iarray* iarray); void grib_concept_condition_delete(grib_context* c, grib_concept_condition* v); -/* grib_hash_array.cc*/ +/* grib_hash_array.cc */ grib_hash_array_value* grib_integer_hash_array_value_new(grib_context* c, const char* name, grib_iarray* array); -void grib_hash_array_value_delete(grib_context* c, grib_hash_array_value* v); -/* grib_bufr_descriptor.cc*/ +/* grib_bufr_descriptor.cc */ bufr_descriptor* grib_bufr_descriptor_new(grib_accessor* tables_accessor, int code, int silent, int* err); bufr_descriptor* grib_bufr_descriptor_clone(bufr_descriptor* d); int grib_bufr_descriptor_set_code(bufr_descriptor* v, int code); @@ -182,7 +116,7 @@ void grib_bufr_descriptor_set_scale(bufr_descriptor* v, long scale); int grib_bufr_descriptor_can_be_missing(const bufr_descriptor* v); void grib_bufr_descriptor_delete(bufr_descriptor* v); -/* grib_bufr_descriptors_array.cc*/ +/* grib_bufr_descriptors_array.cc */ bufr_descriptors_array* grib_bufr_descriptors_array_new(grib_context* c, size_t size, size_t incsize); bufr_descriptor* grib_bufr_descriptors_array_pop_front(bufr_descriptors_array* a); bufr_descriptors_array* grib_bufr_descriptors_array_push(bufr_descriptors_array* v, bufr_descriptor* val); @@ -192,7 +126,7 @@ void grib_bufr_descriptors_array_delete(bufr_descriptors_array* v); void grib_bufr_descriptors_array_delete_array(bufr_descriptors_array* v); size_t grib_bufr_descriptors_array_used_size(bufr_descriptors_array* v); -/* grib_darray.cc*/ +/* grib_darray.cc */ void grib_darray_print(const char* title, const grib_darray* darray); grib_darray* grib_darray_new(grib_context* c, size_t size, size_t incsize); grib_darray* grib_darray_push(grib_context* c, grib_darray* v, double val); @@ -200,7 +134,7 @@ void grib_darray_delete(grib_context* c, grib_darray* v); int grib_darray_is_constant(grib_darray* v, double epsilon); size_t grib_darray_used_size(grib_darray* v); -/* grib_sarray.cc*/ +/* grib_sarray.cc */ void grib_sarray_print(const char* title, const grib_sarray* sarray); grib_sarray* grib_sarray_new(grib_context* c, size_t size, size_t incsize); grib_sarray* grib_sarray_push(grib_context* c, grib_sarray* v, char* val); @@ -209,13 +143,13 @@ void grib_sarray_delete_content(grib_context* c, grib_sarray* v); char** grib_sarray_get_array(grib_context* c, grib_sarray* v); size_t grib_sarray_used_size(grib_sarray* v); -/* grib_oarray.cc*/ +/* grib_oarray.cc */ grib_oarray* grib_oarray_new(grib_context* c, size_t size, size_t incsize); grib_oarray* grib_oarray_push(grib_context* c, grib_oarray* v, void* val); void grib_oarray_delete(grib_context* c, grib_oarray* v); void* grib_oarray_get(grib_oarray* v, int i); -/* grib_iarray.cc*/ +/* grib_iarray.cc */ void grib_iarray_print(const char* title, const grib_iarray* iarray); grib_iarray* grib_iarray_new(grib_context* c, size_t size, size_t incsize); long grib_iarray_pop(grib_iarray* a); @@ -226,7 +160,7 @@ void grib_iarray_delete_array(grib_iarray* v); long* grib_iarray_get_array(grib_iarray* v); size_t grib_iarray_used_size(grib_iarray* v); -/* grib_vdarray.cc*/ +/* grib_vdarray.cc */ void grib_vdarray_print(const char* title, const grib_vdarray* vdarray); grib_vdarray* grib_vdarray_new(grib_context* c, size_t size, size_t incsize); grib_vdarray* grib_vdarray_push(grib_context* c, grib_vdarray* v, grib_darray* val); @@ -234,7 +168,7 @@ void grib_vdarray_delete(grib_context* c, grib_vdarray* v); void grib_vdarray_delete_content(grib_context* c, grib_vdarray* v); size_t grib_vdarray_used_size(grib_vdarray* v); -/* grib_vsarray.cc*/ +/* grib_vsarray.cc */ void grib_vsarray_print(const char* title, const grib_vsarray* vdarray); grib_vsarray* grib_vsarray_new(grib_context* c, size_t size, size_t incsize); grib_vsarray* grib_vsarray_push(grib_context* c, grib_vsarray* v, grib_sarray* val); @@ -242,7 +176,7 @@ void grib_vsarray_delete(grib_context* c, grib_vsarray* v); void grib_vsarray_delete_content(grib_context* c, grib_vsarray* v); size_t grib_vsarray_used_size(grib_vsarray* v); -/* grib_viarray.cc*/ +/* grib_viarray.cc */ void grib_viarray_print(const char* title, const grib_viarray* viarray); grib_viarray* grib_viarray_new(grib_context* c, size_t size, size_t incsize); grib_viarray* grib_viarray_push(grib_context* c, grib_viarray* v, grib_iarray* val); @@ -260,12 +194,8 @@ void grib_viarray_delete_content(grib_context* c, grib_viarray* v); /* grib_accessor_class_bits_per_value.cc*/ /* grib_accessor_class_bufr_data_array.cc*/ -grib_vsarray* accessor_bufr_data_array_get_stringValues(grib_accessor* a); -grib_accessors_list* accessor_bufr_data_array_get_dataAccessors(grib_accessor* a); -grib_trie_with_rank* accessor_bufr_data_array_get_dataAccessorsTrie(grib_accessor* a); -void accessor_bufr_data_array_set_unpackMode(grib_accessor* a, int unpackMode); -/* grib_accessor_class_bufr_data_element.cc*/ +/* grib_accessor_class_bufr_data_element.cc */ void accessor_bufr_data_element_set_index(grib_accessor* a, long index); void accessor_bufr_data_element_set_type(grib_accessor* a, int type); void accessor_bufr_data_element_set_numberOfSubsets(grib_accessor* a, long numberOfSubsets); @@ -276,47 +206,11 @@ void accessor_bufr_data_element_set_numericValues(grib_accessor* a, grib_vdarray void accessor_bufr_data_element_set_stringValues(grib_accessor* a, grib_vsarray* stringValues); void accessor_bufr_data_element_set_elementsDescriptorsIndex(grib_accessor* a, grib_viarray* elementsDescriptorsIndex); -/* grib_accessor_class_bufr_elements_table.cc*/ +/* grib_accessor_class_bufr_elements_table.cc */ int bufr_descriptor_is_marker(bufr_descriptor* d); bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, int code, int* err); -/* grib_accessor_class_bufr_group.cc*/ - -/* grib_accessor_class_bufr_string_values.cc*/ - -/* grib_accessor_class_pack_bufr_values.cc*/ - -/* grib_accessor_class_bufr_extract_area_subsets.cc*/ - -/* grib_accessor_class_bufr_extract_datetime_subsets.cc*/ - -/* grib_accessor_class_group.cc*/ - -/* grib_accessor_class_unpack_bufr_values.cc*/ - -/* grib_accessor_class_non_alpha.cc*/ - -/* grib_accessor_class_g1bitmap.cc*/ - -/* grib_accessor_class_g2bitmap.cc*/ - -/* grib_accessor_class_concept.cc*/ - -/* grib_accessor_class_hash_array.cc*/ - -/* grib_accessor_class_decimal_precision.cc*/ - -/* grib_accessor_class_divdouble.cc*/ - -/* grib_accessor_class_budgdate.cc*/ - -/* grib_accessor_class_validity_date.cc*/ - -/* grib_accessor_class_validity_time.cc*/ - -/* grib_accessor_class_bytes.cc*/ - -/* grib_accessor_class.cc*/ +/* grib_accessor_class.cc */ grib_section* grib_create_root_section(const grib_context* context, grib_handle* h); grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, const long len, grib_arguments* params); void grib_push_accessor(grib_accessor* a, grib_block_of_accessors* l); @@ -326,314 +220,46 @@ int grib_get_block_length(grib_section* s, size_t* l); grib_accessor* find_paddings(grib_section* s); void grib_update_paddings(grib_section* s); -/* grib_accessor_class_change_scanning_direction.cc*/ - -/* grib_accessor_class_change_scanning_direction.cc*/ - -/* grib_accessor_class_check_internal_version.cc*/ - -/* grib_accessor_class_codeflag.cc*/ - -/* grib_accessor_class_smart_table.cc*/ +/* grib_accessor_class_smart_table.cc */ void grib_smart_table_delete(grib_context* c); -/* grib_accessor_class_smart_table_column.cc*/ - -/* grib_accessor_class_codetable.cc*/ +/* grib_accessor_class_codetable.cc */ void grib_codetable_delete(grib_context* c); int codes_codetable_get_contents_malloc(const grib_handle* h, const char* key, code_table_entry** entries, size_t* num_entries); int codes_codetable_check_code_figure(const grib_handle* h, const char* key, long code_figure); int codes_codetable_check_abbreviation(const grib_handle* h, const char* key, const char* abbreviation); -/* grib_accessor_class_codetable_units.cc*/ - -/* grib_accessor_class_codetable_title.cc*/ - -/* grib_accessor_class_count_file.cc*/ - -/* grib_accessor_class_count_total.cc*/ - -/* grib_accessor_class_double.cc*/ - -/* grib_accessor_class_element.cc*/ - -/* grib_accessor_class_evaluate.cc*/ - -/* grib_accessor_class_g1date.cc*/ - -/* grib_accessor_class_g1monthlydate.cc*/ - -/* grib_accessor_class_library_version.cc*/ - -/* grib_accessor_class_when.cc*/ - -/* grib_accessor_class_g1verificationdate.cc*/ - -/* grib_accessor_class_g1day_of_the_year_date.cc*/ - -/* grib_accessor_class_g1_half_byte_codeflag.cc*/ - -/* grib_accessor_class_g1forecastmonth.cc*/ - -/* grib_accessor_class_g1step_range.cc*/ +/* grib_accessor_class_g1step_range.cc */ int grib_g1_step_get_steps(grib_accessor* a, long* start, long* theEnd); -/* grib_accessor_class_g2step_range.cc*/ - -/* grib_accessor_class_data_g22order_packing.cc*/ - -/* grib_accessor_class_mars_step.cc*/ - -/* grib_accessor_class_message_copy.cc*/ - -/* grib_accessor_class_dictionary.cc*/ - -/* grib_accessor_class_latlon_increment.cc*/ - -/* grib_accessor_class_g2date.cc*/ - -/* grib_accessor_class_g2level.cc*/ - -/* grib_accessor_class_g2end_step.cc*/ - -/* grib_accessor_class_g2latlon.cc*/ - -/* grib_accessor_class_g2lon.cc*/ - -/* grib_accessor_class_global_gaussian.cc*/ - -/* grib_accessor_class_gaussian_grid_name.cc*/ - -/* grib_accessor_class_gen.cc*/ - -/* grib_accessor_class_gts_header.cc*/ - -/* grib_accessor_class_ifs_param.cc*/ - -/* grib_accessor_class_uint16.cc*/ - -/* grib_accessor_class_uint32.cc*/ - -/* grib_accessor_class_uint32_little_endian.cc*/ - -/* grib_accessor_class_uint64.cc*/ - -/* grib_accessor_class_uint64_little_endian.cc*/ - -/* grib_accessor_class_uint8.cc*/ - -/* grib_accessor_class_blob.cc*/ - -/* grib_accessor_class_julian_day.cc*/ - -/* grib_accessor_class_julian_date.cc*/ - -/* grib_accessor_class_latlonvalues.cc*/ - -/* grib_accessor_class_latitudes.cc*/ - -/* grib_accessor_class_longitudes.cc*/ - -/* grib_accessor_class_octahedral_gaussian.cc*/ - -/* grib_accessor_class_offset_file.cc*/ - -/* grib_accessor_class_scale.cc*/ - -/* grib_accessor_class_rdbtime_guess_date.cc*/ - -/* grib_accessor_class_from_scale_factor_scaled_value.cc*/ - -/* grib_accessor_class_g2bitmap_present.cc*/ - -/* grib_accessor_class_ibmfloat.cc*/ - -/* grib_accessor_class_ieeefloat.cc*/ - -/* grib_accessor_class_constant.cc*/ - -/* grib_accessor_class_iterator.cc*/ +/* grib_accessor_class_iterator.cc */ grib_iterator* grib_iterator_new(const grib_handle* h, unsigned long flags, int* error); -/* grib_accessor_class_message.cc*/ - -/* grib_accessor_class_nearest.cc*/ +/* grib_accessor_class_nearest.cc */ grib_nearest* grib_nearest_new(const grib_handle* h, int* error); -/* grib_accessor_class_ksec1expver.cc*/ - -/* grib_accessor_class_label.cc*/ - -/* grib_accessor_class_long.cc*/ - -/* grib_accessor_class_lookup.cc*/ - -/* grib_accessor_class_octet_number.cc*/ - -/* grib_accessor_class_headers_only.cc*/ - -/* grib_accessor_class_padding.cc*/ - -/* grib_accessor_class_pad.cc*/ - -/* grib_accessor_class_padto.cc*/ - -/* grib_accessor_class_padtoeven.cc*/ - -/* grib_accessor_class_padtomultiple.cc*/ - -/* grib_accessor_class_section_padding.cc*/ - -/* grib_accessor_class_section_pointer.cc*/ - -/* grib_accessor_class_position.cc*/ - -/* grib_accessor_class_signed.cc*/ - -/* grib_accessor_class_signed_bits.cc*/ - -/* grib_accessor_class_section.cc*/ - -/* grib_accessor_class_step_in_units.cc*/ - -/* grib_accessor_class_section_length.cc*/ - -/* grib_accessor_class_g1_message_length.cc*/ +/* grib_accessor_class_g1_message_length.cc */ int grib_get_g1_message_size(grib_handle* h, grib_accessor* tl, grib_accessor* s4, long* total_length, long* sec4_len); -/* grib_accessor_class_g1_section4_length.cc*/ - -/* grib_accessor_class_size.cc*/ - -/* grib_accessor_class_scale_values.cc*/ - -/* grib_accessor_class_offset_values.cc*/ - -/* grib_accessor_class_sprintf.cc*/ - -/* grib_accessor_class_getenv.cc*/ - -/* grib_accessor_class_round.cc*/ - -/* grib_accessor_class_spectral_truncation.cc*/ - -/* grib_accessor_class_time.cc*/ - -/* grib_accessor_class_transient.cc*/ - -/* grib_accessor_class_values.cc*/ - -/* grib_accessor_class_simple_packing_error.cc*/ - -/* grib_accessor_class_data_simple_packing.cc*/ - -/* grib_accessor_class_data_ccsds_packing.cc*/ - -/* grib_accessor_class_count_missing.cc*/ - -/* grib_accessor_class_data_sh_packed.cc*/ - -/* grib_accessor_class_data_sh_unpacked.cc*/ - -/* grib_accessor_class_number_of_values_data_raw_packing.cc*/ - -/* grib_accessor_class_data_g1simple_packing.cc*/ - -/* grib_accessor_class_data_g1shsimple_packing.cc*/ - -/* grib_accessor_class_data_shsimple_packing.cc*/ - -/* grib_accessor_class_data_dummy_field.cc*/ - -/* grib_accessor_class_variable.cc*/ +/* grib_accessor_class_variable.cc */ void accessor_variable_set_type(grib_accessor* a, int type); -/* grib_accessor_class_second_order_bits_per_value.cc*/ - -/* grib_accessor_class_data_g2simple_packing.cc*/ - -/* grib_accessor_class_data_g2simple_packing_with_preprocessing.cc*/ - -/* grib_accessor_class_data_g2shsimple_packing.cc*/ - -/* grib_accessor_class_data_g2complex_packing.cc*/ - -/* grib_accessor_class_data_g1second_order_row_by_row_packing.cc*/ - -/* grib_accessor_class_data_g1second_order_constant_width_packing.cc*/ - -/* grib_accessor_class_data_g1second_order_general_packing.cc*/ - -/* grib_accessor_class_data_g1second_order_general_extended_packing.cc*/ - -/* grib_accessor_class_g2grid.cc*/ - -/* grib_accessor_class_unexpanded_descriptors.cc*/ - -/* grib_accessor_class_expanded_descriptors.cc*/ +/* grib_accessor_class_expanded_descriptors.cc */ int grib_accessor_class_expanded_descriptors_set_do_expand(grib_accessor* a, long do_expand); bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(grib_accessor* a, int* err); -/* grib_accessor_class_bufrdc_expanded_descriptors.cc*/ - -/* grib_accessor_class_data_apply_bitmap.cc*/ - -/* grib_accessor_class_data_apply_boustrophedonic.cc*/ - -/* grib_accessor_class_data_apply_boustrophedonic_bitmap.cc*/ - -/* grib_accessor_class_data_secondary_bitmap.cc*/ - -/* grib_accessor_class_data_g1secondary_bitmap.cc*/ - -/* grib_accessor_class_data_g2secondary_bitmap.cc*/ - -/* grib_accessor_class_data_jpeg2000_packing.cc*/ - -/* grib_accessor_class_data_png_packing.cc*/ - -/* grib_accessor_class_data_raw_packing.cc*/ - -/* grib_accessor_class_data_complex_packing.cc*/ - -/* grib_accessor_class_data_g1complex_packing.cc*/ - -/* grib_accessor_class_gds_not_present_bitmap.cc*/ - -/* grib_accessor_class_gds_is_present.cc*/ - -/* grib_accessor_class_select_step_template.cc*/ - -/* grib_accessor_class_local_definition.cc*/ - -/* grib_accessor_class_g2_eps.cc*/ - -/* grib_accessor_class_g2_aerosol.cc*/ - -/* grib_accessor_class_g2_chemical.cc*/ - -/* grib_accessor_class_g2_mars_labeling.cc*/ - -/* grib_accessor_class_transient_darray.cc*/ - -/* grib_accessor_class_md5.cc*/ - -/* grib_jasper_encoding.cc*/ +/* grib_jasper_encoding.cc */ int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* n_vals); int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper); -/* grib_openjpeg_encoding.cc*/ +/* grib_openjpeg_encoding.cc */ int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* n_vals); int grib_openjpeg_encode(grib_context* c, j2k_encode_helper* helper); -/* action_class_set_missing.cc*/ +/* action_class_set_missing.cc */ grib_action* grib_action_create_set_missing(grib_context* context, const char* name); -/* grib_accessor_class_number_of_points.cc*/ - -/* grib_accessor_class_suppressed.cc*/ - -/* grib_index.cc*/ +/* grib_index.cc */ int grib_index_compress(grib_index* index); grib_field_tree* grib_read_field_tree(grib_context* c, FILE* fh, grib_file** files, int* err); grib_index* grib_index_new(grib_context* c, const char* key, int* err); @@ -656,71 +282,28 @@ void grib_index_dump(FILE* fout, grib_index* index, unsigned long flags); char* grib_get_field_file(grib_index* index, off_t* offset); grib_handle* grib_handle_new_from_index(grib_index* index, int* err); grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err); -void grib_index_rewind(grib_index* index); int codes_index_set_product_kind(grib_index* index, ProductKind product_kind); int codes_index_set_unpack_bufr(grib_index* index, int unpack); int is_index_file(const char* filename); -/* grib_accessor_class_number_of_points_gaussian.cc*/ - -/* grib_accessor_class_number_of_values.cc*/ - -/* grib_accessor_class_number_of_coded_values.cc*/ - -/* grib_accessor_class_g1number_of_coded_values_sh_complex.cc*/ - -/* grib_accessor_class_g1number_of_coded_values_sh_simple.cc*/ - -/* grib_accessor_class_dirty.cc*/ - -/* grib_accessor_class_statistics.cc*/ - -/* grib_accessor_class_statistics_spectral.cc*/ - -/* grib_accessor_class_unsigned.cc*/ +/* grib_accessor_class_unsigned.cc */ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, int check); -/* grib_accessor_class_unsigned_bits.cc*/ - -/* grib_accessor_class_raw.cc*/ +/* grib_accessor_class_raw.cc */ void accessor_raw_set_length(grib_accessor* a, size_t len); long accessor_raw_get_offset(grib_accessor* a); -/* grib_accessor_class_bufr_extract_subsets.cc*/ - -/* grib_accessor_class_bufr_simple_thinning.cc*/ - -/* grib_accessor_class_spd.cc*/ - -/* grib_accessor_class_sum.cc*/ - -/* grib_accessor_class_to_integer.cc*/ - -/* grib_accessor_class_to_double.cc*/ - -/* grib_accessor_class_to_string.cc*/ - -/* grib_accessor_class_sexagesimal2decimal.cc*/ - -/* grib_accessor_class_vector.cc*/ - -/* grib_accessor_class_long_vector.cc*/ - -/* grib_gaussian_reduced.cc*/ +/* grib_gaussian_reduced.cc */ void grib_get_reduced_row_wrapper(grib_handle* h, long pl, double lon_first, double lon_last, long* npoints, long* ilon_first, long* ilon_last); void grib_get_reduced_row_legacy(long pl, double lon_first, double lon_last, long* npoints, long* ilon_first, long* ilon_last); void grib_get_reduced_row(long pl, double lon_first, double lon_last, long* npoints, long* ilon_first, long* ilon_last); void grib_get_reduced_row_p(long pl, double lon_first, double lon_last, long* npoints, double* olon_first, double* olon_last); -/* grib_accessor_class_abstract_vector.cc*/ - -/* grib_accessor_class_abstract_long_vector.cc*/ - -/* grib_loader_from_handle.cc*/ +/* grib_loader_from_handle.cc */ int grib_lookup_long_from_handle(grib_context* gc, grib_loader* loader, const char* name, long* value); int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_arguments* default_value); -/* grib_bits.cc*/ +/* grib_bits.cc */ unsigned long grib_decode_unsigned_byte_long(const unsigned char* p, long o, int l); long grib_decode_signed_long(const unsigned char* p, long o, int l); int grib_encode_signed_long(unsigned char* p, long val, long o, int l); @@ -730,7 +313,7 @@ void grib_set_bit(unsigned char* p, long bitp, int val); long grib_decode_signed_longb(const unsigned char* p, long* bitp, long nbits); int grib_encode_signed_longb(unsigned char* p, long val, long* bitp, long nb); -/* grib_timer.cc*/ +/* grib_timer.cc */ double proc_cpu(void); char* timename(double t); grib_timer* grib_get_timer(grib_context* c, const char* name, const char* statname, int elapsed); @@ -743,7 +326,7 @@ void grib_timer_partial_rate(grib_timer* t, double start, long total); void grib_print_all_timers(void); void grib_reset_all_timers(void); -/* grib_ibmfloat.cc*/ +/* grib_ibmfloat.cc */ unsigned long grib_ibm_to_long(double x); double grib_ibmfloat_error(double x); double grib_long_to_ibm(unsigned long x); @@ -752,7 +335,7 @@ double grib_ibm_table_v(unsigned long e); unsigned long grib_ibm_nearest_smaller_to_long(double x); int grib_nearest_smaller_ibm_float(double a, double* ret); -/* grib_ieeefloat.cc*/ +/* grib_ieeefloat.cc */ unsigned long grib_ieee_to_long(double x); double grib_ieeefloat_error(double x); double grib_long_to_ieee(unsigned long x); @@ -766,9 +349,7 @@ double grib_long_to_ieee64(unsigned long x); //int grib_ieee_decode_array_float(grib_context* c, unsigned char* buf, size_t nvals, int bytes, float* val); int grib_ieee_encode_array(grib_context* c, double* val, size_t nvals, int bytes, unsigned char* buf); -/* grib_accessor_class_reference_value_error.cc*/ - -/* grib_memory.cc*/ +/* grib_memory.cc */ void* grib_transient_malloc(const grib_context* c, size_t s); void* grib_transient_realloc(const grib_context* c, void* p, size_t s); void grib_transient_free(const grib_context* c, void* p); @@ -779,7 +360,7 @@ void* grib_buffer_malloc(const grib_context* c, size_t s); void grib_buffer_free(const grib_context* c, void* p); void* grib_buffer_realloc(const grib_context* c, void* p, size_t s); -/* grib_buffer.cc*/ +/* grib_buffer.cc */ grib_buffer* grib_create_growable_buffer(const grib_context* c); grib_buffer* grib_new_buffer(const grib_context* c, const unsigned char* data, size_t buflen); void grib_buffer_delete(const grib_context* c, grib_buffer* b); @@ -790,7 +371,7 @@ void grib_recompute_sections_lengths(grib_section* s); int grib_buffer_replace(grib_accessor* a, const unsigned char* data, size_t newsize, int update_lengths, int update_paddings); void grib_update_sections_lengths(grib_handle* h); -/* grib_dumper.cc*/ +/* grib_dumper.cc */ void grib_init_dumper(grib_dumper* d); void grib_dumper_delete(grib_dumper* d); void grib_dump_long(grib_dumper* d, grib_accessor* a, const char* comment); @@ -805,37 +386,7 @@ void grib_dump_values(grib_dumper* d, grib_accessor* a); 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.cc*/ - -/* grib_dumper_class_debug.cc*/ - -/* grib_dumper_class_default.cc*/ - -/* grib_dumper_class_bufr_encode_C.cc*/ - -/* grib_dumper_class_bufr_encode_filter.cc*/ - -/* grib_dumper_class_bufr_encode_fortran.cc*/ - -/* grib_dumper_class_bufr_encode_python.cc*/ - -/* grib_dumper_class_bufr_decode_C.cc*/ - -/* grib_dumper_class_bufr_decode_filter.cc*/ - -/* grib_dumper_class_bufr_decode_fortran.cc*/ - -/* grib_dumper_class_bufr_decode_python.cc*/ - -/* grib_dumper_class_bufr_simple.cc*/ - -/* grib_dumper_class_json.cc*/ - -/* grib_dumper_class_grib_encode_C.cc*/ - -/* grib_dumper_class_wmo.cc*/ - -/* grib_dumper_class.cc*/ +/* grib_dumper_class.cc */ 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); @@ -845,7 +396,7 @@ void grib_dump_keys(grib_handle* h, FILE* f, const char* mode, unsigned long fla 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); -/* grib_context.cc*/ +/* grib_context.cc */ size_t grib_context_read(const grib_context* c, void* ptr, size_t size, void* stream); off_t grib_context_tell(const grib_context* c, void* stream); int grib_context_seek(const grib_context* c, off_t offset, int whence, void* stream); @@ -905,14 +456,14 @@ void grib_gts_header_off(grib_context* c); void grib_multi_support_on(grib_context* c); void grib_multi_support_off(grib_context* c); -/* grib_date.cc*/ +/* grib_date.cc */ int grib_julian_to_datetime(double jd, long* year, long* month, long* day, long* hour, long* minute, long* second); int grib_datetime_to_julian(long year, long month, long day, long hour, long minute, long second, double* jd); int grib_datetime_to_julian_d(long year, long month, long day, long hour, long minute, double second, double* jd); long grib_julian_to_date(long jdate); long grib_date_to_julian(long ddate); -/* grib_fieldset.cc*/ +/* grib_fieldset.cc */ int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type); grib_fieldset* grib_fieldset_new_from_files(grib_context* c, const char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err); int grib_fieldset_apply_where(grib_fieldset* set, const char* where_string); @@ -925,7 +476,7 @@ grib_handle* grib_fieldset_next_handle(grib_fieldset* set, int* err); int grib_fieldset_count(const grib_fieldset* set); grib_handle* grib_fieldset_retrieve(grib_fieldset* set, int i, int* err); -/* grib_filepool.cc*/ +/* grib_filepool.cc */ void grib_file_pool_clean(void); grib_file* grib_file_pool_get_files(void); grib_file* grib_file_open(const char* filename, const char* mode, int* err); @@ -935,14 +486,14 @@ void grib_file_close_all(int* err); grib_file* grib_get_file(const char* filename, int* err); void grib_file_delete(grib_file* file); -/* grib_geography.cc*/ +/* grib_geography.cc */ int grib_get_gaussian_latitudes(long trunc, double* lats); int is_gaussian_global(double lat1, double lat2, double lon1, double lon2, long num_points_equator, const double* latitudes, double angular_precision); void rotate(const double inlat, const double inlon, const double angleOfRot, const double southPoleLat, const double southPoleLon, double* outlat, double* outlon); void unrotate(const double inlat, const double inlon, const double angleOfRot, const double southPoleLat, const double southPoleLon, double* outlat, double* outlon); double geographic_distance_spherical(double radius, double lon1, double lat1, double lon2, double lat2); -/* grib_handle.cc*/ +/* grib_handle.cc */ grib_section* grib_section_create(grib_handle* h, grib_accessor* owner); void grib_swap_sections(grib_section* the_old, grib_section* the_new); void grib_empty_section(grib_context* c, grib_section* b); @@ -990,14 +541,14 @@ int grib_handle_apply_action(grib_handle* h, grib_action* a); void grib_multi_support_reset_file(grib_context* c, FILE* f); void grib_multi_support_reset(grib_context* c); -/* grib_hash_keys.cc*/ +/* grib_hash_keys.cc */ const struct grib_keys_hash* grib_keys_hash_get(const char* str, size_t len); grib_itrie* grib_hash_keys_new(grib_context* c, int* count); void grib_hash_keys_delete(grib_itrie* t); int grib_hash_keys_get_id(grib_itrie* t, const char* key); int grib_hash_keys_get_size(grib_itrie* t); -/* grib_io.cc*/ +/* grib_io.cc */ off_t stdio_tell(void* data); int stdio_seek(void* data, off_t len); int stdio_seek_from_start(void* data, off_t len); @@ -1029,7 +580,7 @@ int codes_extract_offsets_sizes_malloc(grib_context* c, const char* filename, Pr off_t** offsets, size_t** sizes, int* num_messages, int strict_mode); -/* grib_trie.cc*/ +/* grib_trie.cc */ grib_trie* grib_trie_new(grib_context* c); void grib_trie_delete_container(grib_trie* t); void grib_trie_delete(grib_trie* t); @@ -1038,24 +589,24 @@ void* grib_trie_insert(grib_trie* t, const char* key, void* data); void* grib_trie_insert_no_replace(grib_trie* t, const char* key, void* data); void* grib_trie_get(grib_trie* t, const char* key); -/* grib_trie_with_rank.cc*/ +/* grib_trie_with_rank.cc */ grib_trie_with_rank* grib_trie_with_rank_new(grib_context* c); void grib_trie_with_rank_delete_container(grib_trie_with_rank* t); int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* data); void* grib_trie_with_rank_get(grib_trie_with_rank* t, const char* key, int rank); -/* grib_itrie.cc*/ +/* grib_itrie.cc */ grib_itrie* grib_itrie_new(grib_context* c, int* count); void grib_itrie_delete(grib_itrie* t); int grib_itrie_get_id(grib_itrie* t, const char* key); int grib_itrie_insert(grib_itrie* t, const char* key); int grib_itrie_get_size(grib_itrie* t); -/* grib_rules.cc*/ +/* grib_rules.cc */ grib_rule_entry* grib_new_rule_entry(grib_context* c, const char* name, grib_expression* expression); grib_rule* grib_new_rule(grib_context* c, grib_expression* condition, grib_rule_entry* entries); -/* grib_keys_iterator.cc*/ +/* grib_keys_iterator.cc */ grib_keys_iterator* grib_keys_iterator_new(grib_handle* h, unsigned long filter_flags, const char* name_space); int grib_keys_iterator_set_flags(grib_keys_iterator* ki, unsigned long flags); int grib_keys_iterator_rewind(grib_keys_iterator* ki); @@ -1070,7 +621,7 @@ int grib_keys_iterator_get_string(const grib_keys_iterator* kiter, char* v, size 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.cc*/ +/* bufr_keys_iterator.cc */ 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); @@ -1079,7 +630,7 @@ 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); -/* grib_parse_utils.cc*/ +/* grib_parse_utils.cc */ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* uname, char* fname, int fail); int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const char* name, int type, const char* format, const char* separator, int maxcols, int* newline, FILE* out); int grib_recompose_print(grib_handle* h, grib_accessor* observer, const char* uname, int fail, FILE* out); @@ -1093,21 +644,21 @@ grib_hash_array_value* grib_parse_hash_array_file(grib_context* gc, const char* grib_action* grib_parse_file(grib_context* gc, const char* filename); int grib_type_to_int(char id); -/* grib_query.cc*/ +/* grib_query.cc */ 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(const grib_handle* h, const char* name); grib_accessor* grib_find_accessor_fast(grib_handle* h, const char* name); -/* grib_scaling.cc*/ +/* grib_scaling.cc */ double grib_power(long s, long n); long grib_get_binary_scale_fact(double max, double min, long bpval, int* error); -/* grib_templates.cc*/ -grib_handle* codes_external_template(grib_context* c, ProductKind product_kind, const char* name); -char* get_external_template_path(grib_context* c, const char* name); +/* grib_templates.cc */ +grib_handle* codes_external_sample(grib_context* c, ProductKind product_kind, const char* name); +char* get_external_sample_path(grib_context* c, const char* name); -/* grib_dependency.cc*/ +/* grib_dependency.cc */ grib_handle* grib_handle_of_accessor(const grib_accessor* a); void grib_dependency_add(grib_accessor* observer, grib_accessor* observed); void grib_dependency_remove_observed(grib_accessor* observed); @@ -1117,7 +668,7 @@ void grib_dependency_remove_observer(grib_accessor* observer); void grib_dependency_observe_expression(grib_accessor* observer, grib_expression* e); void grib_dependency_observe_arguments(grib_accessor* observer, grib_arguments* a); -/* grib_value.cc*/ +/* grib_value.cc */ int grib_set_expression(grib_handle* h, const char* name, grib_expression* e); int grib_set_long_internal(grib_handle* h, const char* name, long val); int grib_set_long(grib_handle* h, const char* name, long val); @@ -1186,59 +737,59 @@ int grib_values_check(grib_handle* h, grib_values* values, int count); int codes_copy_key(grib_handle* h1, grib_handle* h2, const char* key, int type); int codes_compare_key(grib_handle* h1, grib_handle* h2, const char* key, int compare_flags); -/* grib_errors.cc*/ +/* grib_errors.cc */ const char* grib_get_error_message(int code); void grib_check(const char* call, const char* file, int line, int e, const char* msg); -/* grib_expression_class_binop.cc*/ +/* grib_expression_class_binop.cc */ grib_expression* new_binop_expression(grib_context* c, grib_binop_long_proc long_func, grib_binop_double_proc double_func, grib_expression* left, grib_expression* right); -/* grib_expression_class_logical_and.cc*/ +/* grib_expression_class_logical_and.cc */ grib_expression* new_logical_and_expression(grib_context* c, grib_expression* left, grib_expression* right); -/* grib_expression_class_logical_or.cc*/ +/* grib_expression_class_logical_or.cc */ grib_expression* new_logical_or_expression(grib_context* c, grib_expression* left, grib_expression* right); -/* grib_expression_class_is_in_dict.cc*/ +/* grib_expression_class_is_in_dict.cc */ grib_expression* new_is_in_dict_expression(grib_context* c, const char* name, const char* list); -/* grib_expression_class_true.cc*/ +/* grib_expression_class_true.cc */ grib_expression* new_true_expression(grib_context* c); -/* grib_expression_class_string_compare.cc*/ +/* grib_expression_class_string_compare.cc */ grib_expression* new_string_compare_expression(grib_context* c, grib_expression* left, grib_expression* right); -/* grib_expression_class_unop.cc*/ +/* grib_expression_class_unop.cc */ grib_expression* new_unop_expression(grib_context* c, grib_unop_long_proc long_func, grib_unop_double_proc double_func, grib_expression* exp); -/* grib_expression_class_functor.cc*/ +/* grib_expression_class_functor.cc */ grib_expression* new_func_expression(grib_context* c, const char* name, grib_arguments* args); -/* grib_expression_class_accessor.cc*/ +/* grib_expression_class_accessor.cc */ grib_expression* new_accessor_expression(grib_context* c, const char* name, long start, size_t length); -/* grib_expression_class_is_in_list.cc*/ +/* grib_expression_class_is_in_list.cc */ grib_expression* new_is_in_list_expression(grib_context* c, const char* name, const char* list); -/* grib_expression_class_is_integer.cc*/ +/* grib_expression_class_is_integer.cc */ grib_expression* new_is_integer_expression(grib_context* c, const char* name, int start, int length); -/* grib_expression_class_length.cc*/ +/* grib_expression_class_length.cc */ grib_expression* new_length_expression(grib_context* c, const char* name); -/* grib_expression_class_long.cc*/ +/* grib_expression_class_long.cc */ grib_expression* new_long_expression(grib_context* c, long value); -/* grib_expression_class_double.cc*/ +/* grib_expression_class_double.cc */ grib_expression* new_double_expression(grib_context* c, double value); -/* grib_expression_class_string.cc*/ +/* grib_expression_class_string.cc */ grib_expression* new_string_expression(grib_context* c, const char* value); -/* grib_expression_class_sub_string.cc*/ +/* grib_expression_class_sub_string.cc */ grib_expression* new_sub_string_expression(grib_context* c, const char* value, size_t start, size_t length); -/* grib_nearest.cc*/ +/* grib_nearest.cc */ 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); @@ -1254,28 +805,10 @@ int grib_nearest_find_generic(grib_nearest* nearest, grib_handle* h, double inla double** out_distances, double* outlats, double* outlons, double* values, double* distances, int* indexes, size_t* len); -/* grib_nearest_class.cc*/ +/* grib_nearest_class.cc */ grib_nearest* grib_nearest_factory(grib_handle* h, grib_arguments* args, int* error); -/* grib_nearest_class_gen.cc*/ - -/* grib_nearest_class_regular.cc*/ - -/* grib_nearest_class_reduced.cc*/ - -/* grib_nearest_class_latlon_reduced.cc*/ - -/* grib_nearest_class_lambert_conformal.cc*/ - -/* grib_nearest_class_polar_stereographic.cc*/ - -/* grib_iterator_class_polar_stereographic.cc*/ - -/* grib_iterator_class_lambert_azimuthal_equal_area.cc*/ - -/* grib_iterator_class_lambert_conformal.cc*/ - -/* grib_iterator.cc*/ +/* grib_iterator.cc */ 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); @@ -1284,25 +817,13 @@ int grib_iterator_reset(grib_iterator* i); int grib_iterator_init(grib_iterator* i, grib_handle* h, grib_arguments* args); int grib_iterator_delete(grib_iterator* i); -/* grib_iterator_class.cc*/ +/* grib_iterator_class.cc */ grib_iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error); -/* grib_iterator_class_gaussian.cc*/ - -/* grib_iterator_class_gaussian_reduced.cc*/ - -/* grib_iterator_class_latlon_reduced.cc*/ - -/* grib_iterator_class_gen.cc*/ +/* grib_iterator_class_gen.cc */ int transform_iterator_data(grib_context* c, double* data, long iScansNegatively, long jScansPositively, long jPointsAreConsecutive, long alternativeRowScanning, size_t numPoints, long nx, long ny); -/* grib_iterator_class_latlon.cc*/ - -/* grib_iterator_class_regular.cc*/ - -/* grib_iterator_class_space_view.cc*/ - -/* grib_expression.cc*/ +/* grib_expression.cc */ int grib_expression_native_type(grib_handle* h, grib_expression* g); int grib_expression_evaluate_long(grib_handle* h, grib_expression* g, long* result); int grib_expression_evaluate_double(grib_handle* h, grib_expression* g, double* result); @@ -1321,7 +842,7 @@ double grib_arguments_get_double(grib_handle* h, grib_arguments* args, int n); grib_expression* grib_arguments_get_expression(grib_handle* h, grib_arguments* args, int n); int grib_arguments_get_count(grib_arguments* args); -/* codes_util.cc*/ +/* codes_util.cc */ double normalise_longitude_in_degrees(double lon); char get_dir_separator_char(void); int path_is_regular_file(const char* path); @@ -1330,9 +851,10 @@ char* codes_getenv(const char* name); int codes_check_grib_ieee_packing_value(int value); int codes_flush_sync_close_file(FILE* f); int is_date_valid(long year, long month, long day, long hour, long minute, double second); +int is_time_valid(long number); // number is HHMM int compute_scaled_value_and_scale_factor(double input, int64_t scaled_value_max, int64_t scale_factor_max, int64_t* ret_value, int64_t* ret_factor); -/* grib_util.cc*/ +/* grib_util.cc */ grib_handle* grib_util_sections_copy(grib_handle* hfrom, grib_handle* hto, int what, int* err); grib_string_list* grib_util_get_param_id(const char* mars_param); grib_string_list* grib_util_get_mars_param(const char* param_id); @@ -1346,12 +868,12 @@ int grib2_is_PDTN_Aerosol(long productDefinitionTemplateNumber); int grib2_is_PDTN_AerosolOptical(long productDefinitionTemplateNumber); int grib2_select_PDTN(int is_eps, int is_instant, int is_chemical, int is_chemical_srcsink, int is_chemical_distfn, int is_aerosol, int is_aerosol_optical); size_t sum_of_pl_array(const long* pl, size_t plsize); -int grib_is_earth_oblate(grib_handle* h); +int grib_is_earth_oblate(const grib_handle* h); int grib_check_data_values_minmax(grib_handle* h, const double min_val, const double max_val); -int grib_producing_large_constant_fields(grib_handle* h, int edition); +int grib_producing_large_constant_fields(const grib_handle* h, int edition); int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max_val); -/* bufr_util.cc*/ +/* bufr_util.cc */ int compute_bufr_key_rank(grib_handle* h, grib_string_list* keys, const char* key); char** codes_bufr_copy_data_return_copied_keys(grib_handle* hin, grib_handle* hout, size_t* nkeys, int* err); int codes_bufr_copy_data(grib_handle* hin, grib_handle* hout); @@ -1361,7 +883,7 @@ int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err); int codes_bufr_key_is_coordinate(const grib_handle* h, const char* key, int* err); int codes_bufr_key_exclude_from_dump(const char* key); -/* string_util.cc*/ +/* string_util.cc */ int strcmp_nocase(const char* s1, const char* s2); void string_rtrim(char* s); void string_lrtrim(char** x, int do_left, int do_right); @@ -1375,13 +897,11 @@ const char* grib_get_type_name(int type); char* string_replace_char(char* str, char oldc, char newc); void string_remove_char(char* str, char c); -/* functions.cc*/ +/* functions.cc */ long grib_op_eq(long a, long b); long grib_op_ne(long a, long b); long grib_op_lt(long a, long b); long grib_op_gt(long a, long b); -long grib_op_and(long a, long b); -long grib_op_or(long a, long b); long grib_op_ge(long a, long b); long grib_op_le(long a, long b); long grib_op_bit(long a, long b); @@ -1406,20 +926,18 @@ double grib_op_gt_d(double a, double b); double grib_op_ge_d(double a, double b); double grib_op_le_d(double a, double b); -/* codes_memfs.cc*/ +/* codes_memfs.cc */ FILE* codes_fopen(const char* name, const char* mode); int codes_access(const char* name, int mode); -/* grib_accessor_class_data_g2bifourier_packing.cc*/ - -/* grib_optimize_decimal_factor.cc*/ +/* grib_optimize_decimal_factor.cc */ int grib_optimize_decimal_factor(grib_accessor* a, const char* reference_value, const double pmax, const double pmin, const int knbit, const int compat_gribex, const int compat_32bit, long* kdec, long* kbin, double* ref); -/* grib_api_version.cc*/ +/* grib_api_version.cc */ const char* grib_get_git_sha1(void); const char* codes_get_build_date(void); -/* grib_bits_any_endian.cc*/ +/* grib_bits_any_endian.cc */ int grib_is_all_bits_one(int64_t val, long nbits); int grib_encode_string(unsigned char* bitStream, long* bitOffset, size_t numberOfCharacters, const char* string); char* grib_decode_string(const unsigned char* bitStream, long* bitOffset, size_t numberOfCharacters, char* string); @@ -1430,7 +948,7 @@ int grib_encode_unsigned_longb(unsigned char* p, unsigned long val, long* bitp, int grib_encode_size_tb(unsigned char* p, size_t val, long* bitp, long nb); -/* grib_bits_any_endian_simple.cc*/ +/* grib_bits_any_endian_simple.cc */ int grib_decode_long_array(const unsigned char* p, long* bitp, long bitsPerValue, size_t n_vals, long* val); //int grib_decode_double_array(const unsigned char* p, long* bitp, long bitsPerValue, double reference_value, double s, double d, size_t n_vals, double* val); //int grib_decode_float_array(const unsigned char* p, long* bitp, long bitsPerValue, double reference_value, double s, double d, size_t n_vals, float* val); diff --git a/src/expression.class b/src/expression.class index 9c11d39db..64c9a2e70 100644 --- a/src/expression.class +++ b/src/expression.class @@ -1,20 +1,14 @@ typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void init(grib_expression* e); -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); +static void init(grib_expression* e); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static string get_name(grib_expression* e); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); +static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); typedef struct grib_expression_NAME{ grib_expression base; @@ -28,7 +22,6 @@ static grib_expression_class _grib_expression_class_NAME = { "NAME", /* name */ sizeof(grib_expression_NAME),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ &init, /* constructor */ &destroy, /* destructor */ &print, @@ -44,8 +37,3 @@ grib_expression_class* grib_expression_class_NAME = &_grib_expression_class_NAME ADD_TO_FILE grib_expression_class.h extern grib_expression_class* grib_expression_class_NAME; ADD_TO_FILE grib_expression_factory.h { "NAME", &grib_expression_class_NAME, }, - -static void init_class(grib_expression_class* c) -{ -INIT -} diff --git a/src/functions.cc b/src/functions.cc index 9680d07bd..6c6bba770 100644 --- a/src/functions.cc +++ b/src/functions.cc @@ -27,14 +27,14 @@ long grib_op_gt(long a, long b) { return a > b; } -long grib_op_and(long a, long b) -{ - return a && b; -} -long grib_op_or(long a, long b) -{ - return a || b; -} +// long grib_op_and(long a, long b) +// { +// return a && b; +// } +// long grib_op_or(long a, long b) +// { +// return a || b; +// } long grib_op_ge(long a, long b) { return a >= b; @@ -43,7 +43,6 @@ long grib_op_le(long a, long b) { return a <= b; } - long grib_op_bit(long a, long b) { return a & (1 << b); @@ -52,7 +51,6 @@ long grib_op_bitoff(long a, long b) { return !grib_op_bit(a, b); } - long grib_op_not(long a) { return !a; @@ -61,15 +59,14 @@ long grib_op_neg(long a) { return -a; } - double grib_op_neg_d(double a) { return -a; } +// Note: This is actually 'a' to the power 'b' long grib_op_pow(long a, long b) { - /* Note: This is actually 'a' to the power 'b' */ return codes_power(b, a); } @@ -93,7 +90,6 @@ long grib_op_modulo(long a, long b) { return a % b; } - double grib_op_mul_d(double a, double b) { return a * b; @@ -102,7 +98,6 @@ double grib_op_div_d(double a, double b) { return a / b; } - double grib_op_add_d(double a, double b) { return a + b; @@ -111,7 +106,6 @@ double grib_op_sub_d(double a, double b) { return a - b; } - double grib_op_eq_d(double a, double b) { return a == b; diff --git a/src/grib_accessor.cc b/src/grib_accessor.cc index 0b4b7ed99..a684b9e1d 100644 --- a/src/grib_accessor.cc +++ b/src/grib_accessor.cc @@ -54,18 +54,18 @@ int grib_pack_missing(grib_accessor* a) return 0; } -int grib_pack_zero(grib_accessor* a) -{ - grib_accessor_class* c = a->cclass; - while (c) { - if (c->clear) { - return c->clear(a); - } - c = c->super ? *(c->super) : NULL; - } - DEBUG_ASSERT(0); - return 0; -} +// int grib_pack_zero(grib_accessor* a) +// { +// grib_accessor_class* c = a->cclass; +// while (c) { +// if (c->clear) { +// return c->clear(a); +// } +// c = c->super ? *(c->super) : NULL; +// } +// DEBUG_ASSERT(0); +// return 0; +// } int grib_is_missing_internal(grib_accessor* a) { @@ -112,7 +112,9 @@ int grib_pack_float(grib_accessor* a, const float* v, size_t* len) int grib_pack_expression(grib_accessor* a, grib_expression* e) { grib_accessor_class* c = a->cclass; - //grib_context_log(a->context, GRIB_LOG_DEBUG, "(%s)%s is packing (double) %g",(a->parent->owner)?(a->parent->owner->name):"root", a->name ,v?(*v):0); + // grib_context_log(a->context, GRIB_LOG_INFO, "....(%s)%s is packing", + // (a->parent->owner)?(a->parent->owner->name):"root", + // a->name); while (c) { if (c->pack_expression) { return c->pack_expression(a, e); @@ -526,7 +528,7 @@ int grib_accessor_notify_change(grib_accessor* a, grib_accessor* changed) c = c->super ? *(c->super) : NULL; } if (a && a->cclass) - printf("notify_change not implemented for %s %s\n", a->cclass->name, a->name); + fprintf(stderr, "Error: notify_change not implemented for %s %s\n", a->cclass->name, a->name); DEBUG_ASSERT(0); return 0; } @@ -726,48 +728,47 @@ int grib_accessor_add_attribute(grib_accessor* a, grib_accessor* attr, int nest_ return GRIB_TOO_MANY_ATTRIBUTES; } -int grib_accessor_replace_attribute(grib_accessor* a, grib_accessor* attr) -{ - int id = 0; - int idx = 0; - if (grib_accessor_get_attribute_index(a, attr->name, &id) != NULL) { - grib_accessor_delete(a->context, a->attributes[id]); - a->attributes[id] = attr; - attr->parent_as_attribute = a; - if (a->same) - attr->same = grib_accessor_get_attribute_index(a->same, attr->name, &idx); - } - else { - grib_accessor_add_attribute(a, attr, 0); - } - return GRIB_SUCCESS; -} +// int grib_accessor_replace_attribute(grib_accessor* a, grib_accessor* attr) +// { +// int id = 0; +// int idx = 0; +// if (grib_accessor_get_attribute_index(a, attr->name, &id) != NULL) { +// grib_accessor_delete(a->context, a->attributes[id]); +// a->attributes[id] = attr; +// attr->parent_as_attribute = a; +// if (a->same) +// attr->same = grib_accessor_get_attribute_index(a->same, attr->name, &idx); +// } +// else { +// grib_accessor_add_attribute(a, attr, 0); +// } +// return GRIB_SUCCESS; +// } -int grib_accessor_delete_attribute(grib_accessor* a, const char* name) -{ - int id = 0; - if (grib_accessor_get_attribute_index(a, name, &id) != NULL) { - grib_accessor_delete(a->context, a->attributes[id]); - a->attributes[id] = NULL; - return GRIB_SUCCESS; - } - else { - return GRIB_NOT_FOUND; - } -} +// int grib_accessor_delete_attribute(grib_accessor* a, const char* name) +// { +// int id = 0; +// if (grib_accessor_get_attribute_index(a, name, &id) != NULL) { +// grib_accessor_delete(a->context, a->attributes[id]); +// a->attributes[id] = NULL; +// return GRIB_SUCCESS; +// } +// else { +// return GRIB_NOT_FOUND; +// } +// } -grib_accessor* grib_accessor_get_attribute_by_index(grib_accessor* a, int index) -{ - if (index < MAX_ACCESSOR_ATTRIBUTES) - return a->attributes[index]; +// grib_accessor* grib_accessor_get_attribute_by_index(grib_accessor* a, int index) +// { +// if (index < MAX_ACCESSOR_ATTRIBUTES) +// return a->attributes[index]; +// return NULL; +// } - return NULL; -} - -const char* grib_accessor_get_name(grib_accessor* a) -{ - return a->name; -} +// const char* grib_accessor_get_name(grib_accessor* a) +// { +// return a->name; +// } grib_accessor* grib_accessor_get_attribute_index(grib_accessor* a, const char* name, int* index) { @@ -847,24 +848,21 @@ grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al) // last=next; // next=last->next; // } - return al->last; } -grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a) -{ - grib_accessors_list* last = al; - grib_accessors_list* next = al->next; - - while (next) { - if (last->accessor == a) - return last; - last = next; - next = last->next; - } - - return NULL; -} +// grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a) +// { +// grib_accessors_list* last = al; +// grib_accessors_list* next = al->next; +// while (next) { +// if (last->accessor == a) +// return last; +// last = next; +// next = last->next; +// } +// return NULL; +// } void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al) { diff --git a/src/grib_accessor_class.cc b/src/grib_accessor_class.cc index 9cdd04b97..4120fb5bd 100644 --- a/src/grib_accessor_class.cc +++ b/src/grib_accessor_class.cc @@ -11,11 +11,12 @@ #include "grib_api_internal.h" #include "grib_accessor_classes_hash.cc" +#include /* grib level */ /* This file is generated by ./make_class.pl */ -#include "grib_accessor_class.h" +#include "accessor/grib_accessor.h" #if GRIB_PTHREADS static pthread_once_t once = PTHREAD_ONCE_INIT; @@ -139,7 +140,7 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, c = *((grib_accessor_classes_hash(creator->op, strlen(creator->op)))->cclass); #endif - a = (grib_accessor*)grib_context_malloc_clear(p->h->context, c->size); + a = c->create_empty_accessor(); a->name = creator->name; a->name_space = creator->name_space; @@ -150,8 +151,8 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, a->creator = creator; a->context = p->h->context; a->h = NULL; - a->next = NULL; - a->previous = NULL; + a->next_ = NULL; + a->previous_ = NULL; a->parent = p; a->length = 0; a->offset = 0; @@ -159,7 +160,7 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, a->set = creator->set; if (p->block->last) { - a->offset = grib_get_next_position_offset(p->block->last); + a->offset = p->block->last->get_next_position_offset(); //printf("offset: p->block->last %s %s %ld %ld\n", // p->block->last->cclass->name, @@ -176,8 +177,8 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, a->cclass = c; - grib_init_accessor(a, len, params); - size = grib_get_next_position_offset(a); + a->init_accessor(len, params); + size = a->get_next_position_offset(); if (size > p->h->buffer->ulength) { if (!p->h->buffer->growable) { @@ -189,7 +190,7 @@ grib_accessor* grib_accessor_factory(grib_section* p, grib_action* creator, a->offset + a->length, p->h->buffer->ulength); - grib_accessor_delete(p->h->context, a); + a->destroy(p->h->context); return NULL; } else { @@ -223,10 +224,10 @@ static void link_same_attributes(grib_accessor* a, grib_accessor* b) grib_accessor* bAttribute = NULL; if (a == NULL || b == NULL) return; - if (!grib_accessor_has_attributes(b)) + if (!b->has_attributes()) return; while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { - bAttribute = grib_accessor_get_attribute_index(b, a->attributes[i]->name, &idx); + bAttribute = b->get_attribute_index(a->attributes[i]->name, &idx); if (bAttribute) a->attributes[i]->same = bAttribute; i++; @@ -240,8 +241,8 @@ void grib_push_accessor(grib_accessor* a, grib_block_of_accessors* l) if (!l->first) l->first = l->last = a; else { - l->last->next = a; - a->previous = l->last; + l->last->next_ = a; + a->previous_ = l->last; } l->last = a; @@ -270,11 +271,11 @@ void grib_section_post_init(grib_section* s) while (a) { grib_accessor_class* c = a->cclass; - if (c->post_init) - c->post_init(a); + c->post_init(a); + if (a->sub_section) grib_section_post_init(a->sub_section); - a = a->next; + a = a->next_; } } @@ -306,20 +307,20 @@ int grib_section_adjust_sizes(grib_section* s, int update, int depth) } length += l; offset += l; - a = a->next; + a = a->next_; } if (s) { if (s->aclength) { size_t len = 1; long plen = 0; - int lret = grib_unpack_long(s->aclength, &plen, &len); + int lret = s->aclength->unpack_long(&plen, &len); Assert(lret == GRIB_SUCCESS); /* This happens when there is some padding */ if ((plen != length) || force_update) { if (update) { plen = length; - lret = grib_pack_long(s->aclength, &plen, &len); + lret = s->aclength->pack_long(&plen, &len); if (lret != GRIB_SUCCESS) return lret; s->padding = 0; @@ -358,7 +359,7 @@ int grib_get_block_length(grib_section* s, size_t* l) // if(s->aclength) { // size_t len = 1; // long plen = 0; -// int ret = grib_unpack_long(s->aclength, &plen, &len); +// int ret = s->aclength->unpack_long(&plen, &len); // if(ret == GRIB_SUCCESS && plen != 0) // { // *l = plen; @@ -371,13 +372,13 @@ int grib_get_block_length(grib_section* s, size_t* l) // return GRIB_SUCCESS; // } // // no accessor for block length -// if(s->owner) *l = grib_get_next_position_offset(s->block->last) - s->owner->offset; -// else *l = grib_get_next_position_offset(s->block->last); +// if(s->owner) *l = s->block->last->get_next_position_offset() - s->owner->offset; +// else *l = s->block->last->get_next_position_offset(); // if(s->aclength) { // size_t len = 1; // long plen = *l; -// int ret = grib_pack_long(s->aclength, &plen, &len); +// int ret = s->aclength->pack_long(&plen, &len); // if(ret != GRIB_SUCCESS) // ; // if(s->h->context->debug) @@ -397,10 +398,10 @@ grib_accessor* find_paddings(grib_section* s) if (p) return p; - if (grib_preferred_size(a, 0) != a->length) + if (a->preferred_size(0) != a->length) return a; - a = a->next; + a = a->next_; } return NULL; @@ -414,7 +415,7 @@ void grib_update_paddings(grib_section* s) /* while((changed = find_paddings(s)) != NULL) */ while ((changed = find_paddings(s->h->root)) != NULL) { Assert(changed != last); - grib_resize(changed, grib_preferred_size(changed, 0)); + changed->resize(changed->preferred_size(0)); last = changed; } } diff --git a/src/grib_accessor_class.h b/src/grib_accessor_class.h index 0c569decd..cfec4d21d 100644 --- a/src/grib_accessor_class.h +++ b/src/grib_accessor_class.h @@ -1,4 +1,5 @@ -/* This file is automatically generated by ./make_class.pl, do not edit */ +#include "grib_api_internal.h" + extern grib_accessor_class* grib_accessor_class_abstract_long_vector; extern grib_accessor_class* grib_accessor_class_abstract_vector; extern grib_accessor_class* grib_accessor_class_ascii; diff --git a/src/grib_accessor_class_abstract_long_vector.cc b/src/grib_accessor_class_abstract_long_vector.cc deleted file mode 100644 index 523e0a740..000000000 --- a/src/grib_accessor_class_abstract_long_vector.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/****************************************************************** - * Enrico Fucile - ******************************************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - MEMBERS = long* v - MEMBERS = long pack_index - MEMBERS = int number_of_elements - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - - -typedef struct grib_accessor_abstract_long_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; -} grib_accessor_abstract_long_vector; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_abstract_long_vector = { - &grib_accessor_class_gen, /* super */ - "abstract_long_vector", /* name */ - sizeof(grib_accessor_abstract_long_vector), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_abstract_long_vector = &_grib_accessor_class_abstract_long_vector; - -/* END_CLASS_IMP */ diff --git a/src/grib_accessor_class_abstract_vector.cc b/src/grib_accessor_class_abstract_vector.cc deleted file mode 100644 index 1353aeffc..000000000 --- a/src/grib_accessor_class_abstract_vector.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - MEMBERS = double* v - MEMBERS = int number_of_elements - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - - -typedef struct grib_accessor_abstract_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; -} grib_accessor_abstract_vector; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_abstract_vector = { - &grib_accessor_class_double, /* super */ - "abstract_vector", /* name */ - sizeof(grib_accessor_abstract_vector), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_abstract_vector = &_grib_accessor_class_abstract_vector; - -/* END_CLASS_IMP */ diff --git a/src/grib_accessor_class_ascii.cc b/src/grib_accessor_class_ascii.cc deleted file mode 100644 index b0c90182e..000000000 --- a/src/grib_accessor_class_ascii.cc +++ /dev/null @@ -1,278 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ -/*********************************************************** - * Enrico Fucile - ***********************************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = get_native_type - IMPLEMENTS = compare - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_ascii -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ -} grib_accessor_ascii; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_ascii = { - &grib_accessor_class_gen, /* super */ - "ascii", /* name */ - sizeof(grib_accessor_ascii), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ascii = &_grib_accessor_class_ascii; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = len; - Assert(a->length >= 0); -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - size_t i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - const size_t alen = a->length; - - if (*len < (alen + 1)) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, alen+1, *len); - *len = alen + 1; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < alen; i++) - val[i] = hand->buffer->data[a->offset + i]; - val[i] = 0; - *len = i; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - size_t i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - const size_t alen = a->length; - if (len[0] > (alen + 1)) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "pack_string: Wrong size (%zu) for %s, it contains %ld values", len[0], a->name, a->length + 1); - len[0] = 0; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < alen; i++) { - if (i < len[0]) - hand->buffer->data[a->offset + i] = val[i]; - else - hand->buffer->data[a->offset + i] = 0; - } - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as long (It's a string)", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_double(grib_accessor* a, const double* v, size_t* len) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as double (It's a string)", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - size_t i = 0; - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - i = 0; - while (i < l - 1 && val[i] == ' ') - i++; - - if (val[i] == 0) { - *v = 0; - return 0; - } - if (val[i + 1] == ' ' && i < l - 2) - val[i + 1] = 0; - - *v = strtol(val, &last, 10); - - grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - - int err = grib_unpack_string(a, val, &l); - if (err) return err; - - *v = strtod(val, &last); - - if (*last == 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); - return GRIB_SUCCESS; - } - - grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot unpack %s as double. Hint: Try unpacking as string", a->name); - - return GRIB_NOT_IMPLEMENTED; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - char* aval = 0; - char* bval = 0; - int err = 0; - - size_t alen = a->length+1; - size_t blen = b->length+1; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); - bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); - - err = grib_unpack_string(a, aval, &alen); - if (err) return err; - err = grib_unpack_string(b, bval, &blen); - if (err) return err; - - retval = GRIB_SUCCESS; - if (!STR_EQUAL(aval, bval)) - retval = GRIB_STRING_VALUE_MISMATCH; - - grib_context_free(a->context, aval); - grib_context_free(b->context, bval); - - return retval; -} diff --git a/src/grib_accessor_class_bit.cc b/src/grib_accessor_class_bit.cc deleted file mode 100644 index 17c1d3c8c..000000000 --- a/src/grib_accessor_class_bit.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - MEMBERS = const char* owner - MEMBERS = int bit_index - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bit -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in bit */ - const char* owner; - int bit_index; -} grib_accessor_bit; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_bit = { - &grib_accessor_class_long, /* super */ - "bit", /* name */ - sizeof(grib_accessor_bit), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bit = &_grib_accessor_class_bit; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_bit* self = (grib_accessor_bit*)a; - a->length = 0; - self->owner = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); - self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_bit* self = (grib_accessor_bit*)a; - int ret = 0; - - long data = 0; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : unpack_long : Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->owner, &data)) != GRIB_SUCCESS) { - *len = 0; - return ret; - } - - if (data & (1 << self->bit_index)) - *val = 1; - else - *val = 0; - - *len = 1; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_bit* self = (grib_accessor_bit*)a; - grib_accessor* owner = NULL; - unsigned char* mdata = 0; - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : pack_long : At least one value to pack for %s", a->name); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - owner = grib_find_accessor(grib_handle_of_accessor(a), self->owner); - - if (!owner) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_bit : Cannot get the owner %s for computing the bit value of %s ", self->owner, a->name); - *len = 0; - return GRIB_NOT_FOUND; - } - - mdata = grib_handle_of_accessor(a)->buffer->data; - mdata += grib_byte_offset(owner); - - /* Note: In the definitions, flagbit numbers go from 7 to 0 (the bit_index), while WMO convention is from 1 to 8 */ - if (a->context->debug) { - /* Print bit positions from 1 (MSB) */ - fprintf(stderr, "ECCODES DEBUG Setting bit %d in %s to %d\n", 8 - self->bit_index, owner->name, (*val > 0) ); - } - grib_set_bit(mdata, 7 - self->bit_index, *val > 0); - - *len = 1; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_bitmap.cc b/src/grib_accessor_class_bitmap.cc deleted file mode 100644 index bd52d16cd..000000000 --- a/src/grib_accessor_class_bitmap.cc +++ /dev/null @@ -1,303 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bytes - IMPLEMENTS = next_offset - IMPLEMENTS = unpack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_float - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_string - IMPLEMENTS = string_length - IMPLEMENTS = init;dump;update_size - MEMBERS=const char* tableReference - MEMBERS=const char* missing_value - MEMBERS=const char* offsetbsec - MEMBERS=const char* sLength - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in bitmap */ - const char* tableReference; - const char* missing_value; - const char* offsetbsec; - const char* sLength; -} grib_accessor_bitmap; - -extern grib_accessor_class* grib_accessor_class_bytes; - -static grib_accessor_class _grib_accessor_class_bitmap = { - &grib_accessor_class_bytes, /* super */ - "bitmap", /* name */ - sizeof(grib_accessor_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bitmap = &_grib_accessor_class_bitmap; - -/* END_CLASS_IMP */ - - -static void compute_size(grib_accessor* a) -{ - long slen = 0; - long off = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_accessor_bitmap* self = (grib_accessor_bitmap*)a; - grib_get_long_internal(hand, self->offsetbsec, &off); - grib_get_long_internal(hand, self->sLength, &slen); - - if (slen == 0) { - grib_accessor* seclen; - size_t size; - /* Assume reparsing */ - Assert(hand->loader != 0); - if (hand->loader != 0) { - seclen = grib_find_accessor(hand, self->sLength); - Assert(seclen); - grib_get_block_length(seclen->parent, &size); - slen = size; - } - } - - // printf("compute_size off=%ld slen=%ld a->offset=%ld\n", (long)off,(long)slen,(long)a->offset); - - a->length = off + (slen - a->offset); - - if (a->length < 0) { - /* Assume reparsing */ - /*Assert(hand->loader != 0);*/ - a->length = 0; - } - - Assert(a->length >= 0); -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_bitmap* self = (grib_accessor_bitmap*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->tableReference = grib_arguments_get_name(hand, arg, n++); - self->missing_value = grib_arguments_get_name(hand, arg, n++); - self->offsetbsec = grib_arguments_get_name(hand, arg, n++); - self->sLength = grib_arguments_get_name(hand, arg, n++); - - compute_size(a); -} - -static long next_offset(grib_accessor* a) -{ - return grib_byte_offset(a) + grib_byte_count(a); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - long len = 0; - char label[1024]; - - grib_value_count(a, &len); - - snprintf(label, 1024, "Bitmap of %ld values", len); - grib_dump_bytes(dumper, a, label); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long pos = a->offset * 8; - long tlen = 0; - long i = 0; - int err = 0; - const grib_handle* hand = grib_handle_of_accessor(a); - - err = grib_value_count(a, &tlen); - if (err) - return err; - - if (*len < tlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < tlen; i++) { - val[i] = (long)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); - } - *len = tlen; - return GRIB_SUCCESS; -} - -template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating points numbers"); - long pos = a->offset * 8; - long tlen; - long i; - int err = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - err = grib_value_count(a, &tlen); - if (err) - return err; - - if (*len < tlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %ld values", a->name, tlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < tlen; i++) { - val[i] = (T)grib_decode_unsigned_long(hand->buffer->data, &pos, 1); - } - *len = tlen; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - long pos = a->offset * 8; - - pos += idx; - *val = (double)grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, 1); - - return GRIB_SUCCESS; -} -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - size_t i = 0; - for (i=0; ilength = s; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - const size_t l = a->length; - - if (*len < l) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) { - val[i] = hand->buffer->data[a->offset + i]; - } - - *len = a->length; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_bits_per_value.cc b/src/grib_accessor_class_bits_per_value.cc deleted file mode 100644 index 5648a9a69..000000000 --- a/src/grib_accessor_class_bits_per_value.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/********************************** - * Enrico Fucile - *********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* bits_per_value - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bits_per_value -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in bits_per_value */ - const char* values; - const char* bits_per_value; -} grib_accessor_bits_per_value; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_bits_per_value = { - &grib_accessor_class_long, /* super */ - "bits_per_value", /* name */ - sizeof(grib_accessor_bits_per_value), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bits_per_value = &_grib_accessor_class_bits_per_value; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_bits_per_value* self = (grib_accessor_bits_per_value*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_bits_per_value* self = (grib_accessor_bits_per_value*)a; - grib_handle* h = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(h, self->bits_per_value, val)) != GRIB_SUCCESS) - return ret; - - *len = 1; - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - double* values = NULL; - size_t size = 0; - int ret = 0; - grib_accessor_bits_per_value* self = (grib_accessor_bits_per_value*)a; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->bits_per_value, *val)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_blob.cc b/src/grib_accessor_class_blob.cc deleted file mode 100644 index 7e1c1de62..000000000 --- a/src/grib_accessor_class_blob.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init - IMPLEMENTS = unpack_bytes;dump - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_blob -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in blob */ -} grib_accessor_blob; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_blob = { - &grib_accessor_class_gen, /* super */ - "blob", /* name */ - sizeof(grib_accessor_blob), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_blob = &_grib_accessor_class_blob; - -/* END_CLASS_IMP */ - -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); -} - -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 < (size_t)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); - - return GRIB_SUCCESS; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_bytes(dumper, a, NULL); -} diff --git a/src/grib_accessor_class_budgdate.cc b/src/grib_accessor_class_budgdate.cc deleted file mode 100644 index 15fc9b4bd..000000000 --- a/src/grib_accessor_class_budgdate.cc +++ /dev/null @@ -1,174 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - MEMBERS=const char* year - MEMBERS=const char* month - MEMBERS=const char* day - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_budgdate -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in budgdate */ - const char* year; - const char* month; - const char* day; -} grib_accessor_budgdate; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_budgdate = { - &grib_accessor_class_long, /* super */ - "budgdate", /* name */ - sizeof(grib_accessor_budgdate), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_budgdate = &_grib_accessor_class_budgdate; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_budgdate* self = (grib_accessor_budgdate*)a; - int n = 0; - - self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_budgdate* self = (grib_accessor_budgdate*)a; - - long year = 0; - long month = 0; - long day = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->day, &day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->month, &month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->year, &year)) != GRIB_SUCCESS) - return ret; - - if (*len < 1) - return GRIB_WRONG_ARRAY_SIZE; - - val[0] = (1900 + year) * 10000 + month * 100 + day; - - return ret; -} - -/* TODO: Check for a valid date */ -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int ret = 0; - long v = val[0]; - grib_accessor_budgdate* self = (grib_accessor_budgdate*)a; - - long year = 0; - long month = 0; - long day = 0; - - if (*len != 1) - return GRIB_WRONG_ARRAY_SIZE; - - year = v / 10000; - v %= 10000; - month = v / 100; - v %= 100; - day = v; - - year -= 1900; - - Assert(year < 255); - - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->year, year)) != GRIB_SUCCESS) - return ret; - - return ret; -} diff --git a/src/grib_accessor_class_bufr_extract_subsets.cc b/src/grib_accessor_class_bufr_extract_subsets.cc deleted file mode 100644 index 599d1d7b4..000000000 --- a/src/grib_accessor_class_bufr_extract_subsets.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init; get_native_type - IMPLEMENTS = pack_long; - MEMBERS = const char* numericValues - MEMBERS = const char* pack - MEMBERS = grib_accessor* numericValuesAccessor - MEMBERS = grib_accessor* packAccessor - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_extract_subsets -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_extract_subsets */ - const char* numericValues; - const char* pack; - grib_accessor* numericValuesAccessor; - grib_accessor* packAccessor; -} grib_accessor_bufr_extract_subsets; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_extract_subsets = { - &grib_accessor_class_gen, /* super */ - "bufr_extract_subsets", /* name */ - sizeof(grib_accessor_bufr_extract_subsets), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufr_extract_subsets = &_grib_accessor_class_bufr_extract_subsets; - -/* END_CLASS_IMP */ - -static void get_accessors(grib_accessor* a) -{ - grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a; - grib_handle* h = grib_handle_of_accessor(a); - - if (self->packAccessor) - return; - self->numericValuesAccessor = grib_find_accessor(h, self->numericValues); - self->packAccessor = grib_find_accessor(h, self->pack); -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - int n = 0; - grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a; - - a->length = 0; - self->numericValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->pack = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int err = 0; - grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a; - size_t l = 1; - long v[1]; - - get_accessors(a); - - v[0] = 1; - err = grib_pack_long(self->packAccessor, v, &l); - if (err) { - if (err == GRIB_ENCODING_ERROR) - grib_context_log(a->context, GRIB_LOG_ERROR, "Could not extract subset(s).\n\tHint: Did you forget to set unpack=1?"); - return err; - } - - return err; -} diff --git a/src/grib_accessor_class_bufr_group.cc b/src/grib_accessor_class_bufr_group.cc deleted file mode 100644 index 9af0a5633..000000000 --- a/src/grib_accessor_class_bufr_group.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_variable - IMPLEMENTS = dump;next - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void dump(grib_accessor*, grib_dumper*); -static grib_accessor* next(grib_accessor*, int); - -typedef struct grib_accessor_bufr_group -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in variable */ - double dval; - float fval; - char* cval; - char* cname; - int type; - /* Members defined in bufr_group */ -} grib_accessor_bufr_group; - -extern grib_accessor_class* grib_accessor_class_variable; - -static grib_accessor_class _grib_accessor_class_bufr_group = { - &grib_accessor_class_variable, /* super */ - "bufr_group", /* name */ - sizeof(grib_accessor_bufr_group), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - &next, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufr_group = &_grib_accessor_class_bufr_group; - -/* END_CLASS_IMP */ - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_section(dumper, a, a->sub_section->block); -} - -static grib_accessor* next(grib_accessor* a, int explore) -{ - grib_accessor* next = NULL; - if (explore) { - next = a->sub_section->block->first; - if (!next) - next = a->next; - } - else { - next = a->next; - } - if (!next) { - if (a->parent->owner) - next = a->parent->owner->cclass->next(a->parent->owner, 0); - } - return next; -} diff --git a/src/grib_accessor_class_bufr_simple_thinning.cc b/src/grib_accessor_class_bufr_simple_thinning.cc deleted file mode 100644 index b457d0e9e..000000000 --- a/src/grib_accessor_class_bufr_simple_thinning.cc +++ /dev/null @@ -1,213 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init; get_native_type - IMPLEMENTS = pack_long; - MEMBERS = const char* doExtractSubsets - MEMBERS = const char* numberOfSubsets - MEMBERS = const char* extractSubsetList - MEMBERS = const char* simpleThinningStart - MEMBERS = const char* simpleThinningMissingRadius - MEMBERS = const char* simpleThinningSkip - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_simple_thinning -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bufr_simple_thinning */ - const char* doExtractSubsets; - const char* numberOfSubsets; - const char* extractSubsetList; - const char* simpleThinningStart; - const char* simpleThinningMissingRadius; - const char* simpleThinningSkip; -} grib_accessor_bufr_simple_thinning; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bufr_simple_thinning = { - &grib_accessor_class_gen, /* super */ - "bufr_simple_thinning", /* name */ - sizeof(grib_accessor_bufr_simple_thinning), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufr_simple_thinning = &_grib_accessor_class_bufr_simple_thinning; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a; - grib_handle* h = grib_handle_of_accessor(a); - int n = 0; - - a->length = 0; - self->doExtractSubsets = grib_arguments_get_name(h, arg, n++); - self->numberOfSubsets = grib_arguments_get_name(h, arg, n++); - self->extractSubsetList = grib_arguments_get_name(h, arg, n++); - self->simpleThinningStart = grib_arguments_get_name(h, arg, n++); - self->simpleThinningMissingRadius = grib_arguments_get_name(h, arg, n++); - self->simpleThinningSkip = grib_arguments_get_name(h, arg, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int apply_thinning(grib_accessor* a) -{ - grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a; - int ret = 0; - long skip; - grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = h->context; - long compressed = 0, nsubsets; - long i; - grib_iarray* subsets; - long* subsets_ar = 0; - long start = 0, radius = 0; - - ret = grib_get_long(h, "compressedData", &compressed); - if (ret) - return ret; - if (compressed) { - long numberOfSubsets = 0; - ret = grib_get_long(h, self->numberOfSubsets, &numberOfSubsets); - if (ret) - return ret; - - ret = grib_get_long(h, self->simpleThinningStart, &start); - if (ret) - return ret; - - ret = grib_get_long(h, self->simpleThinningSkip, &skip); - if (ret) - return ret; - if (skip <= 0) - return GRIB_INVALID_KEY_VALUE; - - ret = grib_get_long(h, self->simpleThinningMissingRadius, &radius); - if (ret) - return ret; - - subsets = grib_iarray_new(c, numberOfSubsets / skip + 1, 10); - for (i = 0; i < numberOfSubsets; i += skip + 1) { - grib_iarray_push(subsets, i + 1); - } - - nsubsets = grib_iarray_used_size(subsets); - - if (nsubsets != 0) { - subsets_ar = grib_iarray_get_array(subsets); - ret = grib_set_long_array(h, self->extractSubsetList, subsets_ar, nsubsets); - grib_context_free(c, subsets_ar); - if (ret) - return ret; - - ret = grib_set_long(h, "unpack", 1); - if (ret) - return ret; - - ret = grib_set_long(h, self->doExtractSubsets, 1); - if (ret) - return ret; - } - grib_iarray_delete(subsets); - } - else { - return GRIB_NOT_IMPLEMENTED; - } - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int err = 0; - grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a; - - if (*len == 0) - return GRIB_SUCCESS; - err = apply_thinning(a); - if (err) - return err; - - return grib_set_long(a->parent->h, self->doExtractSubsets, 1); -} diff --git a/src/grib_accessor_class_bufr_string_values.cc b/src/grib_accessor_class_bufr_string_values.cc deleted file mode 100644 index 02627e763..000000000 --- a/src/grib_accessor_class_bufr_string_values.cc +++ /dev/null @@ -1,189 +0,0 @@ -/* -* (C) Copyright 2005- ECMWF. -* -* This software is licensed under the terms of the Apache Licence Version 2.0 -* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -* -* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by -* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. -*/ - -/* Sequences and replication (not delayed) are resolved in this class. - Number of elements to which a delayed replication applies are recomputed to - take account of the expansion. - Expanded descriptors cannot contain sequences and only delayed replication - can appear -*/ - -#include "grib_api_internal.h" -/* -This is used by make_class.pl - -START_CLASS_DEF -CLASS = accessor -SUPER = grib_accessor_class_ascii -IMPLEMENTS = unpack_string_array -IMPLEMENTS = unpack_string -IMPLEMENTS = init;dump;destroy -IMPLEMENTS = value_count -MEMBERS = const char* dataAccessorName -MEMBERS = grib_accessor* dataAccessor - -END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufr_string_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in bufr_string_values */ - const char* dataAccessorName; - grib_accessor* dataAccessor; -} grib_accessor_bufr_string_values; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_bufr_string_values = { - &grib_accessor_class_ascii, /* super */ - "bufr_string_values", /* name */ - sizeof(grib_accessor_bufr_string_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufr_string_values = &_grib_accessor_class_bufr_string_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_bufr_string_values* self = (grib_accessor_bufr_string_values*)a; - int n = 0; - self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->dataAccessor = NULL; - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string_array(dumper, a, NULL); -} - -static grib_accessor* get_accessor(grib_accessor* a) -{ - grib_accessor_bufr_string_values* self = (grib_accessor_bufr_string_values*)a; - if (!self->dataAccessor) { - self->dataAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->dataAccessorName); - } - return self->dataAccessor; -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - grib_accessor* data = 0; - grib_context* c = a->context; - grib_vsarray* stringValues = NULL; - size_t l = 0, tl; - size_t i, j, n = 0; - char** b = buffer; - - data = get_accessor(a); - if (!data) - return GRIB_NOT_FOUND; - - stringValues = accessor_bufr_data_array_get_stringValues(data); - - n = grib_vsarray_used_size(stringValues); - - tl = 0; - for (j = 0; j < n; j++) { - l = grib_sarray_used_size(stringValues->v[j]); - tl += l; - - if (tl > *len) - return GRIB_ARRAY_TOO_SMALL; - - for (i = 0; i < l; i++) { - *(b++) = grib_context_strdup(c, stringValues->v[j]->v[i]); - } - } - *len = tl; - - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int value_count(grib_accessor* a, long* rlen) -{ - grib_accessor* descriptors = get_accessor(a); - return grib_value_count(descriptors, rlen); -} - -static void destroy(grib_context* c, grib_accessor* a) -{ -} diff --git a/src/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/grib_accessor_class_bufrdc_expanded_descriptors.cc deleted file mode 100644 index 8476f4708..000000000 --- a/src/grib_accessor_class_bufrdc_expanded_descriptors.cc +++ /dev/null @@ -1,212 +0,0 @@ -/* -* (C) Copyright 2005- ECMWF. -* -* This software is licensed under the terms of the Apache Licence Version 2.0 -* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -* -* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by -* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. -*/ - -/* Sequences and replication (not delayed) are resolved in this class. - Number of elements to which a delayed replication applies are recomputed to - take account of the expansion. - Expanded descriptors cannot contain sequences and only delayed replication - can appear -*/ - -#include "grib_api_internal.h" -/* -This is used by make_class.pl - -START_CLASS_DEF -CLASS = accessor -SUPER = grib_accessor_class_long -IMPLEMENTS = unpack_long -IMPLEMENTS = unpack_string_array -IMPLEMENTS = init;dump;destroy -IMPLEMENTS = value_count -MEMBERS = const char* expandedDescriptors -MEMBERS = grib_accessor* expandedDescriptorsAccessor - -END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_bufrdc_expanded_descriptors -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in bufrdc_expanded_descriptors */ - const char* expandedDescriptors; - grib_accessor* expandedDescriptorsAccessor; -} grib_accessor_bufrdc_expanded_descriptors; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_bufrdc_expanded_descriptors = { - &grib_accessor_class_long, /* super */ - "bufrdc_expanded_descriptors", /* name */ - sizeof(grib_accessor_bufrdc_expanded_descriptors), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bufrdc_expanded_descriptors = &_grib_accessor_class_bufrdc_expanded_descriptors; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_bufrdc_expanded_descriptors* self = (grib_accessor_bufrdc_expanded_descriptors*)a; - int n = 0; - self->expandedDescriptors = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->expandedDescriptorsAccessor = 0; - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static grib_accessor* get_accessor(grib_accessor* a) -{ - grib_accessor_bufrdc_expanded_descriptors* self = (grib_accessor_bufrdc_expanded_descriptors*)a; - if (!self->expandedDescriptorsAccessor) { - self->expandedDescriptorsAccessor = grib_find_accessor(grib_handle_of_accessor(a), self->expandedDescriptors); - } - return self->expandedDescriptorsAccessor; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor* descriptors = 0; - size_t rlen = 0, l; - long lenall = 0; - size_t i = 0; - long* v = 0; - grib_context* c = a->context; - - descriptors = get_accessor(a); - if (!descriptors) return GRIB_NOT_FOUND; - - grib_value_count(a, &lenall); - v = (long*)grib_context_malloc_clear(c, sizeof(long) * lenall); - l = lenall; - grib_unpack_long(descriptors, v, &l); - - rlen = 0; - for (i = 0; i < l; i++) { - if ((v[i] < 100000 || v[i] > 221999)) - val[rlen++] = v[i]; - } - *len = rlen; - grib_context_free(c,v); - - return GRIB_SUCCESS; -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - int err = 0; - grib_accessor* descriptors = 0; - size_t l = 0; - long lenall = 0; - size_t i = 0; - long* v = 0; - char buf[25] = {0,}; - grib_context* c = a->context; - - descriptors = get_accessor(a); - if (!descriptors) return GRIB_NOT_FOUND; - - err = grib_value_count(a, &lenall); - if (err) return err; - l = lenall; - if (l > *len) return GRIB_ARRAY_TOO_SMALL; - - v = (long*)grib_context_malloc_clear(c, sizeof(long) * l); - err = grib_unpack_long(descriptors, v, &l); - if (err) return err; - - for (i = 0; i < l; i++) { - snprintf(buf, sizeof(buf), "%06ld", v[i]); - buffer[i] = grib_context_strdup(c, buf); - } - *len = l; - grib_context_free(c,v); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* rlen) -{ - grib_accessor* descriptors = get_accessor(a); - - return grib_value_count(descriptors, rlen); -} - -static void destroy(grib_context* c, grib_accessor* a) -{ -} diff --git a/src/grib_accessor_class_bytes.cc b/src/grib_accessor_class_bytes.cc deleted file mode 100644 index 71533095e..000000000 --- a/src/grib_accessor_class_bytes.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init - IMPLEMENTS = compare;unpack_string;pack_string - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_bytes -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ -} grib_accessor_bytes; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_bytes = { - &grib_accessor_class_gen, /* super */ - "bytes", /* name */ - sizeof(grib_accessor_bytes), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_bytes = &_grib_accessor_class_bytes; - -/* END_CLASS_IMP */ - -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); -} - -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; - - 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; - - return retval; -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - unsigned char* p = NULL; - char* s = v; - long i = 0; - const long length = grib_byte_count(a); - const long slength = 2 * length; - - if (*len < (size_t)slength) { - *len = slength; - return GRIB_BUFFER_TOO_SMALL; - } - - p = grib_handle_of_accessor(a)->buffer->data + grib_byte_offset(a); - - for (i = 0; i < length; i++) { - snprintf(s, INT_MAX, "%02x", *(p++)); - s += 2; - } - - *len = slength; - - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - /* The string representation (val) of the byte array will have two chars - * per byte e.g. 4C5B means the 2 bytes 0114 and 0133 in octal - * so has to be twice the length of the byte array - */ - int err = 0; - grib_accessor_class* super = *(a->cclass->super); - grib_context* c = a->context; - size_t nbytes = a->length; - const size_t expected_blen = nbytes; - const size_t expected_slen = 2 * expected_blen; - unsigned char* bytearray = NULL; - size_t i = 0, slen = strlen(val); - - if (slen != expected_slen || *len != expected_slen) { - grib_context_log(c, GRIB_LOG_ERROR, - "%s: Key %s is %lu bytes. Expected a string with %lu characters (actual length=%zu)", - __func__, a->name, expected_blen, expected_slen, *len); - return GRIB_WRONG_ARRAY_SIZE; - } - - bytearray = (unsigned char*)grib_context_malloc(c, nbytes * (sizeof(unsigned char))); - if (!bytearray) return GRIB_OUT_OF_MEMORY; - - for (i = 0; i < (slen/2); i++) { - unsigned int byteVal = 0; - if (sscanf(val + 2*i, "%02x", &byteVal) != 1) { - grib_context_log(c, GRIB_LOG_ERROR,"%s: Invalid hex byte specfication '%.2s'", __func__, val + 2*i); - grib_context_free(c, bytearray); - return GRIB_INVALID_KEY_VALUE; - } - Assert(byteVal < 256); - bytearray[i] = (int)byteVal; - } - - /* Forward to base class to pack the byte array */ - err = super->pack_bytes(a, bytearray, &nbytes); - grib_context_free(c, bytearray); - return err; -} diff --git a/src/grib_accessor_class_change_alternative_row_scanning.cc b/src/grib_accessor_class_change_alternative_row_scanning.cc deleted file mode 100644 index 394bb8409..000000000 --- a/src/grib_accessor_class_change_alternative_row_scanning.cc +++ /dev/null @@ -1,212 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_long; - IMPLEMENTS = unpack_long - IMPLEMENTS = init;get_native_type - MEMBERS = const char* values - MEMBERS = const char* Ni - MEMBERS = const char* Nj - MEMBERS = const char* alternativeRowScanning - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_change_alternative_row_scanning -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in change_alternative_row_scanning */ - const char* values; - const char* Ni; - const char* Nj; - const char* alternativeRowScanning; -} grib_accessor_change_alternative_row_scanning; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_change_alternative_row_scanning = { - &grib_accessor_class_gen, /* super */ - "change_alternative_row_scanning", /* name */ - sizeof(grib_accessor_change_alternative_row_scanning), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_change_alternative_row_scanning = &_grib_accessor_class_change_alternative_row_scanning; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - int n = 0; - grib_accessor_change_alternative_row_scanning* self = (grib_accessor_change_alternative_row_scanning*)a; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->Ni = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->Nj = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->alternativeRowScanning = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int err = 0; - grib_accessor_change_alternative_row_scanning* self = (grib_accessor_change_alternative_row_scanning*)a; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - long i, j, jr, theEnd, Ni, Nj, k, kp, alternativeRowScanning; - size_t size = 0; - double* values = NULL; - double tmp = 0.0; - - if (*val == 0) - return 0; - - /* Make sure Ni / Nj are not missing */ - if (grib_is_missing(h, self->Ni, &err) && !err) { - grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: Key %s cannot be 'missing'!", self->Ni); - return GRIB_WRONG_GRID; - } - if (grib_is_missing(h, self->Nj, &err) && !err) { - grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: Key %s cannot be 'missing'!", self->Nj); - return GRIB_WRONG_GRID; - } - - if ((err = grib_get_long_internal(h, self->Ni, &Ni)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(h, self->Nj, &Nj)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long_internal(h, self->alternativeRowScanning, &alternativeRowScanning)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return err; - - if ( size > (size_t)(Ni * Nj) ) { - grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: wrong values size!=Ni*Nj (%zu!=%ld*%ld)", size, Ni, Nj); - return GRIB_WRONG_ARRAY_SIZE; - } - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((err = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - theEnd = Ni / 2; - for (j = 0; j < Nj; j++) { - jr = Ni * j; - for (i = 0; i < theEnd; i++) { - if (j % 2 == 1) { - /* Swap first and last value on every odd row */ - k = jr + i; - kp = jr + Ni - i - 1; - tmp = values[k]; - values[k] = values[kp]; - values[kp] = tmp; - } - } - } - alternativeRowScanning = !alternativeRowScanning; - if ((err = grib_set_long_internal(h, self->alternativeRowScanning, alternativeRowScanning)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - if ((err = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - /* Decoding this accessor doesn't make sense so we return a dummy value */ - *v = -1; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_check_internal_version.cc b/src/grib_accessor_class_check_internal_version.cc deleted file mode 100644 index d59f353de..000000000 --- a/src/grib_accessor_class_check_internal_version.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = value_count;string_length - IMPLEMENTS = init - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_check_internal_version -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in check_internal_version */ -} grib_accessor_check_internal_version; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_check_internal_version = { - &grib_accessor_class_ascii, /* super */ - "check_internal_version", /* name */ - sizeof(grib_accessor_check_internal_version), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_check_internal_version = &_grib_accessor_class_check_internal_version; - -/* END_CLASS_IMP */ - -/* This is the internal engine version number */ -/* We check this against the version number found in the definitions boot.def file */ -/* See the key "internalVersion" */ -#define LATEST_ENGINE_VERSION 30 - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - /* Check version of definition files is compatible with the engine */ - int err = 0; - long defs_file_version = 0; - grib_handle* h = grib_handle_of_accessor(a); - const char* s_defn_version = grib_arguments_get_name(h, args, 0); - Assert(s_defn_version); - - err = grib_get_long_internal(h, s_defn_version, &defs_file_version); - if (!err) { - if (defs_file_version > LATEST_ENGINE_VERSION) { - grib_context_log(h->context, GRIB_LOG_FATAL, - "Definition files version (%d) is greater than engine version (%d)!\n" - " " /* indent for 2nd line */ - "These definition files are for a later version of the ecCodes engine.", - defs_file_version, LATEST_ENGINE_VERSION); - } - } -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 255; -} diff --git a/src/grib_accessor_class_codeflag.cc b/src/grib_accessor_class_codeflag.cc deleted file mode 100644 index 77789389d..000000000 --- a/src/grib_accessor_class_codeflag.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/**************************************** - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = init;dump - IMPLEMENTS = value_count - MEMBERS = const char* tablename - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_codeflag -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in codeflag */ - const char* tablename; -} grib_accessor_codeflag; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_codeflag = { - &grib_accessor_class_unsigned, /* super */ - "codeflag", /* name */ - sizeof(grib_accessor_codeflag), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_codeflag = &_grib_accessor_class_codeflag; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* param) -{ - grib_accessor_codeflag* self = (grib_accessor_codeflag*)a; - a->length = len; - self->tablename = grib_arguments_get_string(grib_handle_of_accessor(a), param, 0); - Assert(a->length >= 0); -} - -static int test_bit(long a, long b) -{ - DEBUG_ASSERT(b>=0); - return a & (1 << b); -} - -static int grib_get_codeflag(grib_accessor* a, long code, char* codename) -{ - grib_accessor_codeflag* self = (grib_accessor_codeflag*)a; - FILE* f = NULL; - char fname[1024]; - char bval[50]; - char num[50]; - char* filename = 0; - char line[1024]; - size_t i = 0; - int j = 0; - int err = 0; - - err = grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); - if (err) { - strncpy(fname, self->tablename, sizeof(fname)-1); - fname[sizeof(fname)-1] = '\0'; - } - - if ((filename = grib_context_full_defs_path(a->context, fname)) == NULL) { - grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot open flag table %s", filename); - strcpy(codename, "Cannot open flag table"); - return GRIB_FILE_NOT_FOUND; - } - - f = codes_fopen(filename, "r"); - if (!f) { - grib_context_log(a->context, (GRIB_LOG_WARNING) | (GRIB_LOG_PERROR), "Cannot open flag table %s", filename); - strcpy(codename, "Cannot open flag table"); - return GRIB_FILE_NOT_FOUND; - } - - // strcpy(codename, self->tablename); - // strcat(codename,": "); - // j = strlen(codename); - - while (fgets(line, sizeof(line) - 1, f)) { - sscanf(line, "%49s %49s", num, bval); - - if (num[0] != '#') { - if ((test_bit(code, a->length * 8 - atol(num)) > 0) == atol(bval)) { - size_t linelen = strlen(line); - codename[j++] = '('; - codename[j++] = num[0]; - codename[j++] = '='; - codename[j++] = bval[0]; - codename[j++] = ')'; - codename[j++] = ' '; - if (j) - codename[j++] = ' '; - - for (i = (strlen(num) + strlen(bval) + 2); i < linelen - 1; i++) - codename[j++] = line[i]; - if (line[i] != '\n') - codename[j++] = line[i]; - codename[j++] = ';'; - } - } - } - - if (j > 1 && codename[j - 1] == ';') - j--; - codename[j] = 0; - - strcat(codename, ":"); - strcat(codename, fname); - - fclose(f); - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_accessor_codeflag* self = (grib_accessor_codeflag*)a; - long v; - char flagname[1024]; - char fname[1024]; - - size_t llen = 1; - - grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1); - grib_unpack_long(a, &v, &llen); - - grib_get_codeflag(a, v, flagname); - - grib_dump_bits(dumper, a, flagname); -} diff --git a/src/grib_accessor_class_codetable_title.cc b/src/grib_accessor_class_codetable_title.cc deleted file mode 100644 index 2ddd0f3cb..000000000 --- a/src/grib_accessor_class_codetable_title.cc +++ /dev/null @@ -1,171 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string; get_native_type - MEMBERS = const char* codetable - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_codetable_title -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in codetable_title */ - const char* codetable; -} grib_accessor_codetable_title; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_codetable_title = { - &grib_accessor_class_gen, /* super */ - "codetable_title", /* name */ - sizeof(grib_accessor_codetable_title), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_codetable_title = &_grib_accessor_class_codetable_title; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_codetable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in codetable */ - const char* tablename; - const char* masterDir; - const char* localDir; - grib_codetable* table; -} grib_accessor_codetable; - - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - grib_accessor_codetable_title* self = (grib_accessor_codetable_title*)a; - int n = 0; - self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_codetable_title* self = (grib_accessor_codetable_title*)a; - grib_codetable* table = NULL; - - size_t size = 1; - long value; - int err = GRIB_SUCCESS; - char tmp[1024]; - size_t l = 1024; - grib_accessor_codetable* ca = (grib_accessor_codetable*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); - - if ((err = grib_unpack_long((grib_accessor*)ca, &value, &size)) != GRIB_SUCCESS) - return err; - - table = ca->table; - - if (table && (value >= 0) && (value < table->size) && table->entries[value].title) { - strcpy(tmp, table->entries[value].title); - } - else { - snprintf(tmp, sizeof(tmp), "%d", (int)value); - } - - l = strlen(tmp) + 1; - - if (*len < l) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - strcpy(buffer, tmp); - *len = l; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_codetable_units.cc b/src/grib_accessor_class_codetable_units.cc deleted file mode 100644 index de9a9655f..000000000 --- a/src/grib_accessor_class_codetable_units.cc +++ /dev/null @@ -1,171 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string; get_native_type - MEMBERS = const char* codetable - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_codetable_units -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in codetable_units */ - const char* codetable; -} grib_accessor_codetable_units; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_codetable_units = { - &grib_accessor_class_gen, /* super */ - "codetable_units", /* name */ - sizeof(grib_accessor_codetable_units), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_codetable_units = &_grib_accessor_class_codetable_units; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_codetable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in codetable */ - const char* tablename; - const char* masterDir; - const char* localDir; - grib_codetable* table; -} grib_accessor_codetable; - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - grib_accessor_codetable_units* self = (grib_accessor_codetable_units*)a; - - int n = 0; - self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_codetable_units* self = (grib_accessor_codetable_units*)a; - grib_codetable* table = NULL; - - size_t size = 1; - long value; - int err = GRIB_SUCCESS; - char tmp[1024]; - size_t l = sizeof(tmp); - grib_accessor_codetable* ca = (grib_accessor_codetable*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); - - if ((err = grib_unpack_long((grib_accessor*)ca, &value, &size)) != GRIB_SUCCESS) - return err; - - table = ca->table; - - if (table && (value >= 0) && (value < table->size) && table->entries[value].units) { - strcpy(tmp, table->entries[value].units); - } - else { - snprintf(tmp, sizeof(tmp), "%d", (int)value); - } - - l = strlen(tmp) + 1; - - if (*len < l) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - strcpy(buffer, tmp); - *len = l; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_constant.cc b/src/grib_accessor_class_constant.cc deleted file mode 100644 index b54de5b88..000000000 --- a/src/grib_accessor_class_constant.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - - -/************************************* - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_variable - IMPLEMENTS = init - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_constant -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in variable */ - double dval; - float fval; - char* cval; - char* cname; - int type; - /* Members defined in constant */ -} grib_accessor_constant; - -extern grib_accessor_class* grib_accessor_class_variable; - -static grib_accessor_class _grib_accessor_class_constant = { - &grib_accessor_class_variable, /* super */ - "constant", /* name */ - sizeof(grib_accessor_constant), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_constant = &_grib_accessor_class_constant; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} diff --git a/src/grib_accessor_class_count_file.cc b/src/grib_accessor_class_count_file.cc deleted file mode 100644 index 196a48038..000000000 --- a/src/grib_accessor_class_count_file.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/*********************************************** - * Enrico Fucile - **********************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_count_file -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in count_file */ -} grib_accessor_count_file; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_count_file = { - &grib_accessor_class_long, /* super */ - "count_file", /* name */ - sizeof(grib_accessor_count_file), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_count_file = &_grib_accessor_class_count_file; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - *val = grib_context_get_handle_file_count(a->context); - *len = 1; - return 0; -} diff --git a/src/grib_accessor_class_count_total.cc b/src/grib_accessor_class_count_total.cc deleted file mode 100644 index 022cc4998..000000000 --- a/src/grib_accessor_class_count_total.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - - -/*************************************************** - * Enrico Fucile - **************************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_count_total -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in count_total */ -} grib_accessor_count_total; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_count_total = { - &grib_accessor_class_long, /* super */ - "count_total", /* name */ - sizeof(grib_accessor_count_total), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_count_total = &_grib_accessor_class_count_total; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - *val = grib_context_get_handle_total_count(a->context); - *len = 1; - return 0; -} diff --git a/src/grib_accessor_class_data_dummy_field.cc b/src/grib_accessor_class_data_dummy_field.cc deleted file mode 100644 index 65b6d5a8f..000000000 --- a/src/grib_accessor_class_data_dummy_field.cc +++ /dev/null @@ -1,219 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_g1simple_packing - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - IMPLEMENTS = pack_double - MEMBERS=const char* missing_value - MEMBERS=const char* numberOfPoints - MEMBERS=const char* bitmap - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_dummy_field -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g1simple_packing */ - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; - /* Members defined in data_dummy_field */ - const char* missing_value; - const char* numberOfPoints; - const char* bitmap; -} grib_accessor_data_dummy_field; - -extern grib_accessor_class* grib_accessor_class_data_g1simple_packing; - -static grib_accessor_class _grib_accessor_class_data_dummy_field = { - &grib_accessor_class_data_g1simple_packing, /* super */ - "data_dummy_field", /* name */ - sizeof(grib_accessor_data_dummy_field), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_dummy_field = &_grib_accessor_class_data_dummy_field; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->numberOfPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - size_t i = 0, n_vals = 0; - long numberOfPoints; - double missing_value = 0; - int err = 0; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints)) != GRIB_SUCCESS) - return err; - n_vals = numberOfPoints; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < n_vals; i++) - val[i] = missing_value; - - if (grib_find_accessor(grib_handle_of_accessor(a), self->bitmap)) { - if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->bitmap, val, n_vals)) != GRIB_SUCCESS) - return err; - } - - *len = (long)n_vals; - return err; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - - size_t n_vals = *len; - int err = 0; - long bits_per_value = 0; - long half_byte = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return err; - - buflen = (1 + ((bits_per_value * n_vals) / 8)) * sizeof(unsigned char); - - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); - if (!buf) - return GRIB_OUT_OF_MEMORY; - - half_byte = (buflen * 8) - ((*len) * bits_per_value); - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, half_byte)) != GRIB_SUCCESS) { - grib_context_free(a->context, buf); - return err; - } - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_free(a->context, buf); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* numberOfPoints) -{ - grib_accessor_data_dummy_field* self = (grib_accessor_data_dummy_field*)a; - int err = 0; - *numberOfPoints = 0; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints)) != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to get count of %s (%s)", a->name, grib_get_error_message(err)); - } - - return err; -} diff --git a/src/grib_accessor_class_data_g1complex_packing.cc b/src/grib_accessor_class_data_g1complex_packing.cc deleted file mode 100644 index 6c8fa5cd6..000000000 --- a/src/grib_accessor_class_data_g1complex_packing.cc +++ /dev/null @@ -1,235 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_complex_packing - IMPLEMENTS = pack_double - IMPLEMENTS = init - MEMBERS= const char* N - MEMBERS=const char* half_byte - MEMBERS=const char* packingType - MEMBERS=const char* ieee_packing - MEMBERS=const char* precision - END_CLASS_DEF - - */ - - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1complex_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_complex_packing */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; - /* Members defined in data_g1complex_packing */ - const char* N; - const char* half_byte; - const char* packingType; - const char* ieee_packing; - const char* precision; -} grib_accessor_data_g1complex_packing; - -extern grib_accessor_class* grib_accessor_class_data_complex_packing; - -static grib_accessor_class _grib_accessor_class_data_g1complex_packing = { - &grib_accessor_class_data_complex_packing, /* super */ - "data_g1complex_packing", /* name */ - sizeof(grib_accessor_data_g1complex_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g1complex_packing = &_grib_accessor_class_data_g1complex_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1complex_packing* self = (grib_accessor_data_g1complex_packing*)a; - self->half_byte = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->N = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->packingType = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->ieee_packing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->edition = 1; - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g1complex_packing* self = (grib_accessor_data_g1complex_packing*)a; - int ret = GRIB_SUCCESS; - long seclen = 0; - long sub_j = 0; - long sub_k = 0; - long sub_m = 0; - long n = 0; - long half_byte = 0; - long bits_per_value = 0; - size_t buflen = 0; - grib_accessor_class* super = *(a->cclass->super); - - if (*len == 0) - return GRIB_NO_VALUES; - -// /* TODO: spectral_ieee does not work */ -// if (c->ieee_packing && self->ieee_packing) { -// grib_handle* h = grib_handle_of_accessor(a); -// grib_context* c = a->context; -// char* packingType_s = NULL; -// char* ieee_packing_s = NULL; -// long precision = c->ieee_packing == 32 ? 1 : 2; -// size_t lenstr = strlen(self->ieee_packing); - -// packingType_s = grib_context_strdup(c, self->packingType); -// ieee_packing_s = grib_context_strdup(c, self->ieee_packing); -// precision_s = grib_context_strdup(c, self->precision); - -// grib_set_string(h, packingType_s, ieee_packing_s, &lenstr); -// grib_set_long(h, precision_s, precision); - -// grib_context_free(c, packingType_s); -// grib_context_free(c, ieee_packing_s); -// grib_context_free(c, precision_s); -// return grib_set_double_array(h, "values", val, *len); -// } - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_j, &sub_j)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_k, &sub_k)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->sub_m, &sub_m)) != GRIB_SUCCESS) - return ret; - - self->dirty = 1; - - Assert((sub_j == sub_k) && (sub_m == sub_j)); - - ret = super->pack_double(a, val, len); - - if (ret == GRIB_SUCCESS) { - n = a->offset + 4 * ((sub_k + 1) * (sub_k + 2)); - - /* Octet number starts from beginning of message but shouldn't */ - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n)) != GRIB_SUCCESS) - return ret; - - // ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection); - // if (ret != GRIB_SUCCESS) - // return ret; - // if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->N, n - offsetsection)) != GRIB_SUCCESS) - // return ret; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value); - if (ret != GRIB_SUCCESS) - return ret; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->seclen, &seclen); - if (ret != GRIB_SUCCESS) - return ret; - - buflen = 32 * (sub_k + 1) * (sub_k + 2) + (*len - (sub_k + 1) * (sub_k + 2)) * bits_per_value + 18 * 8; - half_byte = seclen * 8 - buflen; - if (a->context->debug == -1) { - fprintf(stderr, "ECCODES DEBUG: half_byte=%ld\n", half_byte); - } - - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->half_byte, half_byte); - if (ret != GRIB_SUCCESS) - return ret; - } - return ret; -} diff --git a/src/grib_accessor_class_data_g1secondary_bitmap.cc b/src/grib_accessor_class_data_g1secondary_bitmap.cc deleted file mode 100644 index 4ae89c576..000000000 --- a/src/grib_accessor_class_data_g1secondary_bitmap.cc +++ /dev/null @@ -1,220 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_secondary_bitmap - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* number_of_ones - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g1secondary_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_secondary_bitmap */ - const char* primary_bitmap; - const char* secondary_bitmap; - const char* missing_value; - const char* expand_by; - /* Members defined in data_g1secondary_bitmap */ - const char* number_of_ones; -} grib_accessor_data_g1secondary_bitmap; - -extern grib_accessor_class* grib_accessor_class_data_secondary_bitmap; - -static grib_accessor_class _grib_accessor_class_data_g1secondary_bitmap = { - &grib_accessor_class_data_secondary_bitmap, /* super */ - "data_g1secondary_bitmap", /* name */ - sizeof(grib_accessor_data_g1secondary_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g1secondary_bitmap = &_grib_accessor_class_data_g1secondary_bitmap; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g1secondary_bitmap* self = (grib_accessor_data_g1secondary_bitmap*)a; - self->number_of_ones = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_g1secondary_bitmap* self = (grib_accessor_data_g1secondary_bitmap*)a; - size_t len = 0; - int err = 0; - long expand_by; - *count = 0; - - err = grib_get_long_internal(grib_handle_of_accessor(a), self->expand_by, &expand_by); - if (err) - return err; - - err = grib_get_size(grib_handle_of_accessor(a), self->primary_bitmap, &len); - if (err) - return err; - - *count = expand_by * len; - return GRIB_SUCCESS; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g1secondary_bitmap* self = (grib_accessor_data_g1secondary_bitmap*)a; - - int err = 0; - - long primary_len = 0; - long secondary_len = 0; - double* primary_bitmap = NULL; - double* secondary_bitmap = NULL; - long i = 0; - long j = 0; - long on = 0; - long k; - long m; - double missing_value = 0; - double present_value = 0; - long expand_by = 0; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) - return err; - if (expand_by <= 0) - return GRIB_ENCODING_ERROR; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len % expand_by) { - /*TODO: issue warning */ - return GRIB_ENCODING_ERROR; - } - - primary_len = *len / expand_by; - primary_bitmap = (double*)grib_context_malloc_clear(a->context, primary_len * sizeof(double)); - if (!primary_bitmap) - return GRIB_OUT_OF_MEMORY; - - secondary_len = *len; - secondary_bitmap = (double*)grib_context_malloc_clear(a->context, secondary_len * sizeof(double)); - if (!secondary_bitmap) { - grib_context_free(a->context, primary_bitmap); - return GRIB_OUT_OF_MEMORY; - } - - if (missing_value == 0) - present_value = 1; - else - present_value = 0; - - k = 0; - m = 0; - for (i = 0; i < *len; i += expand_by) { - int cnt = 0; - for (j = 0; j < expand_by; j++) - if (val[i + j] == missing_value) - cnt++; - - if (cnt == expand_by) /* all expand_by values are missing */ - primary_bitmap[k++] = missing_value; - else { - primary_bitmap[k++] = present_value; - for (j = 0; j < expand_by; j++) - secondary_bitmap[m++] = val[i + j]; - on++; - } - } - - *len = k; - - /*printf("QQQQQQQ %ld %ld second=%ld\n",primary_len,on,m);*/ - Assert(k == primary_len); - - err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_bitmap, k); - if (err == GRIB_SUCCESS) - err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_bitmap, m); - - grib_context_free(a->context, primary_bitmap); - grib_context_free(a->context, secondary_bitmap); - - if (err == GRIB_SUCCESS) - err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_ones, on); - - return err; -} diff --git a/src/grib_accessor_class_data_g1shsimple_packing.cc b/src/grib_accessor_class_data_g1shsimple_packing.cc deleted file mode 100644 index 332b0af0c..000000000 --- a/src/grib_accessor_class_data_g1shsimple_packing.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_shsimple_packing - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); - -typedef struct grib_accessor_data_g1shsimple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_shsimple_packing */ - const char* coded_values; - const char* real_part; - int dirty; - /* Members defined in data_g1shsimple_packing */ -} grib_accessor_data_g1shsimple_packing; - -extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; - -static grib_accessor_class _grib_accessor_class_data_g1shsimple_packing = { - &grib_accessor_class_data_shsimple_packing, /* super */ - "data_g1shsimple_packing", /* name */ - sizeof(grib_accessor_data_g1shsimple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g1shsimple_packing = &_grib_accessor_class_data_g1shsimple_packing; - -/* END_CLASS_IMP */ - - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_data_g1shsimple_packing* self = (grib_accessor_data_g1shsimple_packing*)a; - size_t len = 0; - int err = 0; - - err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &len); - len += 1; - - *count = len; - return err; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_g1shsimple_packing* self = (grib_accessor_data_g1shsimple_packing*)a; - int err = GRIB_SUCCESS; - - size_t coded_n_vals = 0; - size_t n_vals = 0; - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &coded_n_vals)) != GRIB_SUCCESS) - return err; - - n_vals = coded_n_vals + 1; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->real_part, val)) != GRIB_SUCCESS) - return err; - - val++; - - if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, &coded_n_vals)) != GRIB_SUCCESS) - return err; - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_data_g1shsimple_packing_bitmap : unpack_double : creating %s, %d values", - a->name, n_vals); - - *len = n_vals; - - return err; -} diff --git a/src/grib_accessor_class_data_g2complex_packing.cc b/src/grib_accessor_class_data_g2complex_packing.cc deleted file mode 100644 index 98bcaf5cc..000000000 --- a/src/grib_accessor_class_data_g2complex_packing.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_complex_packing - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS=const char* numberOfValues - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2complex_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_complex_packing */ - const char* GRIBEX_sh_bug_present; - const char* ieee_floats; - const char* laplacianOperatorIsSet; - const char* laplacianOperator; - const char* sub_j; - const char* sub_k; - const char* sub_m; - const char* pen_j; - const char* pen_k; - const char* pen_m; - /* Members defined in data_g2complex_packing */ - const char* numberOfValues; -} grib_accessor_data_g2complex_packing; - -extern grib_accessor_class* grib_accessor_class_data_complex_packing; - -static grib_accessor_class _grib_accessor_class_data_g2complex_packing = { - &grib_accessor_class_data_complex_packing, /* super */ - "data_g2complex_packing", /* name */ - sizeof(grib_accessor_data_g2complex_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2complex_packing = &_grib_accessor_class_data_g2complex_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2complex_packing* self = (grib_accessor_data_g2complex_packing*)a; - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->edition = 2; - - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int value_count(grib_accessor* a, long* numberOfValues) -{ - grib_accessor_data_g2complex_packing* self = (grib_accessor_data_g2complex_packing*)a; - *numberOfValues = 0; - - return grib_get_long(grib_handle_of_accessor(a), self->numberOfValues, numberOfValues); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2complex_packing* self = (grib_accessor_data_g2complex_packing*)a; - int ret = GRIB_SUCCESS; - grib_accessor_class* super = *(a->cclass->super); - - if (*len == 0) - return GRIB_NO_VALUES; - - ret = super->pack_double(a, val, len); - - if (ret == GRIB_SUCCESS) - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, *len); - - return ret; -} diff --git a/src/grib_accessor_class_data_g2secondary_bitmap.cc b/src/grib_accessor_class_data_g2secondary_bitmap.cc deleted file mode 100644 index cceb3d765..000000000 --- a/src/grib_accessor_class_data_g2secondary_bitmap.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_secondary_bitmap - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* number_of_values - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2secondary_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_secondary_bitmap */ - const char* primary_bitmap; - const char* secondary_bitmap; - const char* missing_value; - const char* expand_by; - /* Members defined in data_g2secondary_bitmap */ - const char* number_of_values; -} grib_accessor_data_g2secondary_bitmap; - -extern grib_accessor_class* grib_accessor_class_data_secondary_bitmap; - -static grib_accessor_class _grib_accessor_class_data_g2secondary_bitmap = { - &grib_accessor_class_data_secondary_bitmap, /* super */ - "data_g2secondary_bitmap", /* name */ - sizeof(grib_accessor_data_g2secondary_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2secondary_bitmap = &_grib_accessor_class_data_g2secondary_bitmap; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a; - self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 4); -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a; - *len = 0; - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2secondary_bitmap* self = (grib_accessor_data_g2secondary_bitmap*)a; - int err = 0; - - long primary_len = 0, secondary_len = 0; - double* primary_bitmap = NULL; - double* secondary_bitmap = NULL; - long i = 0, j = 0, k = 0, m = 0; - double missing_value = 0, present_value = 0; - long expand_by = 0; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) - return err; - if (expand_by <= 0) - return GRIB_ENCODING_ERROR; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if (*len % expand_by) { - /*TODO: issue warning */ - return GRIB_ENCODING_ERROR; - } - - primary_len = *len / expand_by; - primary_bitmap = (double*)grib_context_malloc_clear(a->context, primary_len * sizeof(double)); - if (!primary_bitmap) - return GRIB_OUT_OF_MEMORY; - - secondary_len = *len; - secondary_bitmap = (double*)grib_context_malloc_clear(a->context, secondary_len * sizeof(double)); - if (!secondary_bitmap) { - grib_context_free(a->context, primary_bitmap); - return GRIB_OUT_OF_MEMORY; - } - - if (missing_value == 0) - present_value = 1; - else - present_value = 0; - - k = 0; - m = 0; - for (i = 0; i < *len; i += expand_by) { - int cnt = 0; - for (j = 0; j < expand_by; j++) - if (val[i + j] == missing_value) - cnt++; - - if (cnt == expand_by) /* all expand_by values are missing */ - primary_bitmap[k++] = missing_value; - else { - primary_bitmap[k++] = present_value; - for (j = 0; j < expand_by; j++) - secondary_bitmap[m++] = val[i + j]; - //on++; - } - } - - *len = k; - - Assert(k == primary_len); - - err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_bitmap, k); - if (err == GRIB_SUCCESS) - err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_bitmap, m); - - grib_context_free(a->context, primary_bitmap); - grib_context_free(a->context, secondary_bitmap); - - if (err == GRIB_SUCCESS) - err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, *len * expand_by); - - return err; -} diff --git a/src/grib_accessor_class_data_g2shsimple_packing.cc b/src/grib_accessor_class_data_g2shsimple_packing.cc deleted file mode 100644 index bdb1157cf..000000000 --- a/src/grib_accessor_class_data_g2shsimple_packing.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_shsimple_packing - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* numberOfValues - MEMBERS=const char* numberOfDataPoints - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2shsimple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_shsimple_packing */ - const char* coded_values; - const char* real_part; - int dirty; - /* Members defined in data_g2shsimple_packing */ - const char* numberOfValues; - const char* numberOfDataPoints; -} grib_accessor_data_g2shsimple_packing; - -extern grib_accessor_class* grib_accessor_class_data_shsimple_packing; - -static grib_accessor_class _grib_accessor_class_data_g2shsimple_packing = { - &grib_accessor_class_data_shsimple_packing, /* super */ - "data_g2shsimple_packing", /* name */ - sizeof(grib_accessor_data_g2shsimple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2shsimple_packing = &_grib_accessor_class_data_g2shsimple_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2shsimple_packing* self = (grib_accessor_data_g2shsimple_packing*)a; - - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); - self->numberOfDataPoints = grib_arguments_get_name(grib_handle_of_accessor(a), args, 3); - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_data_g2shsimple_packing* self = (grib_accessor_data_g2shsimple_packing*)a; - *len = 0; - return grib_get_long(grib_handle_of_accessor(a), self->numberOfValues, len); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_g2shsimple_packing* self = (grib_accessor_data_g2shsimple_packing*)a; - int err = GRIB_SUCCESS; - - size_t n_vals = 0; - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->coded_values, &n_vals)) != GRIB_SUCCESS) - return err; - - self->dirty = 0; - - /* n_vals = coded_n_vals+1; */ - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->real_part, val)) != GRIB_SUCCESS) - return err; - - val++; - - if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, &n_vals)) != GRIB_SUCCESS) - return err; - - *len = n_vals; - - return err; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2shsimple_packing* self = (grib_accessor_data_g2shsimple_packing*)a; - int err = GRIB_SUCCESS; - - size_t coded_n_vals = *len - 1; - size_t n_vals = *len; - - if (*len == 0) - return GRIB_NO_VALUES; - - self->dirty = 1; - - if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->real_part, *val)) != GRIB_SUCCESS) - return err; - - val++; - - if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, coded_n_vals)) != GRIB_SUCCESS) - return err; - - *len = n_vals; - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, (long)n_vals)) != GRIB_SUCCESS) - return err; - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfDataPoints, (long)n_vals)) != GRIB_SUCCESS) - return err; - - return err; -} diff --git a/src/grib_accessor_class_data_g2simple_packing.cc b/src/grib_accessor_class_data_g2simple_packing.cc deleted file mode 100644 index 69e1bdbc9..000000000 --- a/src/grib_accessor_class_data_g2simple_packing.cc +++ /dev/null @@ -1,265 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_scaling.h" -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = pack_bytes - IMPLEMENTS = value_count - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_bytes(grib_accessor*, const unsigned char*, size_t* len); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2simple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g2simple_packing */ -} grib_accessor_data_g2simple_packing; - -extern grib_accessor_class* grib_accessor_class_data_simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g2simple_packing = { - &grib_accessor_class_data_simple_packing, /* super */ - "data_g2simple_packing", /* name */ - sizeof(grib_accessor_data_g2simple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - &pack_bytes, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2simple_packing = &_grib_accessor_class_data_g2simple_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2simple_packing* self = (grib_accessor_data_g2simple_packing*)a; - a->flags |= GRIB_ACCESSOR_FLAG_DATA; - self->edition = 2; -} - -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_g2simple_packing* self = (grib_accessor_data_g2simple_packing*)a; - *n_vals = 0; - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); -} - -static int pack_double(grib_accessor* a, const double* cval, size_t* len) -{ - grib_accessor_data_g2simple_packing* self = (grib_accessor_data_g2simple_packing*)a; - grib_accessor_class* super = *(a->cclass->super); - size_t n_vals = *len; - double reference_value = 0; - long binary_scale_factor = 0; - long bits_per_value = 0; - long decimal_scale_factor = 0; - double decimal = 1; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned char* encoded = NULL; - double divisor = 1; - long off = 0; - int ret = 0; - double units_factor = 1.0; - double units_bias = 0.0; - double* val = (double*)cval; - int i; - grib_context* c = a->context; - - if (*len == 0) { - grib_buffer_replace(a, NULL, 0, 1, 1); - return GRIB_SUCCESS; - } - - if (ret == GRIB_SUCCESS) - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, *len); - - if (ret != GRIB_SUCCESS) - return ret; - - if (self->units_factor && - (grib_get_double_internal(grib_handle_of_accessor(a), self->units_factor, &units_factor) == GRIB_SUCCESS)) { - grib_set_double_internal(grib_handle_of_accessor(a), self->units_factor, 1.0); - } - - if (self->units_bias && - (grib_get_double_internal(grib_handle_of_accessor(a), self->units_bias, &units_bias) == GRIB_SUCCESS)) { - grib_set_double_internal(grib_handle_of_accessor(a), self->units_bias, 0.0); - } - - if (units_factor != 1.0) { - if (units_bias != 0.0) - for (i = 0; i < n_vals; i++) - val[i] = val[i] * units_factor + units_bias; - else - for (i = 0; i < n_vals; i++) - val[i] *= units_factor; - } - else if (units_bias != 0.0) - for (i = 0; i < n_vals; i++) - val[i] += units_bias; - - /* IEEE packing */ - if (c->ieee_packing) { - grib_handle* h = grib_handle_of_accessor(a); - long precision = 0; /* Either 1(=32 bits) or 2(=64 bits) */ - size_t lenstr = 10; - if ((ret = codes_check_grib_ieee_packing_value(c->ieee_packing)) != GRIB_SUCCESS) - return ret; - precision = c->ieee_packing == 32 ? 1 : 2; - if ((ret = grib_set_string(h, "packingType", "grid_ieee", &lenstr)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long(h, "precision", precision)) != GRIB_SUCCESS) - return ret; - - return grib_set_double_array(h, "values", val, *len); - } - - if (super != grib_accessor_class_data_g2simple_packing) { - /* Normal case: parent not same as me! */ - ret = super->pack_double(a, val, len); - } - else { - /* GRIB-364: simple packing with logarithm pre-processing */ - grib_accessor_class* super2 = NULL; - Assert(super->super); - super2 = *(super->super); - ret = super2->pack_double(a, val, len); - } - switch (ret) { - case GRIB_CONSTANT_FIELD: - grib_buffer_replace(a, NULL, 0, 1, 1); - return GRIB_SUCCESS; - case GRIB_SUCCESS: - break; - default: - grib_context_log(a->context, GRIB_LOG_ERROR, "GRIB2 simple packing: unable to set values (%s)", grib_get_error_message(ret)); - return ret; - } - - if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), self->reference_value, &reference_value)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bits_per_value, &bits_per_value)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS) - return ret; - - decimal = codes_power(decimal_scale_factor, 10); - divisor = codes_power(-binary_scale_factor, 2); - - buflen = (((bits_per_value * n_vals) + 7) / 8) * sizeof(unsigned char); - buf = (unsigned char*)grib_context_buffer_malloc_clear(a->context, buflen); - encoded = buf; - - grib_encode_double_array(n_vals, val, bits_per_value, reference_value, decimal, divisor, encoded, &off); - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_data_g2simple_packing : pack_double : packing %s, %d values", a->name, n_vals); - - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_buffer_free(a->context, buf); - - return ret; -} - -static int pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) -{ - size_t length = *len; - grib_buffer_replace(a, val, length, 1, 1); - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc deleted file mode 100644 index 88a4de2cb..000000000 --- a/src/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc +++ /dev/null @@ -1,287 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#define DIRECT 0 -#define INVERSE 1 - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_data_g2simple_packing - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - MEMBERS=const char* pre_processing - MEMBERS=const char* pre_processing_parameter - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_g2simple_packing_with_preprocessing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_simple_packing */ - int edition; - const char* units_factor; - const char* units_bias; - const char* changing_precision; - const char* number_of_values; - const char* bits_per_value; - const char* reference_value; - const char* binary_scale_factor; - const char* decimal_scale_factor; - const char* optimize_scaling_factor; - /* Members defined in data_g2simple_packing */ - /* Members defined in data_g2simple_packing_with_preprocessing */ - const char* pre_processing; - const char* pre_processing_parameter; -} grib_accessor_data_g2simple_packing_with_preprocessing; - -extern grib_accessor_class* grib_accessor_class_data_g2simple_packing; - -static grib_accessor_class _grib_accessor_class_data_g2simple_packing_with_preprocessing = { - &grib_accessor_class_data_g2simple_packing, /* super */ - "data_g2simple_packing_with_preprocessing", /* name */ - sizeof(grib_accessor_data_g2simple_packing_with_preprocessing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_g2simple_packing_with_preprocessing = &_grib_accessor_class_data_g2simple_packing_with_preprocessing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_g2simple_packing_with_preprocessing* self = (grib_accessor_data_g2simple_packing_with_preprocessing*)a; - self->pre_processing = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->pre_processing_parameter = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_g2simple_packing_with_preprocessing* self = (grib_accessor_data_g2simple_packing_with_preprocessing*)a; - *n_vals = 0; - - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); -} - -static int pre_processing_func(double* values, long length, long pre_processing, - double* pre_processing_parameter, int mode) -{ - int i = 0, ret = 0; - double min = values[0]; - double next_min = values[0]; - Assert(length > 0); - - switch (pre_processing) { - /* NONE */ - case 0: - break; - /* LOGARITHM */ - case 1: - if (mode == DIRECT) { - for (i = 0; i < length; i++) { - if (values[i] < min) - min = values[i]; - if (values[i] > next_min) - next_min = values[i]; - } - for (i = 0; i < length; i++) { - if (values[i] > min && values[i] < next_min) - next_min = values[i]; - } - if (min > 0) { - *pre_processing_parameter = 0; - for (i = 0; i < length; i++) { - DEBUG_ASSERT(values[i] > 0); - values[i] = log(values[i]); - } - } - else { - double ppp = 0; - *pre_processing_parameter = next_min - 2 * min; - if (next_min == min) - return ret; - ppp = *pre_processing_parameter; - for (i = 0; i < length; i++) { - DEBUG_ASSERT((values[i] + ppp) > 0); - values[i] = log(values[i] + ppp); - } - } - } - else { - Assert(mode == INVERSE); - if (*pre_processing_parameter == 0) { - for (i = 0; i < length; i++) - values[i] = exp(values[i]); - } - else { - for (i = 0; i < length; i++) - values[i] = exp(values[i]) - *pre_processing_parameter; - } - } - break; - default: - ret = GRIB_NOT_IMPLEMENTED; - break; - } - - return ret; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_g2simple_packing_with_preprocessing* self = (grib_accessor_data_g2simple_packing_with_preprocessing*)a; - grib_accessor_class* super = *(a->cclass->super); - grib_accessor_class* super2 = NULL; - - size_t n_vals = 0; - long nn = 0; - int err = 0; - - long pre_processing; - double pre_processing_parameter; - - err = grib_value_count(a, &nn); - n_vals = nn; - if (err) - return err; - - if (n_vals == 0) { - *len = 0; - return GRIB_SUCCESS; - } - - self->dirty = 0; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->pre_processing, &pre_processing)) != GRIB_SUCCESS) { - return err; - } - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->pre_processing_parameter, &pre_processing_parameter)) != GRIB_SUCCESS) { - return err; - } - - Assert(super->super); - super2 = *(super->super); - err = super2->unpack_double(a, val, &n_vals); /* GRIB-364 */ - if (err != GRIB_SUCCESS) - return err; - - err = pre_processing_func(val, n_vals, pre_processing, &pre_processing_parameter, INVERSE); - if (err != GRIB_SUCCESS) - return err; - - *len = (long)n_vals; - - return err; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_g2simple_packing_with_preprocessing* self = (grib_accessor_data_g2simple_packing_with_preprocessing*)a; - grib_accessor_class* super = *(a->cclass->super); - - size_t n_vals = *len; - int err = 0; - - long pre_processing = 0; - double pre_processing_parameter = 0; - - self->dirty = 1; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->pre_processing, &pre_processing)) != GRIB_SUCCESS) - return err; - - err = pre_processing_func((double*)val, n_vals, pre_processing, &pre_processing_parameter, DIRECT); - if (err != GRIB_SUCCESS) - return err; - - err = super->pack_double(a, val, len); - if (err != GRIB_SUCCESS) - return err; - - if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->pre_processing_parameter, pre_processing_parameter)) != GRIB_SUCCESS) - return err; - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals)) != GRIB_SUCCESS) - return err; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_data_raw_packing.cc b/src/grib_accessor_class_data_raw_packing.cc deleted file mode 100644 index 336c73684..000000000 --- a/src/grib_accessor_class_data_raw_packing.cc +++ /dev/null @@ -1,309 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ -/***************************** - * Enrico Fucile - ****************************/ - -#include "grib_ieeefloat.h" - -#define PRE_PROCESSING_NONE 0 -#define PRE_PROCESSING_DIFFERENCE 1 -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_values - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_double_element;unpack_double_element_set - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - MEMBERS=const char* number_of_values - MEMBERS=const char* precision - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); - -typedef struct grib_accessor_data_raw_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; - /* Members defined in data_raw_packing */ - const char* number_of_values; - const char* precision; -} grib_accessor_data_raw_packing; - -extern grib_accessor_class* grib_accessor_class_values; - -static grib_accessor_class _grib_accessor_class_data_raw_packing = { - &grib_accessor_class_values, /* super */ - "data_raw_packing", /* name */ - sizeof(grib_accessor_data_raw_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_raw_packing = &_grib_accessor_class_data_raw_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - - self->number_of_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, self->carg++); - a->flags |= GRIB_ACCESSOR_FLAG_DATA; -} - -static int value_count(grib_accessor* a, long* n_vals) -{ - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - *n_vals = 0; - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_values, n_vals); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - unsigned char* buf = NULL; - int bytes = 0; - size_t nvals = 0; - long inlen = grib_byte_count(a); - - long precision = 0; - - int code = GRIB_SUCCESS; - - if ((code = grib_get_long(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) - return code; - - self->dirty = 0; - - buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - buf += grib_byte_offset(a); - - switch (precision) { - case 1: - bytes = 4; - break; - case 2: - bytes = 8; - break; - default: - return GRIB_NOT_IMPLEMENTED; - break; - } - - nvals = inlen / bytes; - - if (*len < nvals) - return GRIB_ARRAY_TOO_SMALL; - - code = grib_ieee_decode_array(a->context, buf, nvals, bytes, val); - - *len = nvals; - - return code; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - - int bytes = 0; - unsigned char* buffer = NULL; - - long precision = 0; - - double* values = (double*)val; - size_t inlen = *len; - - /*int free_buffer = 0; - *int free_values = 0;*/ - - int code = GRIB_SUCCESS; - - size_t bufsize = 0; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((code = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) - return code; - - self->dirty = 1; - - switch (precision) { - case 1: - bytes = 4; - break; - - case 2: - bytes = 8; - break; - - default: - code = GRIB_NOT_IMPLEMENTED; - goto clean_up; - break; - } - - bufsize = bytes * inlen; - - buffer = (unsigned char*)grib_context_malloc(a->context, bufsize); - - if (!buffer) { - code = GRIB_OUT_OF_MEMORY; - goto clean_up; - } - - code = grib_ieee_encode_array(a->context, values, inlen, bytes, buffer); - -clean_up: - /*if (free_buffer) - * free(buffer); - * if (free_values) - * free(values); - */ - - grib_buffer_replace(a, buffer, bufsize, 1, 1); - - grib_context_buffer_free(a->context, buffer); - - if (code == GRIB_SUCCESS) { - code = grib_set_long(grib_handle_of_accessor(a), self->number_of_values, inlen); - if (code == GRIB_READ_ONLY) - code = 0; - } - - return code; -} - -static int unpack_double_element(grib_accessor* a, size_t idx, double* val) -{ - int ret = 0; - grib_accessor_data_raw_packing* self = (grib_accessor_data_raw_packing*)a; - unsigned char* buf = NULL; - int bytes = 0; - size_t nvals = 0; - long inlen = grib_byte_count(a); - long pos = 0; - long precision = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) - return ret; - - self->dirty = 0; - - buf = (unsigned char*)grib_handle_of_accessor(a)->buffer->data; - buf += grib_byte_offset(a); - - switch (precision) { - case 1: - bytes = 4; - break; - - case 2: - bytes = 8; - break; - - default: - return GRIB_NOT_IMPLEMENTED; - break; - } - - pos = bytes * idx; - - Assert(pos <= inlen); - - nvals = 1; - buf += pos; - - ret = grib_ieee_decode_array(a->context, buf, nvals, bytes, val); - - return ret; -} - -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - int err = 0; - size_t i = 0; - for (i=0; iprimary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); - self->secondary_bitmap = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); - self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, 2); - self->expand_by = grib_arguments_get_name(grib_handle_of_accessor(a), args, 3); - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_values(dumper, a); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_data_secondary_bitmap* self = (grib_accessor_data_secondary_bitmap*)a; - - size_t i = 0; - size_t j = 0; - size_t k = 0; - size_t m = 0; - size_t n_vals = 0; - long nn = 0; - long expand_by = 0; - int err = 0; - size_t primary_len; - size_t secondary_len; - double* primary_vals; - double* secondary_vals; - err = grib_value_count(a, &nn); - n_vals = nn; - if (err) - return err; - - if (*len < n_vals) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_long(grib_handle_of_accessor(a), self->expand_by, &expand_by)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->primary_bitmap, &primary_len)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_size(grib_handle_of_accessor(a), self->secondary_bitmap, &secondary_len)) != GRIB_SUCCESS) - return err; - - primary_vals = (double*)grib_context_malloc(a->context, primary_len * sizeof(double)); - if (!primary_vals) - return GRIB_OUT_OF_MEMORY; - - secondary_vals = (double*)grib_context_malloc(a->context, secondary_len * sizeof(double)); - if (!secondary_vals) { - grib_context_free(a->context, primary_vals); - return GRIB_OUT_OF_MEMORY; - } - - if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->primary_bitmap, primary_vals, &primary_len)) != GRIB_SUCCESS) { - grib_context_free(a->context, secondary_vals); - grib_context_free(a->context, primary_vals); - return err; - } - - if ((err = grib_get_double_array_internal(grib_handle_of_accessor(a), self->secondary_bitmap, secondary_vals, &secondary_len)) != GRIB_SUCCESS) { - grib_context_free(a->context, secondary_vals); - grib_context_free(a->context, primary_vals); - return err; - } - - k = 0; - m = 0; - for (i = 0; i < primary_len; i++) { - /* if(primary_vals[i]) f++; */ - if (primary_vals[i]) { - for (j = 0; j < expand_by; j++) - val[k++] = secondary_vals[m++]; - } - else { - for (j = 0; j < expand_by; j++) - val[k++] = 0; - } - } - - Assert(k <= *len); - Assert(m <= secondary_len); - - /*printf("FOOBAR %d %d %ld %d\n",f,primary_len,expand_by,n_vals);*/ - - *len = n_vals; - - grib_context_free(a->context, primary_vals); - grib_context_free(a->context, secondary_vals); - return err; -} - -static int get_native_type(grib_accessor* a) -{ - // grib_accessor_data_secondary_bitmap* self = (grib_accessor_data_secondary_bitmap*)a; - //return grib_accessor_get_native_type(grib_find_accessor(grib_handle_of_accessor(a),self->coded_values)); - return GRIB_TYPE_DOUBLE; -} diff --git a/src/grib_accessor_class_data_shsimple_packing.cc b/src/grib_accessor_class_data_shsimple_packing.cc deleted file mode 100644 index d06743f8d..000000000 --- a/src/grib_accessor_class_data_shsimple_packing.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = pack_double - IMPLEMENTS = dump;get_native_type - MEMBERS=const char* coded_values - MEMBERS=const char* real_part - MEMBERS=int dirty - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_data_shsimple_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in data_shsimple_packing */ - const char* coded_values; - const char* real_part; - int dirty; -} grib_accessor_data_shsimple_packing; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_data_shsimple_packing = { - &grib_accessor_class_gen, /* super */ - "data_shsimple_packing", /* name */ - sizeof(grib_accessor_data_shsimple_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_data_shsimple_packing = &_grib_accessor_class_data_shsimple_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - grib_accessor_data_shsimple_packing* self = (grib_accessor_data_shsimple_packing*)a; - - self->coded_values = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); - self->real_part = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); - a->flags |= GRIB_ACCESSOR_FLAG_DATA; - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_values(dumper, a); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_data_shsimple_packing* self = (grib_accessor_data_shsimple_packing*)a; - int err = GRIB_SUCCESS; - - size_t coded_n_vals = *len - 1; - size_t n_vals = *len; - - self->dirty = 1; - - if (*len == 0) - return GRIB_NO_VALUES; - - if ((err = grib_set_double_internal(grib_handle_of_accessor(a), self->real_part, *val)) != GRIB_SUCCESS) - return err; - - val++; - - if ((err = grib_set_double_array_internal(grib_handle_of_accessor(a), self->coded_values, val, coded_n_vals)) != GRIB_SUCCESS) - return err; - - *len = n_vals; - - return err; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} diff --git a/src/grib_accessor_class_decimal_precision.cc b/src/grib_accessor_class_decimal_precision.cc deleted file mode 100644 index e498931b7..000000000 --- a/src/grib_accessor_class_decimal_precision.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/********************************** - * Enrico Fucile - *********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* bits_per_value - MEMBERS = const char* changing_precision - MEMBERS = const char* decimal_scale_factor - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_decimal_precision -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in decimal_precision */ - const char* values; - const char* bits_per_value; - const char* changing_precision; - const char* decimal_scale_factor; -} grib_accessor_decimal_precision; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_decimal_precision = { - &grib_accessor_class_long, /* super */ - "decimal_precision", /* name */ - sizeof(grib_accessor_decimal_precision), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_decimal_precision = &_grib_accessor_class_decimal_precision; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_decimal_precision* self = (grib_accessor_decimal_precision*)a; - - self->bits_per_value = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->decimal_scale_factor = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->changing_precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_decimal_precision* self = (grib_accessor_decimal_precision*)a; - grib_handle* h = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(h, self->decimal_scale_factor, val)) != GRIB_SUCCESS) - return ret; - - *len = 1; - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - long bitsPerValue = 0; - double* values = NULL; - size_t size = 0; - int ret = 0; - grib_accessor_decimal_precision* self = (grib_accessor_decimal_precision*)a; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (!self->values) { - if ((ret = grib_set_long_internal(h, self->bits_per_value, 0)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_set_long_internal(h, self->decimal_scale_factor, *val)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_set_long_internal(h, self->changing_precision, 1)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - return GRIB_SUCCESS; - } - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_buffer_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->decimal_scale_factor, *val)) != GRIB_SUCCESS) { - grib_context_buffer_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->bits_per_value, bitsPerValue)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->changing_precision, 1)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_buffer_free(c, values); - return ret; - } - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_dirty.cc b/src/grib_accessor_class_dirty.cc deleted file mode 100644 index ec29923e3..000000000 --- a/src/grib_accessor_class_dirty.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************ - * Enrico Fucile - **********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS = const char* accessor - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_dirty -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in dirty */ - const char* accessor; -} grib_accessor_dirty; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_dirty = { - &grib_accessor_class_long, /* super */ - "dirty", /* name */ - sizeof(grib_accessor_dirty), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_dirty = &_grib_accessor_class_dirty; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_dirty* self = (grib_accessor_dirty*)a; - self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->length = 0; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_dirty* self = (grib_accessor_dirty*)a; - grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); - - if (x) - x->dirty = *val; - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_dirty* self = (grib_accessor_dirty*)a; - grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); - - if (x) - x->dirty = 1; - - *val = 1; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_divdouble.cc b/src/grib_accessor_class_divdouble.cc deleted file mode 100644 index 8ab86e22e..000000000 --- a/src/grib_accessor_class_divdouble.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS = const char* val - MEMBERS = double divisor - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_divdouble -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in divdouble */ - const char* val; - double divisor; -} grib_accessor_divdouble; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_divdouble = { - &grib_accessor_class_double, /* super */ - "divdouble", /* name */ - sizeof(grib_accessor_divdouble), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_divdouble = &_grib_accessor_class_divdouble; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_divdouble* self = (grib_accessor_divdouble*)a; - int n = 0; - - self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->divisor = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - const grib_accessor_divdouble* self = (grib_accessor_divdouble*)a; - int ret = GRIB_SUCCESS; - double value = 0; - - ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value); - if (ret != GRIB_SUCCESS) - return ret; - - if (self->divisor == 0) { - return GRIB_INVALID_ARGUMENT; - } - *val = value / self->divisor; - - *len = 1; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_double.cc b/src/grib_accessor_class_double.cc deleted file mode 100644 index 3a2933aff..000000000 --- a/src/grib_accessor_class_double.cc +++ /dev/null @@ -1,201 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;unpack_string - IMPLEMENTS = pack_missing; - IMPLEMENTS = dump - IMPLEMENTS = compare - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_missing(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_double -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ -} grib_accessor_double; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_double = { - &grib_accessor_class_gen, /* super */ - "double", /* name */ - sizeof(grib_accessor_double), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_double = &_grib_accessor_class_double; - -/* END_CLASS_IMP */ - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - double val = 0; - size_t l = 1; - char repres[1024]; - char format[32] = "%g"; - grib_handle* h = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - grib_unpack_double(a, &val, &l); - - if ((val == GRIB_MISSING_DOUBLE) && ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0)) { - snprintf(repres, sizeof(repres), "MISSING"); - } else { - size_t size = sizeof(format); - grib_get_string(h, "formatForDoubles", format, &size); - snprintf(repres, sizeof(repres), format, val); - } - - l = strlen(repres) + 1; - - if (l > *len) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_long: Casting double %s to string ", a->name); - - *len = l; - - strcpy(v, repres); - return GRIB_SUCCESS; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_values(dumper, a); -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - double* aval = 0; - double* bval = 0; - - size_t alen = 0; - size_t blen = 0; - long count = 0; - int err = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - - retval = GRIB_SUCCESS; - while (alen != 0) { - if (*bval != *aval) - retval = GRIB_DOUBLE_VALUE_MISMATCH; - alen--; - } - - grib_context_free(a->context, aval); - grib_context_free(b->context, bval); - - return retval; -} - -static int pack_missing(grib_accessor* a) -{ - size_t len = 1; - double value = GRIB_MISSING_DOUBLE; - - if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) - return grib_pack_double(a, &value, &len); - return GRIB_VALUE_CANNOT_BE_MISSING; -} diff --git a/src/grib_accessor_class_evaluate.cc b/src/grib_accessor_class_evaluate.cc deleted file mode 100644 index 596b95884..000000000 --- a/src/grib_accessor_class_evaluate.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS= grib_arguments* arg - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_evaluate -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in evaluate */ - grib_arguments* arg; -} grib_accessor_evaluate; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_evaluate = { - &grib_accessor_class_long, /* super */ - "evaluate", /* name */ - sizeof(grib_accessor_evaluate), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_evaluate = &_grib_accessor_class_evaluate; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_evaluate* self = (grib_accessor_evaluate*)a; - self->arg = c; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_evaluate* self = (grib_accessor_evaluate*)a; - grib_expression* e = grib_arguments_get_expression(grib_handle_of_accessor(a), self->arg, 0); - - int ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), e, val); - *len = 1; - - return ret; -} diff --git a/src/grib_accessor_class_g1_half_byte_codeflag.cc b/src/grib_accessor_class_g1_half_byte_codeflag.cc deleted file mode 100644 index c275253e5..000000000 --- a/src/grib_accessor_class_g1_half_byte_codeflag.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1_half_byte_codeflag -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in g1_half_byte_codeflag */ -} grib_accessor_g1_half_byte_codeflag; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_g1_half_byte_codeflag = { - &grib_accessor_class_gen, /* super */ - "g1_half_byte_codeflag", /* name */ - sizeof(grib_accessor_g1_half_byte_codeflag), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1_half_byte_codeflag = &_grib_accessor_class_g1_half_byte_codeflag; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - unsigned char dat = 0; - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - dat = grib_handle_of_accessor(a)->buffer->data[a->offset] & 0x0f; - - *val = dat; - *len = 1; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int ret = 0; - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - /* printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]);*/ - grib_handle_of_accessor(a)->buffer->data[a->offset] = (a->parent->h->buffer->data[a->offset] & 0xf0) | (*val & 0x0f); - /* printf("HALF BYTE pack long %ld %02x\n",*val,grib_handle_of_accessor(a)->buffer->data[a->offset]);*/ - - *len = 1; - return ret; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_g1_section4_length.cc b/src/grib_accessor_class_g1_section4_length.cc deleted file mode 100644 index 8e6c2b3f1..000000000 --- a/src/grib_accessor_class_g1_section4_length.cc +++ /dev/null @@ -1,143 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_section_length - IMPLEMENTS = init;unpack_long;pack_long - MEMBERS = const char* total_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1_section4_length -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in section_length */ - /* Members defined in g1_section4_length */ - const char* total_length; -} grib_accessor_g1_section4_length; - -extern grib_accessor_class* grib_accessor_class_section_length; - -static grib_accessor_class _grib_accessor_class_g1_section4_length = { - &grib_accessor_class_section_length, /* super */ - "g1_section4_length", /* name */ - sizeof(grib_accessor_g1_section4_length), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1_section4_length = &_grib_accessor_class_g1_section4_length; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_g1_section4_length* self = (grib_accessor_g1_section4_length*)a; - self->total_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - // Old implementation: - // Here we assume that the totalLength will be coded AFTER the section4 length, and - // the section4 length will be overwritten by the totalLength accessor for large GRIBs - // grib_accessor_class* super = *(a->cclass->super); - // return super->pack_long(a,val,len); - - // Note: Do not directly call pack_long on base class - // because in this special case we want to skip the checks. - // So we call the helper function which has an extra argument - return pack_long_unsigned_helper(a, val, len, /*check=*/0); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1_section4_length* self = (grib_accessor_g1_section4_length*)a; - int ret = 0; - long total_length = 0, sec4_length = 0; - - if ((ret = grib_get_g1_message_size(grib_handle_of_accessor(a), - grib_find_accessor(grib_handle_of_accessor(a), self->total_length), - a, - &total_length, - &sec4_length)) != GRIB_SUCCESS) { - return ret; - } - - *val = sec4_length; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_g1bitmap.cc b/src/grib_accessor_class_g1bitmap.cc deleted file mode 100644 index 519638f6a..000000000 --- a/src/grib_accessor_class_g1bitmap.cc +++ /dev/null @@ -1,206 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bitmap - IMPLEMENTS = pack_double; unpack_bytes - IMPLEMENTS = value_count - IMPLEMENTS = init; - MEMBERS=const char* unusedBits - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in bitmap */ - const char* tableReference; - const char* missing_value; - const char* offsetbsec; - const char* sLength; - /* Members defined in g1bitmap */ - const char* unusedBits; -} grib_accessor_g1bitmap; - -extern grib_accessor_class* grib_accessor_class_bitmap; - -static grib_accessor_class _grib_accessor_class_g1bitmap = { - &grib_accessor_class_bitmap, /* super */ - "g1bitmap", /* name */ - sizeof(grib_accessor_g1bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1bitmap = &_grib_accessor_class_g1bitmap; - -/* END_CLASS_IMP */ - - -static void grib_set_bit_on(unsigned char* p, long* bitp); - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_g1bitmap* self = (grib_accessor_g1bitmap*)a; - self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g1bitmap* self = (grib_accessor_g1bitmap*)a; - size_t tlen; - - unsigned char* buf = NULL; - size_t i; - int err = 0; - long pos = 0; - //long bmaplen = 0; - const int bit_padding = 16; - double miss_values = 0; - tlen = ((*len + bit_padding - 1) / bit_padding * bit_padding) / 8; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &miss_values)) != GRIB_SUCCESS) - return err; - - buf = (unsigned char*)grib_context_malloc_clear(a->context, tlen); - if (!buf) - return GRIB_OUT_OF_MEMORY; - pos = 0; - for (i = 0; i < *len; i++) { - if (val[i] == miss_values) - pos++; - else { - //bmaplen++; - grib_set_bit_on(buf, &pos); - } - } - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->unusedBits, tlen * 8 - *len)) != GRIB_SUCCESS) - return err; - - err = grib_buffer_replace(a, buf, tlen, 1, 1); - if (err) return err; - - grib_context_free(a->context, buf); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_g1bitmap* self = (grib_accessor_g1bitmap*)a; - long tlen; - int err; - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &tlen)) != GRIB_SUCCESS) - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_bitmap.value_count : cannot get %s err=%d", self->unusedBits, err); - - *count = (a->length * 8) - tlen; - return err; -} - -static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len) -{ - unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; - grib_accessor_g1bitmap* self = (grib_accessor_g1bitmap*)a; - long tlen; - int err; - long length = grib_byte_count(a); - long offset = grib_byte_offset(a); - - if (*len < (size_t)length) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it is %ld bytes long\n", a->name, length); - *len = length; - return GRIB_ARRAY_TOO_SMALL; - } - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &tlen)) != GRIB_SUCCESS) - grib_context_log(a->context, GRIB_LOG_ERROR, - "grib_accessor_class_bitmap.unpack_bytes : cannot get %s err=%d", self->unusedBits, err); - - length -= tlen / 8; - memcpy(val, buf + offset, length); - *len = length; - - return GRIB_SUCCESS; -} - -static void grib_set_bit_on(unsigned char* p, long* bitp) -{ - unsigned char o = 1; - p += (*bitp >> 3); - o <<= 7 - ((*bitp) % 8); - *p |= o; - (*bitp) += 1; -} diff --git a/src/grib_accessor_class_g1date.cc b/src/grib_accessor_class_g1date.cc deleted file mode 100644 index 37cd80ad5..000000000 --- a/src/grib_accessor_class_g1date.cc +++ /dev/null @@ -1,280 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long;unpack_string - IMPLEMENTS = init;dump;value_count - MEMBERS=const char* century - MEMBERS=const char* year - MEMBERS=const char* month - MEMBERS=const char* day - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1date */ - const char* century; - const char* year; - const char* month; - const char* day; -} grib_accessor_g1date; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1date = { - &grib_accessor_class_long, /* super */ - "g1date", /* name */ - sizeof(grib_accessor_g1date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1date = &_grib_accessor_class_g1date; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1date* self = (grib_accessor_g1date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->century = grib_arguments_get_name(hand, c, n++); - self->year = grib_arguments_get_name(hand, c, n++); - self->month = grib_arguments_get_name(hand, c, n++); - self->day = grib_arguments_get_name(hand, c, n++); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_g1date* self = (grib_accessor_g1date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - - long year = 0; - long century = 0; - long month = 0; - long day = 0; - - if ((ret = grib_get_long_internal(hand, self->century, ¢ury)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->day, &day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->month, &month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->year, &year)) != GRIB_SUCCESS) - return ret; - - if (*len < 1) - return GRIB_WRONG_ARRAY_SIZE; - - *val = ((century - 1) * 100 + year) * 10000 + month * 100 + day; - - if (year == 255 && day == 255 && month >= 1 && month <= 12) { - *val = month; - } - - if (year == 255 && day != 255 && month >= 1 && month <= 12) { - *val = month * 100 + day; - } - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int ret = 0; - long v = val[0]; - grib_accessor_g1date* self = (grib_accessor_g1date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - - long year = 0; - long century = 0; - long month = 0; - long day = 0; - - if (*len != 1) - return GRIB_WRONG_ARRAY_SIZE; - - { - long d = grib_julian_to_date((long)grib_date_to_julian(v)); - if (v != d) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g1date: pack_long invalid date %ld, changed to %ld", v, d); - return GRIB_ENCODING_ERROR; - } - } - - century = v / 1000000; - v %= 1000000; - year = v / 10000; - v %= 10000; - month = v / 100; - v %= 100; - day = v; - - if (year == 0) - year = 100; - else - century++; - - if ((ret = grib_set_long_internal(hand, self->century, century)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(hand, self->day, day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(hand, self->month, month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(hand, self->year, year)) != GRIB_SUCCESS) - return ret; - - return GRIB_SUCCESS; -} - -static const char* months[] = { - "jan", - "feb", - "mar", - "apr", - "may", - "jun", - "jul", - "aug", - "sep", - "oct", - "nov", - "dec", -}; - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - int ret = 0; - char tmp[1024]; - grib_accessor_g1date* self = (grib_accessor_g1date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - long year = 0; - long century = 0; - long month = 0; - long day = 0; - size_t l; - - if ((ret = grib_get_long_internal(hand, self->century, ¢ury)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->day, &day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->month, &month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->year, &year)) != GRIB_SUCCESS) - return ret; - - if (*len < 1) - return GRIB_WRONG_ARRAY_SIZE; - - if (year == 255 && day == 255 && month >= 1 && month <= 12) { - strcpy(tmp, months[month - 1]); - } - else if (year == 255 && month >= 1 && month <= 12) { - snprintf(tmp, sizeof(tmp), "%s-%02ld", months[month - 1], day); - } - else { - long x = ((century - 1) * 100 + year) * 10000 + month * 100 + day; - snprintf(tmp, sizeof(tmp), "%ld", x); - } - - l = strlen(tmp) + 1; - if (*len < l) { - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - *len = l; - strcpy(val, tmp); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} diff --git a/src/grib_accessor_class_g1day_of_the_year_date.cc b/src/grib_accessor_class_g1day_of_the_year_date.cc deleted file mode 100644 index 9028d5076..000000000 --- a/src/grib_accessor_class_g1day_of_the_year_date.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_g1date - IMPLEMENTS = unpack_string - IMPLEMENTS = dump - IMPLEMENTS = init - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1day_of_the_year_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1date */ - const char* century; - const char* year; - const char* month; - const char* day; - /* Members defined in g1day_of_the_year_date */ -} grib_accessor_g1day_of_the_year_date; - -extern grib_accessor_class* grib_accessor_class_g1date; - -static grib_accessor_class _grib_accessor_class_g1day_of_the_year_date = { - &grib_accessor_class_g1date, /* super */ - "g1day_of_the_year_date", /* name */ - sizeof(grib_accessor_g1day_of_the_year_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1day_of_the_year_date = &_grib_accessor_class_g1day_of_the_year_date; - -/* END_CLASS_IMP */ - - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - /* special clim case where each mont have 30 days.. to comply with mars*/ - grib_accessor_g1day_of_the_year_date* self = (grib_accessor_g1day_of_the_year_date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - char tmp[1024]; - - long year = 0; - long century = 0; - long month = 0; - long day = 0; - long fullyear = 0; - long fake_day_of_year = 0; - - grib_get_long_internal(hand, self->century, ¢ury); - grib_get_long_internal(hand, self->day, &day); - grib_get_long_internal(hand, self->month, &month); - grib_get_long_internal(hand, self->year, &year); - - fullyear = ((century - 1) * 100 + year); - fake_day_of_year = ((month - 1) * 30) + day; - snprintf(tmp, sizeof(tmp), "%04ld-%03ld", fullyear, fake_day_of_year); - - size_t l = strlen(tmp) + 1; - if (*len < l) { - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - *len = l; - strcpy(val, tmp); - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_g1end_of_interval_monthly.cc b/src/grib_accessor_class_g1end_of_interval_monthly.cc deleted file mode 100644 index cbf74322c..000000000 --- a/src/grib_accessor_class_g1end_of_interval_monthly.cc +++ /dev/null @@ -1,234 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_vector - IMPLEMENTS = unpack_double; destroy - IMPLEMENTS = value_count;compare - IMPLEMENTS = init - MEMBERS = const char* verifyingMonth - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_g1end_of_interval_monthly -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; - /* Members defined in g1end_of_interval_monthly */ - const char* verifyingMonth; -} grib_accessor_g1end_of_interval_monthly; - -extern grib_accessor_class* grib_accessor_class_abstract_vector; - -static grib_accessor_class _grib_accessor_class_g1end_of_interval_monthly = { - &grib_accessor_class_abstract_vector, /* super */ - "g1end_of_interval_monthly", /* name */ - sizeof(grib_accessor_g1end_of_interval_monthly), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1end_of_interval_monthly = &_grib_accessor_class_g1end_of_interval_monthly; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a; - int n = 0; - - self->verifyingMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - - self->number_of_elements = 6; - self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements); - - a->length = 0; - a->dirty = 1; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a; - int ret = 0; - char verifyingMonth[7] = {0,}; - size_t slen = 7; - long year = 0, month = 0, date = 0; - const long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - long days = 0; - - if (!a->dirty) - return GRIB_SUCCESS; - - if (*len != (size_t)self->number_of_elements) - return GRIB_ARRAY_TOO_SMALL; - - if ((ret = grib_get_string(grib_handle_of_accessor(a), self->verifyingMonth, verifyingMonth, &slen)) != GRIB_SUCCESS) - return ret; - - date = atoi(verifyingMonth); - if (date < 0) { - return GRIB_INVALID_ARGUMENT; - } - year = date / 100; - month = date - year * 100; - if (month == 2) { - days = 28; - if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) - days = 29; - } - else { - if (month < 1 || month > 12) return GRIB_INVALID_ARGUMENT; - days = mdays[month - 1]; - } - self->v[0] = year; - self->v[1] = month; - - self->v[2] = days; - self->v[3] = 24; - self->v[4] = 00; - self->v[5] = 00; - - a->dirty = 0; - - val[0] = self->v[0]; - val[1] = self->v[1]; - val[2] = self->v[2]; - val[3] = self->v[3]; - val[4] = self->v[4]; - val[5] = self->v[5]; - - return ret; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a; - *count = self->number_of_elements; - return 0; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_g1end_of_interval_monthly* self = (grib_accessor_g1end_of_interval_monthly*)a; - grib_context_free(c, self->v); -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = GRIB_SUCCESS; - double* aval = 0; - double* bval = 0; - - long count = 0; - size_t alen = 0; - size_t blen = 0; - int err = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - b->dirty = 1; - a->dirty = 1; - - err = grib_unpack_double(a, aval, &alen); if(err) return err; - err = grib_unpack_double(b, bval, &blen); if(err) return err; - - for(size_t i=0; icontext, aval); - grib_context_free(b->context, bval); - - return retval; -} diff --git a/src/grib_accessor_class_g1fcperiod.cc b/src/grib_accessor_class_g1fcperiod.cc deleted file mode 100644 index 03aa6e3f4..000000000 --- a/src/grib_accessor_class_g1fcperiod.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_g1step_range - IMPLEMENTS = unpack_string - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); - -typedef struct grib_accessor_g1fcperiod -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; - /* Members defined in g1step_range */ - const char* p1; - const char* p2; - const char* timeRangeIndicator; - const char *unit; - const char *step_unit; - const char *stepType; - const char *patch_fp_precip; - int error_on_units; - /* Members defined in g1fcperiod */ -} grib_accessor_g1fcperiod; - -extern grib_accessor_class* grib_accessor_class_g1step_range; - -static grib_accessor_class _grib_accessor_class_g1fcperiod = { - &grib_accessor_class_g1step_range, /* super */ - "g1fcperiod", /* name */ - sizeof(grib_accessor_g1fcperiod), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1fcperiod = &_grib_accessor_class_g1fcperiod; - -/* END_CLASS_IMP */ - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long start = 0, theEnd = 0; - char tmp[1024]; - const size_t tmpLen = sizeof(tmp); - int err = grib_g1_step_get_steps(a, &start, &theEnd); - size_t l = 0; - - if (err) - return err; - - snprintf(tmp, tmpLen, "%ld-%ld", start / 24, theEnd / 24); - /*printf("---- FCPERIOD %s [start:%g, end:%g]",tmp,start,end);*/ - - l = strlen(tmp) + 1; - if (*len < l) { - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - *len = l; - strcpy(val, tmp); /* NOLINT: CWE-119 clang-analyzer-security.insecureAPI.strcpy */ - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_g1monthlydate.cc b/src/grib_accessor_class_g1monthlydate.cc deleted file mode 100644 index 503d0daa4..000000000 --- a/src/grib_accessor_class_g1monthlydate.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - - -/*********************************************** - * Enrico Fucile - **********************************************/ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init;dump - MEMBERS=const char* date - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1monthlydate -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1monthlydate */ - const char* date; -} grib_accessor_g1monthlydate; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1monthlydate = { - &grib_accessor_class_long, /* super */ - "g1monthlydate", /* name */ - sizeof(grib_accessor_g1monthlydate), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1monthlydate = &_grib_accessor_class_g1monthlydate; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1monthlydate* self = (grib_accessor_g1monthlydate*)a; - int n = 0; - - self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1monthlydate* self = (grib_accessor_g1monthlydate*)a; - - long date = 0; - - grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date); - - date /= 100; - date *= 100; - date += 1; - - *val = date; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_g1number_of_coded_values_sh_complex.cc b/src/grib_accessor_class_g1number_of_coded_values_sh_complex.cc deleted file mode 100644 index 45b983502..000000000 --- a/src/grib_accessor_class_g1number_of_coded_values_sh_complex.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/****************************************************** - * Enrico Fucile - *******************************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* numberOfValues - MEMBERS = const char* bitsPerValue - MEMBERS = const char* offsetBeforeData - MEMBERS = const char* offsetAfterData - MEMBERS = const char* unusedBits - MEMBERS = const char* JS - MEMBERS = const char* KS - MEMBERS = const char* MS - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1number_of_coded_values_sh_complex -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1number_of_coded_values_sh_complex */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; - const char* JS; - const char* KS; - const char* MS; -} grib_accessor_g1number_of_coded_values_sh_complex; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1number_of_coded_values_sh_complex = { - &grib_accessor_class_long, /* super */ - "g1number_of_coded_values_sh_complex", /* name */ - sizeof(grib_accessor_g1number_of_coded_values_sh_complex), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_complex = &_grib_accessor_class_g1number_of_coded_values_sh_complex; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_g1number_of_coded_values_sh_complex* self = (grib_accessor_g1number_of_coded_values_sh_complex*)a; - self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->JS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->KS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->MS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = GRIB_SUCCESS; - long bpv = 0; - long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; - long JS = 0, KS = 0, MS = 0, NS = 0; - - grib_accessor_g1number_of_coded_values_sh_complex* self = (grib_accessor_g1number_of_coded_values_sh_complex*)a; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->JS, &JS)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->KS, &KS)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->MS, &MS)) != GRIB_SUCCESS) - return ret; - - if (JS != KS || KS != MS) - return GRIB_NOT_IMPLEMENTED; - - NS = (MS + 1) * (MS + 2); - - if (bpv != 0) { - DEBUG_ASSERT(offsetAfterData > offsetBeforeData); - *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits + NS * (bpv - 32)) / bpv; - } - else { - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) - return ret; - - *val = numberOfValues; - } - - return ret; -} diff --git a/src/grib_accessor_class_g1number_of_coded_values_sh_simple.cc b/src/grib_accessor_class_g1number_of_coded_values_sh_simple.cc deleted file mode 100644 index 532a4c5dd..000000000 --- a/src/grib_accessor_class_g1number_of_coded_values_sh_simple.cc +++ /dev/null @@ -1,158 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/********************************************** - * Enrico Fucile - **********************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* numberOfValues - MEMBERS = const char* bitsPerValue - MEMBERS = const char* offsetBeforeData - MEMBERS = const char* offsetAfterData - MEMBERS = const char* unusedBits - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1number_of_coded_values_sh_simple -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1number_of_coded_values_sh_simple */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; -} grib_accessor_g1number_of_coded_values_sh_simple; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1number_of_coded_values_sh_simple = { - &grib_accessor_class_long, /* super */ - "g1number_of_coded_values_sh_simple", /* name */ - sizeof(grib_accessor_g1number_of_coded_values_sh_simple), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1number_of_coded_values_sh_simple = &_grib_accessor_class_g1number_of_coded_values_sh_simple; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_g1number_of_coded_values_sh_simple* self = (grib_accessor_g1number_of_coded_values_sh_simple*)a; - self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = GRIB_SUCCESS; - long bpv = 0; - long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; - - grib_accessor_g1number_of_coded_values_sh_simple* self = (grib_accessor_g1number_of_coded_values_sh_simple*)a; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) - return ret; - - if (bpv != 0) { - DEBUG_ASSERT(offsetAfterData > offsetBeforeData); - *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv; - } - else { - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) - return ret; - - *val = numberOfValues; - } - return ret; -} diff --git a/src/grib_accessor_class_g1verificationdate.cc b/src/grib_accessor_class_g1verificationdate.cc deleted file mode 100644 index a3272acc2..000000000 --- a/src/grib_accessor_class_g1verificationdate.cc +++ /dev/null @@ -1,160 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init;dump - MEMBERS=const char* date - MEMBERS=const char* time - MEMBERS=const char* step - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g1verificationdate -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g1verificationdate */ - const char* date; - const char* time; - const char* step; -} grib_accessor_g1verificationdate; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g1verificationdate = { - &grib_accessor_class_long, /* super */ - "g1verificationdate", /* name */ - sizeof(grib_accessor_g1verificationdate), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g1verificationdate = &_grib_accessor_class_g1verificationdate; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a; - int n = 0; - - self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->time = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a; - int ret = 0; - long date = 0; - long time = 0; - long cdate = 0; - long step = 0; - long vtime = 0; - long vdate = 0; - long vd = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->time, &time)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->step, &step)) != GRIB_SUCCESS) - return ret; - - time /= 100; - - cdate = (long)grib_date_to_julian(date); - vtime = cdate * 24 + time + step; - vd = vtime / 24; - vdate = grib_julian_to_date(vd); - - /* printf("\n********\n date %d, time %d, step %d, vdate: %d, cdate %d, vd %d\n********\n", date, time, step, vdate, cdate, vd); */ - - if (*len < 1) - return GRIB_ARRAY_TOO_SMALL; - - *val = vdate; - - /* fprintf(stdout,"\n********\n %d cdate %d vd %d\n********\n", vdate, cdate, step); */ - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_g2_aerosol.cc b/src/grib_accessor_class_g2_aerosol.cc deleted file mode 100644 index 7cd8659df..000000000 --- a/src/grib_accessor_class_g2_aerosol.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = unpack_long;pack_long; value_count - IMPLEMENTS = init - MEMBERS=const char* productDefinitionTemplateNumber - MEMBERS=const char* stepType - MEMBERS=int optical - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2_aerosol -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in g2_aerosol */ - const char* productDefinitionTemplateNumber; - const char* stepType; - int optical; -} grib_accessor_g2_aerosol; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_g2_aerosol = { - &grib_accessor_class_unsigned, /* super */ - "g2_aerosol", /* name */ - sizeof(grib_accessor_g2_aerosol), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2_aerosol = &_grib_accessor_class_g2_aerosol; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2_aerosol* self = (grib_accessor_g2_aerosol*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->productDefinitionTemplateNumber = grib_arguments_get_name(hand, c, n++); - self->stepType = grib_arguments_get_name(hand, c, n++); - self->optical = grib_arguments_get_long(hand, c, n++); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2_aerosol* self = (grib_accessor_g2_aerosol*)a; - long productDefinitionTemplateNumber = 0; - grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber); - - if (self->optical) - *val = grib2_is_PDTN_AerosolOptical(productDefinitionTemplateNumber); - else - *val = grib2_is_PDTN_Aerosol(productDefinitionTemplateNumber); - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2_aerosol* self = (grib_accessor_g2_aerosol*)a; - grib_handle* hand = grib_handle_of_accessor(a); - long productDefinitionTemplateNumber = -1; - long productDefinitionTemplateNumberNew = -1; - /*long type=-1; - long stream=-1;*/ - long eps = -1; - char stepType[15] = {0,}; - size_t slen = 15; - /*int aerosol = *val;*/ - int isInstant = 0; - /*long derivedForecast=-1;*/ - int ret = 0; - - if (grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber) != GRIB_SUCCESS) - return GRIB_SUCCESS; - - /* - grib_get_long(hand, self->type,&type); - grib_get_long(hand, self->stream,&stream); - */ - ret = grib_get_string(hand, self->stepType, stepType, &slen); - Assert(ret == GRIB_SUCCESS); - - //eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber); - eps = grib_is_defined(hand, "perturbationNumber"); - - if (!strcmp(stepType, "instant")) - isInstant = 1; - - if (eps == 1) { - if (isInstant) { - productDefinitionTemplateNumberNew = 45; - } - else { - /*productDefinitionTemplateNumberNew = 47; PDT deprecated*/ - productDefinitionTemplateNumberNew = 85; - } - } - else { - if (isInstant) { - productDefinitionTemplateNumberNew = 48; /*44 is deprecated*/ - } - else { - productDefinitionTemplateNumberNew = 46; - } - } - - if (self->optical) { - /* Note: There is no interval based template for optical properties of aerosol! */ - if (eps) - productDefinitionTemplateNumberNew = 49; - else - productDefinitionTemplateNumberNew = 48; - if (!isInstant) { - grib_context_log(hand->context, GRIB_LOG_ERROR, - "The product definition templates for optical properties of aerosol are for a point-in-time only"); - } - } - - if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) { - grib_set_long(hand, self->productDefinitionTemplateNumber, productDefinitionTemplateNumberNew); - /*if (derivedForecast>=0) grib_set_long(hand, self->derivedForecast,derivedForecast);*/ - } - - return 0; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} diff --git a/src/grib_accessor_class_g2bitmap.cc b/src/grib_accessor_class_g2bitmap.cc deleted file mode 100644 index 441ad70a6..000000000 --- a/src/grib_accessor_class_g2bitmap.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bitmap - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = init; - MEMBERS=const char* numberOfValues - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in bitmap */ - const char* tableReference; - const char* missing_value; - const char* offsetbsec; - const char* sLength; - /* Members defined in g2bitmap */ - const char* numberOfValues; -} grib_accessor_g2bitmap; - -extern grib_accessor_class* grib_accessor_class_bitmap; - -static grib_accessor_class _grib_accessor_class_g2bitmap = { - &grib_accessor_class_bitmap, /* super */ - "g2bitmap", /* name */ - sizeof(grib_accessor_g2bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2bitmap = &_grib_accessor_class_g2bitmap; - -/* END_CLASS_IMP */ - - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_g2bitmap* self = (grib_accessor_g2bitmap*)a; - - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 4); -} - - -static void grib_set_bit_on(unsigned char* p, long* bitp) -{ - unsigned char o = 1; - p += (*bitp >> 3); - o <<= 7 - ((*bitp) % 8); - *p |= o; - (*bitp) += 1; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g2bitmap* self = (grib_accessor_g2bitmap*)a; - - size_t tlen; - - unsigned char* buf = NULL; - size_t i; - int err = 0; - long pos = 0; - // long bmaplen = 0; - double miss_values = 0; - tlen = (*len + 7) / 8; - - if ((err = grib_get_double_internal(grib_handle_of_accessor(a), self->missing_value, &miss_values)) != GRIB_SUCCESS) - return err; - - buf = (unsigned char*)grib_context_malloc_clear(a->context, tlen); - if (!buf) - return GRIB_OUT_OF_MEMORY; - pos = 0; - for (i = 0; i < *len; i++) { - if (val[i] == miss_values) - pos++; - else { - // bmaplen++; - grib_set_bit_on(buf, &pos); - } - } - - if ((err = grib_set_long_internal(grib_handle_of_accessor(a), self->numberOfValues, *len)) != GRIB_SUCCESS) { - grib_context_free(a->context, buf); - return err; - } - - grib_buffer_replace(a, buf, tlen, 1, 1); - - grib_context_free(a->context, buf); - - return GRIB_SUCCESS; -} - - -static int value_count(grib_accessor* a, long* tlen) -{ - grib_accessor_g2bitmap* self = (grib_accessor_g2bitmap*)a; - int err; - *tlen = 0; - - err = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, tlen); - return err; -} diff --git a/src/grib_accessor_class_g2bitmap_present.cc b/src/grib_accessor_class_g2bitmap_present.cc deleted file mode 100644 index 52378d4eb..000000000 --- a/src/grib_accessor_class_g2bitmap_present.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/**************************************** - * Enrico Fucile - *************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS = const char* bitmapIndicator - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2bitmap_present -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g2bitmap_present */ - const char* bitmapIndicator; -} grib_accessor_g2bitmap_present; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g2bitmap_present = { - &grib_accessor_class_long, /* super */ - "g2bitmap_present", /* name */ - sizeof(grib_accessor_g2bitmap_present), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2bitmap_present = &_grib_accessor_class_g2bitmap_present; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_g2bitmap_present* self = (grib_accessor_g2bitmap_present*)a; - self->bitmapIndicator = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = GRIB_SUCCESS; - long bitmapIndicator = 0; - - grib_accessor_g2bitmap_present* self = (grib_accessor_g2bitmap_present*)a; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitmapIndicator, &bitmapIndicator); - if (ret) { - if (ret == GRIB_NOT_FOUND) { - *val = 0; - return 0; - } - else - return ret; - } - - *val = 1; - if (bitmapIndicator == 255) - *val = 0; - - *len = 1; - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_g2bitmap_present* self = (grib_accessor_g2bitmap_present*)a; - long bitmapIndicator = 0; - - if (*val == 0) - bitmapIndicator = 255; - - return grib_set_long(grib_handle_of_accessor(a), self->bitmapIndicator, bitmapIndicator); -} diff --git a/src/grib_accessor_class_g2date.cc b/src/grib_accessor_class_g2date.cc deleted file mode 100644 index 4ed01d99e..000000000 --- a/src/grib_accessor_class_g2date.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long;init;dump - MEMBERS=const char* century - MEMBERS=const char* year - MEMBERS=const char* month - MEMBERS=const char* day - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in g2date */ - const char* century; - const char* year; - const char* month; - const char* day; -} grib_accessor_g2date; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_g2date = { - &grib_accessor_class_long, /* super */ - "g2date", /* name */ - sizeof(grib_accessor_g2date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2date = &_grib_accessor_class_g2date; - -/* END_CLASS_IMP */ -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2date* self = (grib_accessor_g2date*)a; - int n = 0; - - self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_g2date* self = (grib_accessor_g2date*)a; - - long year = 0; - long month = 0; - long day = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->day, &day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->month, &month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->year, &year)) != GRIB_SUCCESS) - return ret; - - if (*len < 1) - return GRIB_WRONG_ARRAY_SIZE; - - val[0] = year * 10000 + month * 100 + day; - - return GRIB_SUCCESS; -} - -/* TODO: Check for a valid date */ -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int ret; - long v = val[0]; - grib_accessor_g2date* self = (grib_accessor_g2date*)a; - - long year = 0; - long month = 0; - long day = 0; - - if (*len != 1) - return GRIB_WRONG_ARRAY_SIZE; - - year = v / 10000; - v %= 10000; - month = v / 100; - v %= 100; - day = v; - - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->day, day)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->month, month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->year, year)) != GRIB_SUCCESS) - return ret; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_g2latlon.cc b/src/grib_accessor_class_g2latlon.cc deleted file mode 100644 index 5549b79a3..000000000 --- a/src/grib_accessor_class_g2latlon.cc +++ /dev/null @@ -1,215 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/******************************************** - * Enrico Fucile - *********************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = is_missing;pack_missing - IMPLEMENTS = init - MEMBERS=const char* grid - MEMBERS=int index - MEMBERS=const char* given - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_missing(grib_accessor*); -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2latlon -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in g2latlon */ - const char* grid; - int index; - const char* given; -} grib_accessor_g2latlon; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_g2latlon = { - &grib_accessor_class_double, /* super */ - "g2latlon", /* name */ - sizeof(grib_accessor_g2latlon), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - &is_missing, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2latlon = &_grib_accessor_class_g2latlon; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - int n = 0; - - self->grid = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - self->given = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - int ret = 0; - - long given = 1; - double grid[6]; - size_t size = 6; - - if (*len < 1) { - ret = GRIB_ARRAY_TOO_SMALL; - return ret; - } - - if (self->given) - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given)) != GRIB_SUCCESS) - return ret; - - if (!given) { - *val = GRIB_MISSING_DOUBLE; - return GRIB_SUCCESS; - } - - if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->grid, grid, &size)) != GRIB_SUCCESS) - return ret; - - *val = grid[self->index]; - - return GRIB_SUCCESS; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - int ret = 0; - double grid[6]; - size_t size = 6; - double new_val = *val; - grib_handle* hand = grib_handle_of_accessor(a); - - if (*len < 1) { - ret = GRIB_ARRAY_TOO_SMALL; - return ret; - } - - if (self->given) { - long given = *val != GRIB_MISSING_DOUBLE; - if ((ret = grib_set_long_internal(hand, self->given, given)) != GRIB_SUCCESS) - return ret; - } - - if ((ret = grib_get_double_array_internal(hand, self->grid, grid, &size)) != GRIB_SUCCESS) - return ret; - - /* index 1 is longitudeOfFirstGridPointInDegrees - * index 3 is longitudeOfLastGridPointInDegrees - */ - if ((self->index == 1 || self->index == 3)) { - /* WMO regulation for GRIB edition 2: - * The longitude values shall be limited to the range 0 to 360 degrees inclusive */ - new_val = normalise_longitude_in_degrees(*val); - if (hand->context->debug && new_val != *val) { - fprintf(stderr, "ECCODES DEBUG pack_double g2latlon: normalise longitude %g -> %g\n", *val, new_val); - } - } - grid[self->index] = new_val; - - return grib_set_double_array_internal(hand, self->grid, grid, size); -} - -static int pack_missing(grib_accessor* a) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - double missing = GRIB_MISSING_DOUBLE; - size_t size = 1; - - if (!self->given) - return GRIB_NOT_IMPLEMENTED; - - return pack_double(a, &missing, &size); -} - -static int is_missing(grib_accessor* a) -{ - grib_accessor_g2latlon* self = (grib_accessor_g2latlon*)a; - long given = 1; - - if (self->given) - grib_get_long_internal(grib_handle_of_accessor(a), self->given, &given); - - return !given; -} diff --git a/src/grib_accessor_class_g2lon.cc b/src/grib_accessor_class_g2lon.cc deleted file mode 100644 index c84776915..000000000 --- a/src/grib_accessor_class_g2lon.cc +++ /dev/null @@ -1,149 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/******************************************** - * Enrico Fucile - *********************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = init - MEMBERS=const char* longitude - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2lon -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in g2lon */ - const char* longitude; -} grib_accessor_g2lon; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_g2lon = { - &grib_accessor_class_double, /* super */ - "g2lon", /* name */ - sizeof(grib_accessor_g2lon), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2lon = &_grib_accessor_class_g2lon; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2lon* self = (grib_accessor_g2lon*)a; - int n = 0; - - self->longitude = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2lon* self = (grib_accessor_g2lon*)a; - int ret = 0; - long longitude; - - if ((ret = grib_get_long(grib_handle_of_accessor(a), self->longitude, &longitude)) != GRIB_SUCCESS) - return ret; - - if (longitude == GRIB_MISSING_LONG) { - *val = GRIB_MISSING_DOUBLE; - return GRIB_SUCCESS; - } - - *val = ((double)longitude) / 1000000.0; - - return GRIB_SUCCESS; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_g2lon* self = (grib_accessor_g2lon*)a; - long longitude; - double value = *val; - - if (value == GRIB_MISSING_DOUBLE) { - longitude = GRIB_MISSING_LONG; - } - else { - if (value < 0) - value += 360; - longitude = (long)(value * 1000000); - } - return grib_set_long(grib_handle_of_accessor(a), self->longitude, longitude); -} diff --git a/src/grib_accessor_class_g2step_range.cc b/src/grib_accessor_class_g2step_range.cc deleted file mode 100644 index 685c8a29b..000000000 --- a/src/grib_accessor_class_g2step_range.cc +++ /dev/null @@ -1,370 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include "step.h" -#include "step_utilities.h" -#include -#include -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_string;unpack_string;value_count - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = get_native_type;string_length - IMPLEMENTS = init - MEMBERS = const char* start_step - MEMBERS = const char* end_step - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_g2step_range -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in g2step_range */ - const char* start_step; - const char* end_step; -} grib_accessor_g2step_range; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_g2step_range = { - &grib_accessor_class_gen, /* super */ - "g2step_range", /* name */ - sizeof(grib_accessor_g2step_range), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_g2step_range = &_grib_accessor_class_g2step_range; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - - int n = 0; - - self->start_step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->end_step = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->length = 0; -} - -//static void dump(grib_accessor* a, grib_dumper* dumper) -//{ - //grib_dump_string(dumper, a, NULL); -//} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - size_t size = 0; - double start_step_value = 0; - double end_step_value = 0; - long step_units; - - int show_hours = a->context->grib_hourly_steps_with_units; - - if ((ret = grib_get_double_internal(h, self->start_step, &start_step_value)) != GRIB_SUCCESS) - return ret; - if ((ret= grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - return ret; - try { - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - return ret; - } - - char fp_format[128] = "%g"; - size_t fp_format_len = sizeof(fp_format); - if ((ret = grib_get_string_internal(h, "formatForDoubles", fp_format, &fp_format_len)) != GRIB_SUCCESS) - return ret; - std::stringstream ss; - - eccodes::Step start_step{start_step_value, step_units}; - if (self->end_step == NULL) { - ss << start_step.value(fp_format, show_hours); - } - else { - if ((ret = grib_get_double_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) - return ret; - - eccodes::Step end_step{end_step_value, step_units}; - - if (start_step_value == end_step_value) { - ss << end_step.value(fp_format, show_hours); - } - else { - ss << start_step.value(fp_format, show_hours) << "-" << end_step.value(fp_format, show_hours); - } - } - - size = ss.str().size() + 1; - - if (*len < size) - return GRIB_ARRAY_TOO_SMALL; - - *len = size; - - memcpy(val, ss.str().c_str(), size); - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_g2step_range::unpack_string: %s", e.what()); - return GRIB_DECODING_ERROR; - } - - return GRIB_SUCCESS; -} - - -// Step range format: [-] -// and can be in different units -// stepRange="X" in instantaneous field is equivalent to set step=X -// stepRange="X" in accumulated field is equivalent to startStep=X, endStep=startStep -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - - long force_step_units; - if ((ret = grib_get_long_internal(h, "forceStepUnits", &force_step_units)) != GRIB_SUCCESS) - return ret; - - // TODO(maee): A better solution should be found - if (h->loader) { // h->loader is set only when rebuilding or reparsing - force_step_units = 255; // See ECC-1768 - } - - try { - std::vector steps = parse_range(val, eccodes::Unit{force_step_units}); - if (steps.size() == 0) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Could not parse step range: %s", val); - return GRIB_INVALID_ARGUMENT; - } - - eccodes::Step step_0; - eccodes::Step step_1; - if (eccodes::Unit{force_step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { - if (steps.size() > 1) - std::tie(step_0, step_1) = find_common_units(steps[0].optimize_unit(), steps[1].optimize_unit()); - else - step_0 = steps[0].optimize_unit(); - } - else { - step_0 = eccodes::Step{steps[0].value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; - if (steps.size() > 1) { - step_1 = eccodes::Step{steps[1].value(eccodes::Unit{force_step_units}), eccodes::Unit{force_step_units}}; - } - } - - if ((ret = grib_set_long_internal(h, "startStepUnit", step_0.unit().value()))) - return ret; - if ((ret = set_step(h, "forecastTime" , "indicatorOfUnitOfTimeRange", step_0)) != GRIB_SUCCESS) - return ret; - - if (self->end_step != NULL) { - if (steps.size() > 1) { - if ((ret = grib_set_long_internal(h, "endStepUnit", step_1.unit().value()))) - return ret; - if ((ret = grib_set_long_internal(h, self->end_step, step_1.value()))) - return ret; - } else { - if ((ret = grib_set_long_internal(h, "endStepUnit", step_0.unit().value()))) - return ret; - if ((ret = grib_set_long_internal(h, self->end_step, step_0.value()))) - return ret; - } - } - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grib_accessor_class_g2step_range::pack_string: %s", e.what()); - return GRIB_INVALID_ARGUMENT; - } - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 255; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - char buff[100]; - size_t bufflen = 100; - - snprintf(buff, sizeof(buff), "%ld", *val); - return pack_string(a, buff, &bufflen); -} - - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - long end_start_value = 0; - long end_step_value = 0; - long step_units = 0; - - if ((ret = grib_get_long_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS) - return ret; - try { - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - throw std::runtime_error("Failed to get stepUnits"); - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - return ret; - } - - eccodes::Step start_step{end_start_value, step_units}; - if (self->end_step == NULL) { - *val = start_step.value(); - } - else { - if ((ret = grib_get_long_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) - return ret; - eccodes::Step end_step{end_step_value, step_units}; - *val = end_step.value(); - } - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Failed to unpack step range: %s", e.what()); - return GRIB_DECODING_ERROR; - } - - return GRIB_SUCCESS; -} - - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_g2step_range* self = (grib_accessor_g2step_range*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - double end_start_value = 0; - double end_step_value = 0; - long step_units = 0; - - if ((ret = grib_get_double_internal(h, self->start_step, &end_start_value)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - throw std::runtime_error("Failed to get stepUnits"); - - try { - if (eccodes::Unit{step_units} == eccodes::Unit{eccodes::Unit::Value::MISSING}) { - if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS) - return ret; - } - - eccodes::Step start_step{end_start_value, step_units}; - if (self->end_step == NULL) { - *val = start_step.value(); - } - else { - if ((ret = grib_get_double_internal(h, self->end_step, &end_step_value)) != GRIB_SUCCESS) - return ret; - eccodes::Step end_step{end_step_value, step_units}; - *val = end_step.value(); - } - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, "grid_accessor_g2step_range::unpack_double: %s", e.what()); - return GRIB_DECODING_ERROR; - } - - return GRIB_SUCCESS; -} - - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} diff --git a/src/grib_accessor_class_gaussian_grid_name.cc b/src/grib_accessor_class_gaussian_grid_name.cc deleted file mode 100644 index 21117d4f1..000000000 --- a/src/grib_accessor_class_gaussian_grid_name.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string; get_native_type;string_length - MEMBERS = const char* N - MEMBERS = const char* Ni - MEMBERS = const char* isOctahedral - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_gaussian_grid_name -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in gaussian_grid_name */ - const char* N; - const char* Ni; - const char* isOctahedral; -} grib_accessor_gaussian_grid_name; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_gaussian_grid_name = { - &grib_accessor_class_gen, /* super */ - "gaussian_grid_name", /* name */ - sizeof(grib_accessor_gaussian_grid_name), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gaussian_grid_name = &_grib_accessor_class_gaussian_grid_name; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_gaussian_grid_name* self = (grib_accessor_gaussian_grid_name*)a; - int n = 0; - - self->N = grib_arguments_get_name(a->parent->h, arg, n++); - self->Ni = grib_arguments_get_name(a->parent->h, arg, n++); - self->isOctahedral = grib_arguments_get_name(a->parent->h, arg, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -#define MAX_GRIDNAME_LEN 16 - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - grib_accessor_gaussian_grid_name* self = (grib_accessor_gaussian_grid_name*)a; - - long N = 0, Ni = 0; - char tmp[MAX_GRIDNAME_LEN] = {0,}; - size_t length = 0; - int ret = GRIB_SUCCESS; - - if ((ret = grib_get_long_internal(a->parent->h, self->N, &N)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(a->parent->h, self->Ni, &Ni)) != GRIB_SUCCESS) - return ret; - - if (Ni == GRIB_MISSING_LONG) { - /* Reduced gaussian grid */ - long isOctahedral = 0; - if ((ret = grib_get_long_internal(a->parent->h, self->isOctahedral, &isOctahedral)) != GRIB_SUCCESS) - return ret; - if (isOctahedral == 1) { - snprintf(tmp, sizeof(tmp), "O%ld", N); - } - else { - snprintf(tmp, sizeof(tmp), "N%ld", N); /* Classic */ - } - } - else { - /* Regular gaussian grid */ - snprintf(tmp, sizeof(tmp), "F%ld", N); - } - length = strlen(tmp) + 1; - - if (*len < length) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, length, *len); - *len = length; - return GRIB_BUFFER_TOO_SMALL; - } - - strcpy(v, tmp); - *len = length; - return GRIB_SUCCESS; -} - -static size_t string_length(grib_accessor* a) -{ - return MAX_GRIDNAME_LEN; -} diff --git a/src/grib_accessor_class_gds_is_present.cc b/src/grib_accessor_class_gds_is_present.cc deleted file mode 100644 index 6066231ac..000000000 --- a/src/grib_accessor_class_gds_is_present.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/****************************** - * Enrico Fucile - *****************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS = const char* gds_present - MEMBERS = const char* grid_definition - MEMBERS = const char* bitmap_present - MEMBERS = const char* values - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_gds_is_present -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in gds_is_present */ - const char* gds_present; - const char* grid_definition; - const char* bitmap_present; - const char* values; -} grib_accessor_gds_is_present; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_gds_is_present = { - &grib_accessor_class_long, /* super */ - "gds_is_present", /* name */ - sizeof(grib_accessor_gds_is_present), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gds_is_present = &_grib_accessor_class_gds_is_present; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_gds_is_present* self = (grib_accessor_gds_is_present*)a; - grib_handle* h = grib_handle_of_accessor(a); - self->gds_present = grib_arguments_get_name(h, c, n++); - self->grid_definition = grib_arguments_get_name(h, c, n++); - self->bitmap_present = grib_arguments_get_name(h, c, n++); - self->values = grib_arguments_get_name(h, c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->length = 0; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_gds_is_present* self = (grib_accessor_gds_is_present*)a; - long missing = 255; - int ret = 0; - size_t size = 0; - double* values = NULL; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (*val != 1) - return GRIB_NOT_IMPLEMENTED; - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - if ((ret = grib_set_long_internal(h, self->gds_present, *val)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_set_long_internal(h, self->bitmap_present, *val)) != GRIB_SUCCESS) - return ret; - - - if ((ret = grib_set_long_internal(h, self->grid_definition, missing)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) - return ret; - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_gds_is_present* self = (grib_accessor_gds_is_present*)a; - - if ((ret = grib_get_long_internal(h, self->gds_present, val)) != GRIB_SUCCESS) - return ret; - - *len = 1; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_gds_not_present_bitmap.cc b/src/grib_accessor_class_gds_not_present_bitmap.cc deleted file mode 100644 index d8ec8ecd1..000000000 --- a/src/grib_accessor_class_gds_not_present_bitmap.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/****************************** - * Enrico Fucile - *****************************/ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = unpack_double - IMPLEMENTS = pack_double - IMPLEMENTS = value_count - IMPLEMENTS = get_native_type - MEMBERS=const char* missing_value - MEMBERS=const char* number_of_values - MEMBERS=const char* number_of_points - MEMBERS=const char* latitude_of_first_point - MEMBERS=const char* ni - - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_gds_not_present_bitmap -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in gds_not_present_bitmap */ - const char* missing_value; - const char* number_of_values; - const char* number_of_points; - const char* latitude_of_first_point; - const char* ni; -} grib_accessor_gds_not_present_bitmap; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_gds_not_present_bitmap = { - &grib_accessor_class_gen, /* super */ - "gds_not_present_bitmap", /* name */ - sizeof(grib_accessor_gds_not_present_bitmap), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gds_not_present_bitmap = &_grib_accessor_class_gds_not_present_bitmap; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - int n = 0; - grib_accessor_gds_not_present_bitmap* self = (grib_accessor_gds_not_present_bitmap*)a; - grib_handle* hand = grib_handle_of_accessor(a); - - self->missing_value = grib_arguments_get_name(hand, args, n++); - self->number_of_values = grib_arguments_get_name(hand, args, n++); - self->number_of_points = grib_arguments_get_name(hand, args, n++); - self->latitude_of_first_point = grib_arguments_get_name(hand, args, n++); - self->ni = grib_arguments_get_name(hand, args, n++); - a->length = 0; -} - -static int value_count(grib_accessor* a, long* number_of_points) -{ - grib_accessor_gds_not_present_bitmap* self = (grib_accessor_gds_not_present_bitmap*)a; - *number_of_points = 0; - return grib_get_long_internal(grib_handle_of_accessor(a), self->number_of_points, number_of_points); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_gds_not_present_bitmap* self = (grib_accessor_gds_not_present_bitmap*)a; - grib_handle* hand = grib_handle_of_accessor(a); - - long number_of_points = 0, number_of_values = 0, ni = 0; - long latitude_of_first_point = 0; - size_t i = 0; - size_t n_vals = 0; - long nn = 0; - long missing_value; - - int err = 0; - double* coded_vals = NULL; - err = grib_value_count(a, &nn); - n_vals = nn; - if (err) - return err; - - if ((err = grib_get_long(hand, self->number_of_points, &number_of_points)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long(hand, self->number_of_values, &number_of_values)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long(hand, self->latitude_of_first_point, &latitude_of_first_point)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long(hand, self->missing_value, &missing_value)) != GRIB_SUCCESS) - return err; - - if ((err = grib_get_long(hand, self->ni, &ni)) != GRIB_SUCCESS) - return err; - - if (*len < number_of_points) { - *len = n_vals; - return GRIB_ARRAY_TOO_SMALL; - } - - if (number_of_values > 0) { - coded_vals = (double*)grib_context_malloc(a->context, number_of_values * sizeof(double)); - - if (coded_vals == NULL) - return GRIB_OUT_OF_MEMORY; - } - - if (latitude_of_first_point == 0) { - for (i = 0; i < number_of_values; i++) - val[i] = 1; - for (i = number_of_values; i < number_of_points; i++) - val[i] = 0; - } - else { - for (i = 0; i < ni - 1; i++) - val[i] = 0; - for (i = ni - 1; i < number_of_points; i++) - val[i] = 1; - } - - *len = number_of_points; - - grib_context_free(a->context, coded_vals); - return err; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - // See deprecated/grib_accessor_class_gds_not_present_bitmap.cc for - // a possible implementation - return GRIB_NOT_IMPLEMENTED; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} diff --git a/src/grib_accessor_class_gen.cc b/src/grib_accessor_class_gen.cc deleted file mode 100644 index 8b59b3b7a..000000000 --- a/src/grib_accessor_class_gen.cc +++ /dev/null @@ -1,678 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/*************************************************************************** - * Jean Baptiste Filippi - 01.11.2005 * - * Enrico Fucile * - * Shahram Najm * - ***************************************************************************/ -#include "grib_api_internal.h" -#include "grib_value.h" -#include -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - IMPLEMENTS = unpack_long;pack_long; clear - IMPLEMENTS = unpack_double;pack_double;unpack_double_element;unpack_double_element_set - IMPLEMENTS = unpack_float - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = unpack_string_array;pack_string_array - IMPLEMENTS = unpack_bytes;pack_bytes - IMPLEMENTS = unpack_double_subarray - IMPLEMENTS = init;dump;destroy;string_length - IMPLEMENTS = get_native_type;sub_section - IMPLEMENTS = next_offset;value_count;byte_offset;byte_count - IMPLEMENTS = notify_change;pack_expression - IMPLEMENTS = update_size; next; preferred_size - IMPLEMENTS = compare;is_missing;make_clone - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static grib_section* sub_section(grib_accessor* a); -static int get_native_type(grib_accessor*); -static int is_missing(grib_accessor*); -static int pack_bytes(grib_accessor*, const unsigned char*, size_t* len); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_string_array(grib_accessor*, const char**, size_t* len); -static int pack_expression(grib_accessor*, grib_expression*); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static size_t string_length(grib_accessor*); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int notify_change(grib_accessor*, grib_accessor*); -static void update_size(grib_accessor*, size_t); -static size_t preferred_size(grib_accessor*, int); -static grib_accessor* next(grib_accessor*, int); -static int compare(grib_accessor*, grib_accessor*); -static int unpack_double_element(grib_accessor*, size_t i, double* val); -static int unpack_double_element_set(grib_accessor*, const size_t* index_array, size_t len, double* val_array); -static int unpack_double_subarray(grib_accessor*, double* val, size_t start, size_t len); -static int clear(grib_accessor*); -static grib_accessor* make_clone(grib_accessor*, grib_section*, int*); - -typedef struct grib_accessor_gen -{ - grib_accessor att; - /* Members defined in gen */ -} grib_accessor_gen; - - -static grib_accessor_class _grib_accessor_class_gen = { - 0, /* super */ - "gen", /* name */ - sizeof(grib_accessor_gen), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - &get_native_type, /* get native type */ - &sub_section, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - &pack_string_array, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - &pack_bytes, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - &pack_expression, /* pack_expression */ - ¬ify_change, /* notify_change */ - &update_size, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - &next, /* next accessor */ - &compare, /* compare vs. another accessor */ - &unpack_double_element, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - &unpack_double_element_set, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - &unpack_double_subarray, /* unpack a subarray */ - &clear, /* clear */ - &make_clone, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gen = &_grib_accessor_class_gen; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* param) -{ - grib_action* act = (grib_action*)(a->creator); - if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { - a->length = 0; - if (!a->vvalue) - a->vvalue = (grib_virtual_value*)grib_context_malloc_clear(a->context, sizeof(grib_virtual_value)); - a->vvalue->type = grib_accessor_get_native_type(a); - a->vvalue->length = len; - if (act->default_value != NULL) { - const char* p = 0; - size_t s_len = 1; - long l; - int ret = 0; - double d; - char tmp[1024]; - grib_expression* expression = grib_arguments_get_expression(grib_handle_of_accessor(a), act->default_value, 0); - int type = grib_expression_native_type(grib_handle_of_accessor(a), expression); - switch (type) { - case GRIB_TYPE_DOUBLE: - grib_expression_evaluate_double(grib_handle_of_accessor(a), expression, &d); - grib_pack_double(a, &d, &s_len); - break; - - case GRIB_TYPE_LONG: - grib_expression_evaluate_long(grib_handle_of_accessor(a), expression, &l); - grib_pack_long(a, &l, &s_len); - break; - - default: - s_len = sizeof(tmp); - p = grib_expression_evaluate_string(grib_handle_of_accessor(a), expression, tmp, &s_len, &ret); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to evaluate %s as string", a->name); - Assert(0); - } - s_len = strlen(p) + 1; - grib_pack_string(a, p, &s_len); - break; - } - } - } - else { - a->length = len; - } -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - const int type = grib_accessor_get_native_type(a); - switch (type) { - case GRIB_TYPE_STRING: - grib_dump_string(dumper, a, NULL); - break; - case GRIB_TYPE_DOUBLE: - grib_dump_double(dumper, a, NULL); - break; - case GRIB_TYPE_LONG: - grib_dump_long(dumper, a, NULL); - break; - default: - grib_dump_bytes(dumper, a, NULL); - } -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 1024; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int get_native_type(grib_accessor* a) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, - "Accessor %s [%s] must implement 'get_native_type'", a->name, a->cclass->name); - return GRIB_TYPE_UNDEFINED; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t* len) -{ - unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; - const long length = grib_byte_count(a); - const long offset = grib_byte_offset(a); - - if (*len < length) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it is %ld bytes long", a->name, length); - *len = length; - return GRIB_ARRAY_TOO_SMALL; - } - - memcpy(val, buf + offset, length); - *len = length; - - return GRIB_SUCCESS; -} - -static int clear(grib_accessor* a) -{ - unsigned char* buf = grib_handle_of_accessor(a)->buffer->data; - const long length = grib_byte_count(a); - const long offset = grib_byte_offset(a); - - memset(buf + offset, 0, length); - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - int type = GRIB_TYPE_UNDEFINED; - if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { - double val = 0.0; - size_t l = 1; - grib_unpack_double(a, &val, &l); - if (val == GRIB_MISSING_DOUBLE) - *v = GRIB_MISSING_LONG; - else - *v = (long)val; - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to long", a->name); - return GRIB_SUCCESS; - } - - if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - grib_unpack_string(a, val, &l); - - *v = strtol(val, &last, 10); - - if (*last == 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to long", a->name); - return GRIB_SUCCESS; - } - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as long", a->name); - if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); - } - return GRIB_NOT_IMPLEMENTED; -} - -template -static int unpack(grib_accessor* a, T* v, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - int type = GRIB_TYPE_UNDEFINED; - const char* Tname = type_to_string(*v); - if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { - long val = 0; - size_t l = 1; - grib_unpack_long(a, &val, &l); - *v = val; - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - - if (a->cclass->unpack_string && a->cclass->unpack_string != &unpack_string) { - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - grib_unpack_string(a, val, &l); - - *v = strtod(val, &last); - if (*last == 0) { /* conversion of string to double worked */ - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting string %s to %s", a->name, Tname); - return GRIB_SUCCESS; - } - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Cannot unpack key '%s' as %s", a->name, Tname); - if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type)); - } - - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - return unpack(a, v, len); -} - -static int unpack_float(grib_accessor* a, float* v, size_t* len) -{ - return unpack(a, v, len); -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - int err = 0; - if (a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double) { - double val = 0.0; - size_t l = 1; - err = grib_unpack_double(a, &val, &l); - if (err) return err; - snprintf(v, 64, "%g", val); - *len = strlen(v); - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting double %s to string", a->name); - return GRIB_SUCCESS; - } - - if (a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long) { - long val = 0; - size_t l = 1; - err = grib_unpack_long(a, &val, &l); - if (err) return err; - snprintf(v, 64, "%ld", val); - *len = strlen(v); - grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to string\n", a->name); - return GRIB_SUCCESS; - } - - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_string_array(grib_accessor* a, char** v, size_t* len) -{ - size_t length = 0; - - int err = grib_get_string_length_acc(a, &length); - if (err) - return err; - v[0] = (char*)grib_context_malloc_clear(a->context, length); - grib_unpack_string(a, v[0], &length); // TODO(masn): check return value - *len = 1; - - return GRIB_SUCCESS; -} - -static int pack_expression(grib_accessor* a, grib_expression* e) -{ - size_t len = 1; - long lval = 0; - double dval = 0; - const char* cval = NULL; - int ret = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - // Use the native type of the expression not the accessor - switch (grib_expression_native_type(hand, e)) { - case GRIB_TYPE_LONG: { - len = 1; - ret = grib_expression_evaluate_long(hand, e, &lval); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as long (from %s)", - a->name, e->cclass->name); - return ret; - } - /*if (hand->context->debug) - printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %ld\n", a->name,lval);*/ - return grib_pack_long(a, &lval, &len); - } - - case GRIB_TYPE_DOUBLE: { - len = 1; - ret = grib_expression_evaluate_double(hand, e, &dval); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as double (from %s)", - a->name, e->cclass->name); - return ret; - } - /*if (hand->context->debug) - printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %g\n", a->name, dval);*/ - return grib_pack_double(a, &dval, &len); - } - - case GRIB_TYPE_STRING: { - char tmp[1024]; - len = sizeof(tmp); - cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Unable to set %s as string (from %s)", - a->name, e->cclass->name); - return ret; - } - len = strlen(cval); - /*if (hand->context->debug) - printf("ECCODES DEBUG grib_accessor_class_gen::pack_expression %s %s\n", a->name, cval);*/ - return grib_pack_string(a, cval, &len); - } - } - - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ - grib_context* c = a->context; - if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { - int i = 0, ret = 0; - double* val = (double*)grib_context_malloc(c, *len * (sizeof(double))); - if (!val) { - grib_context_log(c, GRIB_LOG_ERROR, - "Unable to allocate %zu bytes", *len * (sizeof(double))); - return GRIB_OUT_OF_MEMORY; - } - for (i = 0; i < *len; i++) - val[i] = (long)v[i]; - ret = grib_pack_double(a, val, len); - grib_context_free(c, val); - return ret; - } - grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as an integer", a->name); - if (a->cclass->pack_string && a->cclass->pack_string != &pack_string) { - grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); - } - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_double_array_as_long(grib_accessor* a, const double* v, size_t* len) -{ - grib_context* c = a->context; - int ret = GRIB_SUCCESS; - size_t i = 0; - size_t numBytes = *len * (sizeof(long)); - long* lValues = (long*)grib_context_malloc(c, numBytes); - if (!lValues) { - grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes); - return GRIB_OUT_OF_MEMORY; - } - for (i = 0; i < *len; i++) - lValues[i] = (long)v[i]; /* convert from double to long */ - ret = grib_pack_long(a, lValues, len); - grib_context_free(c, lValues); - return ret; -} - -static int pack_double(grib_accessor* a, const double* v, size_t* len) -{ - int do_pack_as_long = 0; - grib_context* c = a->context; - if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { - do_pack_as_long = 1; - } - else { - /* ECC-648: Special case of codetable */ - if (strcmp(a->cclass->name, "codetable") == 0) { - do_pack_as_long = 1; - } - } - if (do_pack_as_long) { - return pack_double_array_as_long(a, v, len); - } - grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", a->name); - if (a->cclass->pack_string && a->cclass->pack_string != &pack_string) { - grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string"); - } - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_string_array(grib_accessor* a, const char** v, size_t* len) -{ - int err = 0; - size_t length = 0; - grib_accessor* as = 0; - - as = a; - long i = (long)*len - 1; - while (as && i >= 0) { - length = strlen(v[i]); - err = grib_pack_string(as, v[i], &length); - if (err) - return err; - --i; - as = as->same; - } - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* v, size_t* len) -{ - if (a->cclass->pack_double && a->cclass->pack_double != &pack_double) { - size_t l = 1; - char* endPtr = NULL; /* for error handling */ - double val = strtod(v, &endPtr); - if (*endPtr) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Invalid value (%s) for key '%s'. String cannot be converted to a double", - __func__, v, a->name); - return GRIB_WRONG_TYPE; - } - return grib_pack_double(a, &val, &l); - } - - if (a->cclass->pack_long && a->cclass->pack_long != &pack_long) { - size_t l = 1; - long val = atol(v); - return grib_pack_long(a, &val, &l); - } - - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack '%s' as string", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) -{ - const size_t length = *len; - if (length != a->length) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "pack_bytes: Wrong size (%zu) for %s. It is %ld bytes long", - length, a->name, a->length); - return GRIB_BUFFER_TOO_SMALL; - } - grib_buffer_replace(a, val, length, 1, 1); - return GRIB_SUCCESS; -} - -static void destroy(grib_context* ct, grib_accessor* a) -{ - grib_dependency_remove_observed(a); - grib_dependency_remove_observer(a); - if (a->vvalue != NULL) { - grib_context_free(ct, a->vvalue); - a->vvalue = NULL; - } - /*grib_context_log(ct,GRIB_LOG_DEBUG,"address=%p",a);*/ -} - -static grib_section* sub_section(grib_accessor* a) -{ - return NULL; -} - -static int notify_change(grib_accessor* self, grib_accessor* observed) -{ - /* Default behaviour is to notify creator */ - return grib_action_notify_change(self->creator, self, observed); -} - -static void update_size(grib_accessor* a, size_t s) -{ - grib_context_log(a->context, GRIB_LOG_FATAL, - "Accessor %s [%s] must implement 'update_size'", a->name, a->cclass->name); -} - -static grib_accessor* next(grib_accessor* a, int mod) -{ - grib_accessor* next = NULL; - if (a->next) { - next = a->next; - } - else { - if (a->parent->owner) - next = a->parent->owner->cclass->next(a->parent->owner, 0); - } - return next; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - return GRIB_NOT_IMPLEMENTED; -} - -/* Redefined in all padding */ - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - return a->length; -} - -static int is_missing(grib_accessor* a) -{ - int i = 0; - int is_missing = 1; - unsigned char ones = 0xff; - unsigned char* v = NULL; - - if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { - if (a->vvalue == NULL) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s internal error (flags=0x%lX)", a->name, a->flags); - Assert(!"grib_accessor_class_gen::is_missing(): a->vvalue == NULL"); - return 0; - } - return a->vvalue->missing; - } - Assert(a->length >= 0); - - v = grib_handle_of_accessor(a)->buffer->data + a->offset; - - for (i = 0; i < a->length; i++) { - if (*v != ones) { - is_missing = 0; - break; - } - v++; - } - - return is_missing; -} - -static int unpack_double_element(grib_accessor* a, size_t i, double* val) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_double_subarray(grib_accessor* a, double* val, size_t start, size_t len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) -{ - *err = GRIB_NOT_IMPLEMENTED; - return NULL; -} diff --git a/src/grib_accessor_class_getenv.cc b/src/grib_accessor_class_getenv.cc deleted file mode 100644 index 6bc0ced3e..000000000 --- a/src/grib_accessor_class_getenv.cc +++ /dev/null @@ -1,157 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = pack_string;unpack_string;value_count - IMPLEMENTS = init;string_length - MEMBERS= const char* name - MEMBERS= char* value - MEMBERS= const char* default_value - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_getenv -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in getenv */ - const char* name; - char* value; - const char* default_value; -} grib_accessor_getenv; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_getenv = { - &grib_accessor_class_ascii, /* super */ - "getenv", /* name */ - sizeof(grib_accessor_getenv), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_getenv = &_grib_accessor_class_getenv; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - grib_accessor_getenv* self = (grib_accessor_getenv*)a; - static char undefined[] = "undefined"; - - self->name = grib_arguments_get_string(grib_handle_of_accessor(a), args, 0); - self->default_value = grib_arguments_get_string(grib_handle_of_accessor(a), args, 1); - if (!self->default_value) - self->default_value = undefined; - self->value = 0; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_getenv* self = (grib_accessor_getenv*)a; - char* v = 0; - size_t l = 0; - - if (!self->value) { - v = getenv(self->name); - if (!v) - v = (char*)self->default_value; - self->value = v; - } - - l = strlen(self->value); - if (*len < l) - return GRIB_BUFFER_TOO_SMALL; - snprintf(val, 1024, "%s", self->value); - *len = strlen(self->value); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 1024; -} diff --git a/src/grib_accessor_class_group.cc b/src/grib_accessor_class_group.cc deleted file mode 100644 index a64362968..000000000 --- a/src/grib_accessor_class_group.cc +++ /dev/null @@ -1,282 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - IMPLEMENTS = compare - MEMBERS = char endCharacter - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_group -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in group */ - char endCharacter; -} grib_accessor_group; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_group = { - &grib_accessor_class_gen, /* super */ - "group", /* name */ - sizeof(grib_accessor_group), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_group = &_grib_accessor_class_group; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; - grib_accessor_group* self = (grib_accessor_group*)a; - - size_t i = 0; - unsigned char* v; - const char* s = grib_arguments_get_string(grib_handle_of_accessor(a), arg, 0); - - if (s && strlen(s) > 1) { - grib_context_log(a->context, GRIB_LOG_WARNING, - "Using only first character as group end of %s not the string %s", a->name, s); - } - - self->endCharacter = s ? s[0] : 0; - - v = buffer->data + a->offset; - i = 0; - if (s) { - while (*v != self->endCharacter && i <= buffer->ulength) { - if (*v > 126) - *v = 32; - v++; - i++; - } - } - else { - while (*v > 32 && *v != 61 && *v < 127 && i <= buffer->ulength) { - v++; - i++; - } - } - a->length = i; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long i = 0; - size_t l = a->length + 1; - grib_handle* h = grib_handle_of_accessor(a); - - if (*len < l) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - a->cclass->name, a->name, l, *len); - *len = l; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) - val[i] = h->buffer->data[a->offset + i]; - val[i] = 0; - *len = i; - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - size_t i = 0; - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - i = 0; - while (i < l - 1 && val[i] == ' ') - i++; - - if (val[i] == 0) { - *v = 0; - return 0; - } - if (val[i + 1] == ' ' && i < l - 2) - val[i + 1] = 0; - - *v = strtol(val, &last, 10); - - grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - grib_unpack_string(a, val, &l); - - *v = strtod(val, &last); - - if (*last == 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, " Casting string %s to long", a->name); - return GRIB_SUCCESS; - } - - return GRIB_NOT_IMPLEMENTED; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - char* aval = 0; - char* bval = 0; - int err = 0; - - size_t alen = 0; - size_t blen = 0; - long count = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (char*)grib_context_malloc(a->context, alen * sizeof(char)); - bval = (char*)grib_context_malloc(b->context, blen * sizeof(char)); - - grib_unpack_string(a, aval, &alen); - grib_unpack_string(b, bval, &blen); - - retval = GRIB_SUCCESS; - if (strcmp(aval, bval)) - retval = GRIB_STRING_VALUE_MISMATCH; - - grib_context_free(a->context, aval); - grib_context_free(b->context, bval); - - return retval; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/grib_accessor_class_gts_header.cc b/src/grib_accessor_class_gts_header.cc deleted file mode 100644 index 65b295634..000000000 --- a/src/grib_accessor_class_gts_header.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string;value_count - IMPLEMENTS = init;string_length - MEMBERS = int gts_offset - MEMBERS = int gts_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_gts_header -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in gts_header */ - int gts_offset; - int gts_length; -} grib_accessor_gts_header; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_gts_header = { - &grib_accessor_class_ascii, /* super */ - "gts_header", /* name */ - sizeof(grib_accessor_gts_header), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_gts_header = &_grib_accessor_class_gts_header; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_gts_header* self = (grib_accessor_gts_header*)a; - self->gts_offset = -1; - self->gts_length = -1; - self->gts_offset = grib_arguments_get_long(grib_handle_of_accessor(a), c, 0); - self->gts_length = grib_arguments_get_long(grib_handle_of_accessor(a), c, 1); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_gts_header* self = (grib_accessor_gts_header*)a; - grib_handle* h = grib_handle_of_accessor(a); - int offset = 0; - size_t length = 0; - - if (h->gts_header == NULL || h->gts_header_len < 8) { - if (*len < 8) - return GRIB_BUFFER_TOO_SMALL; - snprintf(val, 1024, "missing"); - return GRIB_SUCCESS; - } - if (*len < h->gts_header_len) - return GRIB_BUFFER_TOO_SMALL; - - offset = self->gts_offset > 0 ? self->gts_offset : 0; - length = self->gts_length > 0 ? self->gts_length : h->gts_header_len; - - memcpy(val, h->gts_header + offset, length); - - *len = length; - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - grib_handle* h = grib_handle_of_accessor(a); - return h->gts_header_len; -} diff --git a/src/grib_accessor_class_hash_array.cc b/src/grib_accessor_class_hash_array.cc deleted file mode 100644 index d191a5232..000000000 --- a/src/grib_accessor_class_hash_array.cc +++ /dev/null @@ -1,293 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - - -/******************************************************* - * Enrico Fucile - ******************************************************/ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_string;pack_string;string_length - IMPLEMENTS = unpack_long;pack_long;destroy - IMPLEMENTS = init;dump;value_count;get_native_type - IMPLEMENTS = compare - MEMBERS = char* key - MEMBERS = grib_hash_array_value* ha - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_hash_array -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in hash_array */ - char* key; - grib_hash_array_value* ha; -} grib_accessor_hash_array; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_hash_array = { - &grib_accessor_class_gen, /* super */ - "hash_array", /* name */ - sizeof(grib_accessor_hash_array), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_hash_array = &_grib_accessor_class_hash_array; - -/* END_CLASS_IMP */ - -#define MAX_HASH_ARRAY_STRING_LENGTH 255 - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - a->length = 0; - self->key = 0; - self->ha = NULL; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - char s[200] = {0,}; - snprintf(s, sizeof(s), "%g", *val); - self->key = grib_context_strdup(a->context, s); - self->ha = 0; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - char s[200] = {0,}; - snprintf(s, sizeof(s), "%ld", *val); - if (self->key) - grib_context_free(a->context, self->key); - self->key = grib_context_strdup(a->context, s); - self->ha = 0; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* v, size_t* len) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - self->key = grib_context_strdup(a->context, v); - self->ha = 0; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static grib_hash_array_value* find_hash_value(grib_accessor* a, int* err) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - grib_hash_array_value* ha_ret = 0; - grib_hash_array_value* ha = NULL; - - ha = get_hash_array(grib_handle_of_accessor(a), a->creator); - if (!ha) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "unable to get hash value for %s", a->creator->name); - *err = GRIB_HASH_ARRAY_NO_MATCH; - return NULL; - } - - *err = GRIB_SUCCESS; - - Assert(ha != NULL); - if (!self->key) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "unable to get hash value for %s, set before getting", a->creator->name); - *err = GRIB_HASH_ARRAY_NO_MATCH; - return NULL; - } - - ha_ret = (grib_hash_array_value*)grib_trie_get(ha->index, self->key); - if (!ha_ret) - ha_ret = (grib_hash_array_value*)grib_trie_get(ha->index, "default"); - - if (!ha_ret) { - *err = GRIB_HASH_ARRAY_NO_MATCH; - grib_context_log(a->context, GRIB_LOG_ERROR, - "hash_array: no match for %s=%s", - a->creator->name, self->key); - const char* full_path = get_hash_array_full_path(a->creator); - if (full_path) { - grib_context_log(a->context, GRIB_LOG_ERROR, "hash_array: file path = %s", full_path); - } - grib_context_log(a->context, GRIB_LOG_ERROR, "Hint: Check the key 'masterTablesVersionNumber'"); - return NULL; - } - return ha_ret; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_hash_array_value* ha = 0; - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - int err = 0; - size_t i = 0; - - if (!self->ha) { - ha = find_hash_value(a, &err); - if (err) - return err; - self->ha = ha; - } - - switch (self->ha->type) { - case GRIB_HASH_ARRAY_TYPE_INTEGER: - if (*len < self->ha->iarray->n) { - return GRIB_ARRAY_TOO_SMALL; - } - *len = self->ha->iarray->n; - for (i = 0; i < *len; i++) - val[i] = self->ha->iarray->v[i]; - break; - - default: - return GRIB_NOT_IMPLEMENTED; - } - - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - int type = GRIB_TYPE_STRING; - if (a->flags & GRIB_ACCESSOR_FLAG_LONG_TYPE) - type = GRIB_TYPE_LONG; - - return type; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - if (self->key) - grib_context_free(c, self->key); -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static size_t string_length(grib_accessor* a) -{ - return MAX_HASH_ARRAY_STRING_LENGTH; -} - -static int value_count(grib_accessor* a, long* count) -{ - int err = 0; - grib_accessor_hash_array* self = (grib_accessor_hash_array*)a; - grib_hash_array_value* ha = 0; - - if (!self->ha) { - ha = find_hash_value(a, &err); - if (err) - return err; - self->ha = ha; - } - - *count = self->ha->iarray->n; - return err; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - return GRIB_NOT_IMPLEMENTED; -} diff --git a/src/grib_accessor_class_headers_only.cc b/src/grib_accessor_class_headers_only.cc deleted file mode 100644 index d3a98efb0..000000000 --- a/src/grib_accessor_class_headers_only.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long; get_native_type - IMPLEMENTS = init - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_headers_only -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in headers_only */ -} grib_accessor_headers_only; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_headers_only = { - &grib_accessor_class_gen, /* super */ - "headers_only", /* name */ - sizeof(grib_accessor_headers_only), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_headers_only = &_grib_accessor_class_headers_only; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - *val = grib_handle_of_accessor(a)->partial; - *len = 1; - return 0; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_ibmfloat.cc b/src/grib_accessor_class_ibmfloat.cc deleted file mode 100644 index 27e6da1c5..000000000 --- a/src/grib_accessor_class_ibmfloat.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = init - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - MEMBERS = grib_arguments* arg - IMPLEMENTS = update_size - IMPLEMENTS = nearest_smaller_value - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int nearest_smaller_value (grib_accessor*, double, double*); - -typedef struct grib_accessor_ibmfloat -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in ibmfloat */ - grib_arguments* arg; -} grib_accessor_ibmfloat; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_ibmfloat = { - &grib_accessor_class_double, /* super */ - "ibmfloat", /* name */ - sizeof(grib_accessor_ibmfloat), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - &nearest_smaller_value, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ibmfloat = &_grib_accessor_class_ibmfloat; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_ibmfloat* self = (grib_accessor_ibmfloat*)a; - long count = 0; - - self->arg = arg; - grib_value_count(a, &count); - a->length = 4 * count; - Assert(a->length >= 0); -} - -template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - unsigned long rlen = 0; - long count = 0; - int err = 0; - unsigned long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = grib_value_count(a, &count); - if (err) - return err; - rlen = count; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ibm(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_ibmfloat* self = (grib_accessor_ibmfloat*)a; - int ret = 0; - unsigned long i = 0; - unsigned long rlen = *len; - size_t buflen = 0; - unsigned char* buf = NULL; - long off = 0; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - if (rlen == 1) { - - //double x = 0; - //grib_nearest_smaller_ibm_float(val[0],&x); - //double y = grib_long_to_ibm(grib_ibm_to_long(val[0])); - //printf("IBMFLOAT val=%.20f nearest_smaller_ibm_float=%.20f long_to_ibm=%.20f\n",val[0],x ,y); - - off = byte_offset(a) * 8; - ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ibm_to_long(val[0]), &off, 32); - if (*len > 1) - grib_context_log(a->context, GRIB_LOG_WARNING, "ibmfloat: Trying to pack %zu values in a scalar %s, packing first value", - *len, a->name); - if (ret == GRIB_SUCCESS) - len[0] = 1; - return ret; - } - - buflen = rlen * 4; - - buf = (unsigned char*)grib_context_malloc(a->context, buflen); - - for (i = 0; i < rlen; i++) { - grib_encode_unsigned_longb(buf, grib_ibm_to_long(val[i]), &off, 32); - } - ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), rlen); - - if (ret == GRIB_SUCCESS) - grib_buffer_replace(a, buf, buflen, 1, 1); - else - *len = 0; - - grib_context_free(a->context, buf); - - a->length = byte_count(a); - - return ret; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_ibmfloat* self = (grib_accessor_ibmfloat*)a; - *len = 0; - if (!self->arg) { - *len = 1; - return 0; - } - return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = (long)s; - Assert(a->length >= 0); -} - -static long next_offset(grib_accessor* a) -{ - return grib_byte_offset(a) + grib_byte_count(a); -} - -static int nearest_smaller_value(grib_accessor* a, double val, double* nearest) -{ - int ret = 0; - if (grib_nearest_smaller_ibm_float(val, nearest) == GRIB_INTERNAL_ERROR) { - grib_context_log(a->context, GRIB_LOG_ERROR, "ibm_float:nearest_smaller_value overflow value=%g", val); - grib_dump_content(grib_handle_of_accessor(a), stderr, "wmo", GRIB_DUMP_FLAG_HEXADECIMAL, 0); - ret = GRIB_INTERNAL_ERROR; - } - return ret; -} diff --git a/src/grib_accessor_class_ieeefloat.cc b/src/grib_accessor_class_ieeefloat.cc deleted file mode 100644 index d6fa411bb..000000000 --- a/src/grib_accessor_class_ieeefloat.cc +++ /dev/null @@ -1,226 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_float - IMPLEMENTS = init - IMPLEMENTS = value_count - MEMBERS = grib_arguments* arg - IMPLEMENTS = update_size - IMPLEMENTS = nearest_smaller_value - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int nearest_smaller_value (grib_accessor*, double, double*); - -typedef struct grib_accessor_ieeefloat -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in ieeefloat */ - grib_arguments* arg; -} grib_accessor_ieeefloat; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_ieeefloat = { - &grib_accessor_class_double, /* super */ - "ieeefloat", /* name */ - sizeof(grib_accessor_ieeefloat), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - &nearest_smaller_value, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ieeefloat = &_grib_accessor_class_ieeefloat; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_ieeefloat* self = (grib_accessor_ieeefloat*)a; - long count = 0; - self->arg = arg; - grib_value_count(a, &count); - a->length = 4 * count; - Assert(a->length >= 0); -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_ieeefloat* self = (grib_accessor_ieeefloat*)a; - *len = 0; - - if (!self->arg) { - *len = 1; - return 0; - } - return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_ieeefloat* self = (grib_accessor_ieeefloat*)a; - int ret = 0; - unsigned long i = 0; - unsigned long rlen = (unsigned long)*len; - size_t buflen = 0; - unsigned char* buf = NULL; - long off = 0; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it packs at least 1 value", a->name); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - if (rlen == 1) { - off = a->offset * 8; - ret = grib_encode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, grib_ieee_to_long(val[0]), &off, 32); - if (*len > 1) - grib_context_log(a->context, GRIB_LOG_WARNING, "ieeefloat: Trying to pack %zu values in a scalar %s, packing first value", - *len, a->name); - if (ret == GRIB_SUCCESS) - len[0] = 1; - return ret; - } - - buflen = rlen * 4; - - buf = (unsigned char*)grib_context_malloc(a->context, buflen); - - for (i = 0; i < rlen; i++) { - grib_encode_unsigned_longb(buf, grib_ieee_to_long(val[i]), &off, 32); - } - ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), rlen); - - if (ret == GRIB_SUCCESS) - grib_buffer_replace(a, buf, buflen, 1, 1); - else - *len = 0; - - grib_context_free(a->context, buf); - - return ret; -} - -template -static int unpack(grib_accessor* a, T* val, size_t* len) -{ - static_assert(std::is_floating_point::value, "Requires floating point numbers"); - long rlen = 0; - int err = 0; - long i = 0; - long bitp = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); - - err = grib_value_count(a, &rlen); - if (err) - return err; - - if (*len < (size_t)rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) - val[i] = (T)grib_long_to_ieee(grib_decode_unsigned_long(hand->buffer->data, &bitp, 32)); - - *len = rlen; - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return unpack(a, val, len); -} - -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ - return unpack(a, val, len); -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = (long)s; - Assert(a->length >= 0); -} - -static int nearest_smaller_value(grib_accessor* a, double val, double* nearest) -{ - return grib_nearest_smaller_ieee_float(val, nearest); -} diff --git a/src/grib_accessor_class_ifs_param.cc b/src/grib_accessor_class_ifs_param.cc deleted file mode 100644 index ba7e522c1..000000000 --- a/src/grib_accessor_class_ifs_param.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long; pack_long - IMPLEMENTS = init; get_native_type - MEMBERS=const char* paramId - MEMBERS=const char* type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_ifs_param -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ifs_param */ - const char* paramId; - const char* type; -} grib_accessor_ifs_param; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_ifs_param = { - &grib_accessor_class_gen, /* super */ - "ifs_param", /* name */ - sizeof(grib_accessor_ifs_param), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ifs_param = &_grib_accessor_class_ifs_param; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_ifs_param* self = (grib_accessor_ifs_param*)a; - int n = 0; - - self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->type = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_ifs_param* self = (grib_accessor_ifs_param*)a; - int ret = 0; - long paramId = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->paramId, ¶mId)) != GRIB_SUCCESS) - return ret; - - if (paramId > 129000 && paramId < 129999) - *val = paramId - 129000; - else if (paramId > 200000 && paramId < 200999) - *val = paramId - 200000; - else if (paramId > 211000 && paramId < 211999) - *val = paramId - 1000; - else - *val = paramId; - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_ifs_param* self = (grib_accessor_ifs_param*)a; - long type = 0; - long table = 128; - long paramId = *val; - long param; - - grib_get_long(grib_handle_of_accessor(a), self->type, &type); - - if (type == 33 || type == 35) { - if (paramId > 1000) { - table = paramId / 1000; - param = paramId - table * 1000; - paramId = param; - } - switch (table) { - case 210: - paramId += 211000; - break; - case 128: - paramId += 200000; - break; - default: - break; - } - } - if (type == 50 || type == 52) { - if (paramId > 1000) { - table = paramId / 1000; - param = paramId - table * 1000; - paramId = param; - } - switch (table) { - case 128: - paramId += 129000; - break; - default: - break; - } - } - - return grib_set_long_internal(grib_handle_of_accessor(a), self->paramId, paramId); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_iterator.cc b/src/grib_accessor_class_iterator.cc deleted file mode 100644 index 2a5fc815b..000000000 --- a/src/grib_accessor_class_iterator.cc +++ /dev/null @@ -1,135 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/*************************** - * Enrico Fucile - *************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - MEMBERS=grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_iterator -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in iterator */ - grib_arguments* args; -} grib_accessor_iterator; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_iterator = { - &grib_accessor_class_gen, /* super */ - "iterator", /* name */ - sizeof(grib_accessor_iterator), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_iterator = &_grib_accessor_class_iterator; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - grib_accessor_iterator* self = (grib_accessor_iterator*)a; - self->args = args; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - /* TODO: pass args */ - grib_dump_label(dumper, a, NULL); -} - -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; - *error = GRIB_NOT_IMPLEMENTED; - a = grib_find_accessor(h, "ITERATOR"); - ita = (grib_accessor_iterator*)a; - - if (!a) - return NULL; - - iter = grib_iterator_factory(h, ita->args, flags, error); - - if (iter) - *error = GRIB_SUCCESS; - - return iter; -} diff --git a/src/grib_accessor_class_julian_day.cc b/src/grib_accessor_class_julian_day.cc deleted file mode 100644 index 7a8e28cfc..000000000 --- a/src/grib_accessor_class_julian_day.cc +++ /dev/null @@ -1,209 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = dump - IMPLEMENTS = init - MEMBERS = const char *date - MEMBERS = const char *hour - MEMBERS = const char *minute - MEMBERS = const char *second - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_julian_day -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in julian_day */ - const char *date; - const char *hour; - const char *minute; - const char *second; -} grib_accessor_julian_day; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_julian_day = { - &grib_accessor_class_double, /* super */ - "julian_day", /* name */ - sizeof(grib_accessor_julian_day), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_julian_day = &_grib_accessor_class_julian_day; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_julian_day* self = (grib_accessor_julian_day*)a; - int n = 0; - - self->date = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->hour = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->minute = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->second = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - const double v = *val; - return pack_double(a, &v, len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_julian_day* self = (grib_accessor_julian_day*)a; - int ret = 0; - long hour = 0; - long minute = 0; - long second = 0; - long date = 0; - long year, month, day; - - ret = grib_julian_to_datetime(*val, &year, &month, &day, &hour, &minute, &second); - if (ret != 0) - return ret; - - date = year * 10000 + month * 100 + day; - - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->date, date); - if (ret != 0) - return ret; - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->hour, hour); - if (ret != 0) - return ret; - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->minute, minute); - if (ret != 0) - return ret; - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->second, second); - - return ret; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - double v = 0; - - ret = unpack_double(a, &v, len); - *val = (long)v; - - return ret; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - int ret = 0; - long date, hour, minute, second; - long year, month, day; - grib_accessor_julian_day* self = (grib_accessor_julian_day*)a; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->date, &date); - if (ret != GRIB_SUCCESS) - return ret; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->hour, &hour); - if (ret != GRIB_SUCCESS) - return ret; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->minute, &minute); - if (ret != GRIB_SUCCESS) - return ret; - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->second, &second); - if (ret != GRIB_SUCCESS) - return ret; - - year = date / 10000; - date %= 10000; - month = date / 100; - date %= 100; - day = date; - - ret = grib_datetime_to_julian(year, month, day, hour, minute, second, val); - - return ret; -} diff --git a/src/grib_accessor_class_ksec1expver.cc b/src/grib_accessor_class_ksec1expver.cc deleted file mode 100644 index 762bf66e2..000000000 --- a/src/grib_accessor_class_ksec1expver.cc +++ /dev/null @@ -1,185 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_long;pack_string; - IMPLEMENTS = pack_long - IMPLEMENTS = init - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_ksec1expver -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in ksec1expver */ -} grib_accessor_ksec1expver; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_ksec1expver = { - &grib_accessor_class_ascii, /* super */ - "ksec1expver", /* name */ - sizeof(grib_accessor_ksec1expver), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_ksec1expver = &_grib_accessor_class_ksec1expver; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = len; - Assert(a->length >= 0); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - long pos = a->offset * 8; - char* intc = NULL; - char* pTemp = NULL; - char expver[5]; - char refexpver[5]; - size_t llen = a->length + 1; - Assert(a->length == 4); - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - value = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, a->length * 8); - - grib_unpack_string(a, refexpver, &llen); - - /* test for endian */ - intc = (char*)&value; - pTemp = intc; - - expver[0] = *pTemp++; - expver[1] = *pTemp++; - expver[2] = *pTemp++; - expver[3] = *pTemp++; - expver[4] = 0; - -// expver[0] = intc[0]; -// expver[1] = intc[1]; -// expver[2] = intc[2]; -// expver[3] = intc[3]; -// expver[4] = 0; - - /* if there is a difference, have to reverse*/ - if (strcmp(refexpver, expver)) { - intc[0] = expver[3]; - intc[1] = expver[2]; - intc[2] = expver[1]; - intc[3] = expver[0]; - } - - *val = value; - *len = 1; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - int i = 0; - if (len[0] != 4) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong length for %s. It has to be 4", a->name); - return GRIB_INVALID_KEY_VALUE; - } - if (len[0] > (a->length) + 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "pack_string: Wrong size (%lu) for %s, it contains %ld values", - len[0], a->name, a->length + 1); - len[0] = 0; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) - grib_handle_of_accessor(a)->buffer->data[a->offset + i] = val[i]; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - char sval[5] = {0,}; - size_t slen = 4; - snprintf(sval, sizeof(sval), "%04d", (int)(*val)); - return pack_string(a, sval, &slen); -} diff --git a/src/grib_accessor_class_label.cc b/src/grib_accessor_class_label.cc deleted file mode 100644 index 8d7831faf..000000000 --- a/src/grib_accessor_class_label.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump;get_native_type;unpack_string - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_label -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in label */ -} grib_accessor_label; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_label = { - &grib_accessor_class_gen, /* super */ - "label", /* name */ - sizeof(grib_accessor_label), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_label = &_grib_accessor_class_label; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_label(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LABEL; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - size_t vlen = strlen(a->name); - if (vlen > *len) - return GRIB_BUFFER_TOO_SMALL; - *len = vlen; - strcpy(val, a->name); - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_latitudes.cc b/src/grib_accessor_class_latitudes.cc deleted file mode 100644 index 4131ff066..000000000 --- a/src/grib_accessor_class_latitudes.cc +++ /dev/null @@ -1,306 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS =const char* values - MEMBERS =long distinct - MEMBERS =double* lats - MEMBERS =long size - MEMBERS =int save - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_latitudes -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in latitudes */ - const char* values; - long distinct; - double* lats; - long size; - int save; -} grib_accessor_latitudes; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_latitudes = { - &grib_accessor_class_double, /* super */ - "latitudes", /* name */ - sizeof(grib_accessor_latitudes), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_latitudes = &_grib_accessor_class_latitudes; - -/* END_CLASS_IMP */ - - -static int get_distinct(grib_accessor* a, double** val, long* len); - -static int compare_doubles(const void* a, const void* b, int ascending) -{ - /* ascending is a boolean: 0 or 1 */ - double* arg1 = (double*)a; - double* arg2 = (double*)b; - if (ascending) { - if (*arg1 < *arg2) - return -1; /*Smaller values come before larger ones*/ - } - else { - if (*arg1 > *arg2) - return -1; /*Larger values come before smaller ones*/ - } - if (*arg1 == *arg2) - return 0; - else - return 1; -} -static int compare_doubles_ascending(const void* a, const void* b) -{ - return compare_doubles(a, b, 1); -} -static int compare_doubles_descending(const void* a, const void* b) -{ - return compare_doubles(a, b, 0); -} - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_latitudes* self = (grib_accessor_latitudes*)a; - int n = 0; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->distinct = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - self->save = 0; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_context* c = a->context; - grib_accessor_latitudes* self = (grib_accessor_latitudes*)a; - int ret = 0; - double* v = val; - double dummyLon = 0; - size_t size = 0; - long count = 0; - grib_iterator* iter = NULL; - - self->save = 1; - ret = value_count(a, &count); - if (ret) return ret; - size = count; - if (*len < size) { - /* self->lats are computed in value_count so must free */ - if (self->lats) { - grib_context_free(c, self->lats); - self->lats = NULL; - } - return GRIB_ARRAY_TOO_SMALL; - } - self->save = 0; - - /* self->lats are computed in value_count*/ - if (self->lats) { - int i; - *len = self->size; - for (i = 0; i < size; i++) - val[i] = self->lats[i]; - grib_context_free(c, self->lats); - self->lats = NULL; - self->size = 0; - return GRIB_SUCCESS; - } - - // ECC-1525 Performance: We do not need the values to be decoded - iter = grib_iterator_new(grib_handle_of_accessor(a), GRIB_GEOITERATOR_NO_VALUES, &ret); - if (ret != GRIB_SUCCESS) { - if (iter) - grib_iterator_delete(iter); - grib_context_log(c, GRIB_LOG_ERROR, "latitudes: Unable to create iterator"); - return ret; - } - - while (grib_iterator_next(iter, v++, &dummyLon, NULL)) {} - grib_iterator_delete(iter); - - *len = size; - - return ret; -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_latitudes* self = (grib_accessor_latitudes*)a; - grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = a->context; - double* val = NULL; - int ret; - size_t size; - - *len = 0; - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) { - grib_context_log(h->context, GRIB_LOG_ERROR, "latitudes: Unable to get size of %s", self->values); - return ret; - } - *len = size; - - if (self->distinct) { - ret = get_distinct(a, &val, len); - if (ret != GRIB_SUCCESS) - return ret; - if (self->save) { - self->lats = val; - self->size = *len; - } - else { - grib_context_free(c, val); - } - } - - return ret; -} - -static int get_distinct(grib_accessor* a, double** val, long* len) -{ - long count = 0; - double prev; - double* v = NULL; - double* v1 = NULL; - double dummyLon = 0; - int ret = 0; - int i; - long jScansPositively = 0; /* default: north to south */ - size_t size = *len; - grib_context* c = a->context; - - // Performance: We do not need the values to be decoded - grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), GRIB_GEOITERATOR_NO_VALUES, &ret); - if (ret != GRIB_SUCCESS) { - if (iter) - grib_iterator_delete(iter); - grib_context_log(c, GRIB_LOG_ERROR, "latitudes: Unable to create iterator"); - return ret; - } - v = (double*)grib_context_malloc_clear(c, size * sizeof(double)); - if (!v) { - grib_context_log(c, GRIB_LOG_ERROR, "latitudes: Error allocating %zu bytes", size * sizeof(double)); - return GRIB_OUT_OF_MEMORY; - } - *val = v; - - while (grib_iterator_next(iter, v++, &dummyLon, NULL)) {} - grib_iterator_delete(iter); - v = *val; - - /* See which direction the latitudes are to be scanned */ - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), "jScansPositively", &jScansPositively))) - return ret; - if (jScansPositively) { - qsort(v, *len, sizeof(double), &compare_doubles_ascending); /*South to North*/ - } - else { - qsort(v, *len, sizeof(double), &compare_doubles_descending); /*North to South*/ - } - - v1 = (double*)grib_context_malloc_clear(c, size * sizeof(double)); - if (!v1) { - grib_context_log(c, GRIB_LOG_ERROR, "latitudes: Error allocating %zu bytes", size * sizeof(double)); - return GRIB_OUT_OF_MEMORY; - } - - /* Construct a unique set of lats by filtering out duplicates */ - prev = v[0]; - v1[0] = prev; - count = 1; - for (i = 1; i < *len; i++) { - if (v[i] != prev) { - prev = v[i]; - v1[count] = prev; /* Value different from previous so store it */ - count++; - } - } - - grib_context_free(c, v); - - *val = v1; - - *len = count; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_latlonvalues.cc b/src/grib_accessor_class_latlonvalues.cc deleted file mode 100644 index e559eaa3d..000000000 --- a/src/grib_accessor_class_latlonvalues.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS =const char* values - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_latlonvalues -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in latlonvalues */ - const char* values; -} grib_accessor_latlonvalues; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_latlonvalues = { - &grib_accessor_class_double, /* super */ - "latlonvalues", /* name */ - sizeof(grib_accessor_latlonvalues), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_latlonvalues = &_grib_accessor_class_latlonvalues; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_latlonvalues* self = (grib_accessor_latlonvalues*)a; - int n = 0; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_context* c = a->context; - int err = 0; - double* v = val; - double lat, lon, value; - size_t size = 0; - long count = 0; - grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), 0, &err); - if (err) { - if (iter) grib_iterator_delete(iter); - grib_context_log(c, GRIB_LOG_ERROR, "latlonvalues: Unable to create iterator"); - return err; - } - - err = value_count(a, &count); - if (err) return err; - size = count; - - if (*len < size) { - if (iter) grib_iterator_delete(iter); - return GRIB_ARRAY_TOO_SMALL; - } - - while (grib_iterator_next(iter, &lat, &lon, &value)) { - *(v++) = lat; - *(v++) = lon; - *(v++) = value; - } - - grib_iterator_delete(iter); - - *len = size; - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_latlonvalues* self = (grib_accessor_latlonvalues*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = GRIB_SUCCESS; - size_t size; - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) { - grib_context_log(h->context, GRIB_LOG_ERROR, "latlonvalues: Unable to get size of %s", self->values); - return ret; - } - - *count = 3 * size; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_library_version.cc b/src/grib_accessor_class_library_version.cc deleted file mode 100644 index 2088b68c4..000000000 --- a/src/grib_accessor_class_library_version.cc +++ /dev/null @@ -1,130 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string;value_count;string_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); - -typedef struct grib_accessor_library_version -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in library_version */ -} grib_accessor_library_version; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_library_version = { - &grib_accessor_class_ascii, /* super */ - "library_version", /* name */ - sizeof(grib_accessor_library_version), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_library_version = &_grib_accessor_class_library_version; - -/* END_CLASS_IMP */ - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - char result[30] = {0,}; - size_t size; - - int major = ECCODES_MAJOR_VERSION; - int minor = ECCODES_MINOR_VERSION; - int revision = ECCODES_REVISION_VERSION; - - snprintf(result, sizeof(result), "%d.%d.%d", major, minor, revision); - size = sizeof(result); - - if (*len < size) - return GRIB_ARRAY_TOO_SMALL; - strcpy(val, result); - - *len = size; - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 255; -} diff --git a/src/grib_accessor_class_long.cc b/src/grib_accessor_class_long.cc deleted file mode 100644 index aeccdac78..000000000 --- a/src/grib_accessor_class_long.cc +++ /dev/null @@ -1,272 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;pack_missing; - IMPLEMENTS = unpack_string; pack_string - IMPLEMENTS = unpack_double - IMPLEMENTS = dump - IMPLEMENTS = compare - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_missing(grib_accessor*); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_long -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ -} grib_accessor_long; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_long = { - &grib_accessor_class_gen, /* super */ - "long", /* name */ - sizeof(grib_accessor_long), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - &pack_missing, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_long = &_grib_accessor_class_long; - -/* END_CLASS_IMP */ - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - int err = 0; - long val = 0; - size_t l = 1; - char repres[1024]; - char format[32] = "%ld"; - grib_handle* h = grib_handle_of_accessor(a); - - err = grib_unpack_long(a, &val, &l); - /* TODO: We should catch all errors but in this case the test ERA_Gen.sh will fail - * as the output from grib_ls will be different */ - /* if (err) return err; */ - (void)err; - - if ((val == GRIB_MISSING_LONG) && ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0)) { - snprintf(repres, sizeof(repres), "MISSING"); - } else { - size_t size = sizeof(format); - grib_get_string(h, "formatForLongs", format, &size); - snprintf(repres, sizeof(repres), format, val); - } - - l = strlen(repres) + 1; - - if (*len < l) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - /*grib_context_log(a->context,GRIB_LOG_DEBUG, "grib_accessor_long: Casting long %s to string ", a->name);*/ - - *len = l; - - strcpy(v, repres); - return GRIB_SUCCESS; -} - -static int pack_missing(grib_accessor* a) -{ - size_t len = 1; - long value = GRIB_MISSING_LONG; - - if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) - return grib_pack_long(a, &value, &len); - - return GRIB_VALUE_CANNOT_BE_MISSING; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - size_t rlen = 0; - long count = 0; - unsigned long i = 0; - long* values = NULL; - long oneval = 0; - int ret = GRIB_SUCCESS; - - ret = grib_value_count(a, &count); - if (ret) - return ret; - rlen = count; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %lu values", a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - if (rlen == 1) { - ret = grib_unpack_long(a, &oneval, &rlen); - if (ret != GRIB_SUCCESS) - return ret; - *val = oneval; - *len = 1; - return GRIB_SUCCESS; - } - - values = (long*)grib_context_malloc(a->context, rlen * sizeof(long)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - ret = grib_unpack_long(a, values, &rlen); - if (ret != GRIB_SUCCESS) { - grib_context_free(a->context, values); - return ret; - } - for (i = 0; i < rlen; i++) - val[i] = values[i]; - - grib_context_free(a->context, values); - - *len = rlen; - return GRIB_SUCCESS; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - long* aval = 0; - long* bval = 0; - long count = 0; - - size_t alen = 0; - size_t blen = 0; - int err = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (long*)grib_context_malloc(a->context, alen * sizeof(long)); - bval = (long*)grib_context_malloc(b->context, blen * sizeof(long)); - - grib_unpack_long(a, aval, &alen); - grib_unpack_long(b, bval, &blen); - - retval = GRIB_SUCCESS; - for (size_t i=0; icontext, aval); - grib_context_free(b->context, bval); - - return retval; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - long v = 0; /* The converted value */ - - // ECC-1722 - if (STR_EQUAL_NOCASE(val, "missing")) { - return pack_missing(a); - } - - if (string_to_long(val, &v, 1) != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Trying to pack \"%s\" as long. String cannot be converted to an integer", val); - return GRIB_WRONG_TYPE; - } - return grib_pack_long(a, &v, len); -} diff --git a/src/grib_accessor_class_long_vector.cc b/src/grib_accessor_class_long_vector.cc deleted file mode 100644 index 612163a3e..000000000 --- a/src/grib_accessor_class_long_vector.cc +++ /dev/null @@ -1,208 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_long_vector - IMPLEMENTS = init - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double;get_native_type - MEMBERS = const char* vector - MEMBERS = int index - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_long_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; - /* Members defined in long_vector */ - const char* vector; - int index; -} grib_accessor_long_vector; - -extern grib_accessor_class* grib_accessor_class_abstract_long_vector; - -static grib_accessor_class _grib_accessor_class_long_vector = { - &grib_accessor_class_abstract_long_vector, /* super */ - "long_vector", /* name */ - sizeof(grib_accessor_long_vector), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_long_vector = &_grib_accessor_class_long_vector; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_abstract_long_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in abstract_long_vector */ - long* v; - long pack_index; - int number_of_elements; -} grib_accessor_abstract_long_vector; - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_long_vector* self = (grib_accessor_long_vector*)a; - grib_accessor* va = NULL; - grib_accessor_abstract_long_vector* v = NULL; - int n = 0; - - self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - v = (grib_accessor_abstract_long_vector*)va; - - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - - /* check self->index on init and never change it */ - Assert(self->index < v->number_of_elements && self->index >= 0); - - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - size_t size = 0; - int err = 0; - long* vector; - grib_accessor_long_vector* self = (grib_accessor_long_vector*)a; - grib_accessor* va = NULL; - grib_accessor_abstract_long_vector* v = NULL; - - va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - v = (grib_accessor_abstract_long_vector*)va; - - /*TODO implement the dirty mechanism to avoid to unpack every time */ - err = grib_get_size(grib_handle_of_accessor(a), self->vector, &size); - if (err) return err; - DEBUG_ASSERT(size > 0); - vector = (long*)grib_context_malloc(a->context, sizeof(long) * size); - err = grib_unpack_long(va, vector, &size); - grib_context_free(a->context, vector); - if (err) return err; - - *val = v->v[self->index]; - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - long lval = 0; - int err = 0; - grib_accessor_long_vector* self = (grib_accessor_long_vector*)a; - grib_accessor* va = NULL; - grib_accessor_abstract_long_vector* v = NULL; - va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - v = (grib_accessor_abstract_long_vector*)va; - - err = unpack_long(a, &lval, len); - - *val = (double)v->v[self->index]; - - return err; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int err = 0; - grib_accessor_long_vector* self = (grib_accessor_long_vector*)a; - grib_accessor* va = NULL; - grib_accessor_abstract_long_vector* v = NULL; - - va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - v = (grib_accessor_abstract_long_vector*)va; - - v->pack_index = self->index; - - err = grib_pack_long(va, val, len); - - return err; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_lookup.cc b/src/grib_accessor_class_lookup.cc deleted file mode 100644 index 5fc2880a8..000000000 --- a/src/grib_accessor_class_lookup.cc +++ /dev/null @@ -1,242 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long; unpack_string - IMPLEMENTS = init;post_init;dump - IMPLEMENTS = byte_offset;byte_count - IMPLEMENTS = pack_long - IMPLEMENTS = notify_change - MEMBERS = long llength - MEMBERS = long loffset - MEMBERS = grib_expression* real_name - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void post_init(grib_accessor*); -static int notify_change(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_lookup -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in lookup */ - long llength; - long loffset; - grib_expression* real_name; -} grib_accessor_lookup; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_lookup = { - &grib_accessor_class_long, /* super */ - "lookup", /* name */ - sizeof(grib_accessor_lookup), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - &post_init, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - ¬ify_change, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_lookup = &_grib_accessor_class_lookup; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - a->length = 0; - self->llength = len; - self->loffset = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 0); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - self->real_name = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 1); -} - -static void post_init(grib_accessor* a) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - if (self->real_name) { - grib_dependency_observe_expression(a, self->real_name); - } -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - unsigned char bytes[1024] = {0,}; - char msg[1024] = {0,}; - char buf[2048]; - int i; - unsigned long v = 0; - - size_t llen = self->llength; - grib_unpack_bytes(a, bytes, &llen); /* TODO: Unpack byte unpack the wrong offset */ - - bytes[llen] = 0; - for (i = 0; i < llen; i++) { - msg[i] = isprint(bytes[i]) ? bytes[i] : '?'; - v <<= 8; - v |= bytes[i]; - } - - msg[llen] = 0; - - snprintf(buf, sizeof(buf), "%s %lu %ld-%ld", msg, v, (long)a->offset + self->loffset, (long)self->llength); - - grib_dump_long(dumper, a, buf); -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - unsigned char bytes[1024] = {0,}; - int i; - - size_t llen = self->llength; - grib_unpack_bytes(a, bytes, &llen); /* TODO: Unpack byte unpack the wrong offset */ - - bytes[llen] = 0; - - for (i = 0; i < llen; i++) { - v[i] = isprint(bytes[i]) ? bytes[i] : '?'; - } - - v[llen] = 0; - if (llen == 1 && v[0] == '?') { - /* Try unpack as long */ - size_t length = 10; - long lval = 0; - int err = unpack_long(a, &lval, &length); - if (!err) { - char str[5]; - int conv = snprintf(str, sizeof(str), "%ld", lval); - if (conv == 1) { - v[0] = str[0]; - } - } - } - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - grib_handle* h = grib_handle_of_accessor(a); - - long pos = (a->offset + self->loffset) * 8; - - if (len[0] < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - len[0] = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - /* This is used when reparsing or rebuilding */ - if (h->loader) { - Assert(*len == 1); - return h->loader->lookup_long(h->context, h->loader, a->name, val); - } - - val[0] = grib_decode_unsigned_long(h->buffer->data, &pos, self->llength * 8); - len[0] = 1; - - /*printf("###########lookup unpack_long: %s %ld %ld\n",a->name, pos/8, val[0]);*/ - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static long byte_count(grib_accessor* a) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - return self->llength; -} - -static long byte_offset(grib_accessor* a) -{ - grib_accessor_lookup* self = (grib_accessor_lookup*)a; - return self->loffset; -} - -static int notify_change(grib_accessor* self, grib_accessor* changed) -{ - /* Forward changes */ - return grib_dependency_notify_change(self); -} diff --git a/src/grib_accessor_class_mars_param.cc b/src/grib_accessor_class_mars_param.cc deleted file mode 100644 index beb7a68c5..000000000 --- a/src/grib_accessor_class_mars_param.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string - IMPLEMENTS = init; string_length - MEMBERS= const char* paramId - MEMBERS= const char* table - MEMBERS= const char* param - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_mars_param -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in mars_param */ - const char* paramId; - const char* table; - const char* param; -} grib_accessor_mars_param; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_mars_param = { - &grib_accessor_class_ascii, /* super */ - "mars_param", /* name */ - sizeof(grib_accessor_mars_param), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_mars_param = &_grib_accessor_class_mars_param; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_mars_param* self = (grib_accessor_mars_param*)a; - self->paramId = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->table = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->param = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -// For an implementation of pack_string, see -// src/deprecated/grib_accessor_class_mars_param.cc - -// For an alternative implementation of unpack_string, see -// src/deprecated/grib_accessor_class_mars_param.cc -// -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_mars_param* self = (grib_accessor_mars_param*)a; - long param = 0; - long table = 0; - int ret = 0; - - if (self->table != NULL && (ret = grib_get_long_internal(grib_handle_of_accessor(a), self->table, &table)) != GRIB_SUCCESS) - return ret; - if (self->param != NULL && (ret = grib_get_long_internal(grib_handle_of_accessor(a), self->param, ¶m)) != GRIB_SUCCESS) - return ret; - - /*if (table==200) table=128;*/ - snprintf(val, 32, "%ld.%ld", param, table); - *len = strlen(val) + 1; - - return GRIB_SUCCESS; -} - -static size_t string_length(grib_accessor* a) -{ - return 7; -} diff --git a/src/grib_accessor_class_mars_step.cc b/src/grib_accessor_class_mars_step.cc deleted file mode 100644 index 7792995a7..000000000 --- a/src/grib_accessor_class_mars_step.cc +++ /dev/null @@ -1,218 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = pack_string;unpack_string;value_count;string_length - IMPLEMENTS = pack_long; unpack_long - IMPLEMENTS = get_native_type - IMPLEMENTS = init - MEMBERS = const char* stepRange - MEMBERS = const char* stepType - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_mars_step -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in mars_step */ - const char* stepRange; - const char* stepType; -} grib_accessor_mars_step; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_mars_step = { - &grib_accessor_class_ascii, /* super */ - "mars_step", /* name */ - sizeof(grib_accessor_mars_step), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_mars_step = &_grib_accessor_class_mars_step; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_mars_step* self = (grib_accessor_mars_step*)a; - self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->stepType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - char stepType[100]; - size_t stepTypeLen = 100; - char buf[100] = {0,}; - int ret; - grib_accessor_mars_step* self = (grib_accessor_mars_step*)a; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); - - if (!stepRangeAcc) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s not found", self->stepRange); - return GRIB_NOT_FOUND; - } - - if ((ret = grib_get_string(grib_handle_of_accessor(a), self->stepType, stepType, &stepTypeLen)) != GRIB_SUCCESS) - return ret; - - if (!strcmp(stepType, "instant")) - snprintf(buf, sizeof(buf), "%s", val); - else - snprintf(buf, sizeof(buf), "0-%s", val); - - return grib_pack_string(stepRangeAcc, buf, len); -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - int ret = 0; - grib_accessor_mars_step* self = (grib_accessor_mars_step*)a; - char buf[100] = {0,}; - char* p = NULL; - size_t buflen = 100; - long step; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); - const char* cclass_name = a->cclass->name; - - if (!stepRangeAcc) { - grib_context_log(a->context, GRIB_LOG_ERROR, "%s: %s not found", cclass_name, self->stepRange); - return GRIB_NOT_FOUND; - } - - if ((ret = grib_unpack_string(stepRangeAcc, buf, &buflen)) != GRIB_SUCCESS) - return ret; - - if (*len < buflen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, buflen, *len); - *len = buflen; - return GRIB_BUFFER_TOO_SMALL; - } - - strcpy(val, buf); - step = strtol(buf, &p, 10); - - if (p != NULL && *p == '-' && step == 0) - strcpy(val, ++p); - - *len = strlen(val); - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - char buff[100] = {0,}; - size_t bufflen = 100; - - snprintf(buff, sizeof(buff), "%ld", *val); - - return pack_string(a, buff, &bufflen); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_mars_step* self = (grib_accessor_mars_step*)a; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); - - if (!stepRangeAcc) - return GRIB_NOT_FOUND; - - return grib_unpack_long(stepRangeAcc, val, len); -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 16; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_message.cc b/src/grib_accessor_class_message.cc deleted file mode 100644 index 8dd580d3e..000000000 --- a/src/grib_accessor_class_message.cc +++ /dev/null @@ -1,166 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bytes - IMPLEMENTS = init;update_size;resize; value_count - IMPLEMENTS = unpack_string; string_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static void resize(grib_accessor*,size_t); - -typedef struct grib_accessor_message -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in message */ -} grib_accessor_message; - -extern grib_accessor_class* grib_accessor_class_bytes; - -static grib_accessor_class _grib_accessor_class_message = { - &grib_accessor_class_bytes, /* super */ - "message", /* name */ - sizeof(grib_accessor_message), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - &resize, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_message = &_grib_accessor_class_message; - -/* END_CLASS_IMP */ - - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = grib_handle_of_accessor(a)->buffer->ulength - len - a->offset; -} - -// static int compare(grib_accessor* a, grib_accessor* b) -// { -// if (a->length != b->length) -// return GRIB_COUNT_MISMATCH; -// return GRIB_SUCCESS; -// } - -static void update_size(grib_accessor* a, size_t new_size) -{ - a->length = new_size; -} - -static void resize(grib_accessor* a, size_t new_size) -{ - grib_context_log(a->context, GRIB_LOG_FATAL, "%s %s: Not supported", a->cclass->name, __func__); - - // void* zero = grib_context_malloc_clear(a->context, new_size); - // grib_buffer_replace(a, (const unsigned char*)zero, new_size, 1, 0); - // grib_context_free(a->context, zero); - // grib_context_log(a->context, GRIB_LOG_DEBUG, "resize: grib_accessor_class_message %ld %ld %s %s", - // (long)new_size, (long)a->length, a->cclass->name, a->name); - // Assert(new_size == a->length); -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long i = 0; - size_t l = a->length + 1; - grib_handle* h = grib_handle_of_accessor(a); - - if (*len < l) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - a->cclass->name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) - val[i] = h->buffer->data[a->offset + i]; - val[i] = 0; - *len = i; - return GRIB_SUCCESS; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} diff --git a/src/grib_accessor_class_message_copy.cc b/src/grib_accessor_class_message_copy.cc deleted file mode 100644 index 30806b163..000000000 --- a/src/grib_accessor_class_message_copy.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string;string_length - IMPLEMENTS = byte_count - IMPLEMENTS = init;dump;get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long byte_count(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_message_copy -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in message_copy */ -} grib_accessor_message_copy; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_message_copy = { - &grib_accessor_class_gen, /* super */ - "message_copy", /* name */ - sizeof(grib_accessor_message_copy), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_message_copy = &_grib_accessor_class_message_copy; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long length, grib_arguments* args) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - size_t slen = grib_handle_of_accessor(a)->buffer->ulength; - size_t i; - unsigned char* v = 0; - - if (*len < slen) { - return GRIB_ARRAY_TOO_SMALL; - } - v = grib_handle_of_accessor(a)->buffer->data; - /* replace unprintable characters with space */ - for (i = 0; i < slen; i++) - if (v[i] > 126) - v[i] = 32; - memcpy(val, grib_handle_of_accessor(a)->buffer->data, slen); - val[i] = 0; - - *len = slen; - - return GRIB_SUCCESS; -} - -static size_t string_length(grib_accessor* a) -{ - return grib_handle_of_accessor(a)->buffer->ulength; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} diff --git a/src/grib_accessor_class_multdouble.cc b/src/grib_accessor_class_multdouble.cc deleted file mode 100644 index ac5771627..000000000 --- a/src/grib_accessor_class_multdouble.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS = const char* val - MEMBERS = double multiplier - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_multdouble -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in multdouble */ - const char* val; - double multiplier; -} grib_accessor_multdouble; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_multdouble = { - &grib_accessor_class_double, /* super */ - "multdouble", /* name */ - sizeof(grib_accessor_multdouble), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_multdouble = &_grib_accessor_class_multdouble; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_multdouble* self = (grib_accessor_multdouble*)a; - int n = 0; - - self->val = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->multiplier = grib_arguments_get_double(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - const grib_accessor_multdouble* self = (grib_accessor_multdouble*)a; - int ret = GRIB_SUCCESS; - double value = 0; - - ret = grib_get_double_internal(grib_handle_of_accessor(a), self->val, &value); - if (ret != GRIB_SUCCESS) - return ret; - - *val = value * self->multiplier; - - *len = 1; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_nearest.cc b/src/grib_accessor_class_nearest.cc deleted file mode 100644 index b1a3138d3..000000000 --- a/src/grib_accessor_class_nearest.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - MEMBERS=grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_nearest -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in nearest */ - grib_arguments* args; -} grib_accessor_nearest; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_nearest = { - &grib_accessor_class_gen, /* super */ - "nearest", /* name */ - sizeof(grib_accessor_nearest), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_nearest = &_grib_accessor_class_nearest; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - grib_accessor_nearest* self = (grib_accessor_nearest*)a; - self->args = args; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - /* TODO: pass args */ - grib_dump_label(dumper, a, NULL); -} - -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; - *error = GRIB_NOT_IMPLEMENTED; - a = grib_find_accessor(h, "NEAREST"); - na = (grib_accessor_nearest*)a; - - if (!a) - return NULL; - - n = grib_nearest_factory(h, na->args, error); - - if (n) - *error = GRIB_SUCCESS; - - return n; -} diff --git a/src/grib_accessor_class_non_alpha.cc b/src/grib_accessor_class_non_alpha.cc deleted file mode 100644 index 821f2311f..000000000 --- a/src/grib_accessor_class_non_alpha.cc +++ /dev/null @@ -1,215 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_non_alpha -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in non_alpha */ -} grib_accessor_non_alpha; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_non_alpha = { - &grib_accessor_class_gen, /* super */ - "non_alpha", /* name */ - sizeof(grib_accessor_non_alpha), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_non_alpha = &_grib_accessor_class_non_alpha; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; - size_t i = 0; - unsigned char* v; - - v = buffer->data + a->offset; - i = 0; - while ((*v < 33 || *v > 126) && i <= buffer->ulength) { - v++; - i++; - } - a->length = i; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - return a->length; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_handle* hand = grib_handle_of_accessor(a); - long i = 0; - - if (*len < (a->length + 1)) { - grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", - *len, a->name, a->length + 1); - *len = a->length + 1; - return GRIB_BUFFER_TOO_SMALL; - } - - for (i = 0; i < a->length; i++) { - val[i] = hand->buffer->data[a->offset + i]; - } - val[i] = 0; - *len = i; - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - size_t i = 0; - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - i = 0; - while (i < l - 1 && val[i] == ' ') - i++; - - if (val[i] == 0) { - *v = 0; - return 0; - } - if (val[i + 1] == ' ' && i < l - 2) - val[i + 1] = 0; - - *v = strtol(val, &last, 10); - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - char val[1024]; - size_t l = sizeof(val); - char* last = NULL; - grib_unpack_string(a, val, &l); - - *v = strtod(val, &last); - - if (*last == 0) { - return GRIB_SUCCESS; - } - - return GRIB_NOT_IMPLEMENTED; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/grib_accessor_class_number_of_coded_values.cc b/src/grib_accessor_class_number_of_coded_values.cc deleted file mode 100644 index 14ef832d7..000000000 --- a/src/grib_accessor_class_number_of_coded_values.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/***************************** - * Enrico Fucile - ****************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* numberOfValues - MEMBERS = const char* bitsPerValue - MEMBERS = const char* offsetBeforeData - MEMBERS = const char* offsetAfterData - MEMBERS = const char* unusedBits - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_coded_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in number_of_coded_values */ - const char* numberOfValues; - const char* bitsPerValue; - const char* offsetBeforeData; - const char* offsetAfterData; - const char* unusedBits; -} grib_accessor_number_of_coded_values; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_number_of_coded_values = { - &grib_accessor_class_long, /* super */ - "number_of_coded_values", /* name */ - sizeof(grib_accessor_number_of_coded_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_number_of_coded_values = &_grib_accessor_class_number_of_coded_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_number_of_coded_values* self = (grib_accessor_number_of_coded_values*)a; - self->bitsPerValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetBeforeData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->offsetAfterData = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->unusedBits = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->numberOfValues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = GRIB_SUCCESS; - long bpv = 0; - long offsetBeforeData = 0, offsetAfterData = 0, unusedBits = 0, numberOfValues; - - grib_accessor_number_of_coded_values* self = (grib_accessor_number_of_coded_values*)a; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitsPerValue, &bpv)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetBeforeData, &offsetBeforeData)) != GRIB_SUCCESS) - return ret; - - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetAfterData, &offsetAfterData)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->unusedBits, &unusedBits)) != GRIB_SUCCESS) - return ret; - - if (bpv != 0) { - grib_context_log(a->context, GRIB_LOG_DEBUG, "grib_accessor_number_of_coded_values: offsetAfterData=%ld offsetBeforeData=%ld unusedBits=%ld bpv=%ld\n", - offsetAfterData, offsetBeforeData, unusedBits, bpv); - DEBUG_ASSERT(offsetAfterData > offsetBeforeData); - *val = ((offsetAfterData - offsetBeforeData) * 8 - unusedBits) / bpv; - } - else { - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfValues, &numberOfValues)) != GRIB_SUCCESS) - return ret; - - *val = numberOfValues; - } - - return ret; -} diff --git a/src/grib_accessor_class_number_of_points.cc b/src/grib_accessor_class_number_of_points.cc deleted file mode 100644 index b3d1eade2..000000000 --- a/src/grib_accessor_class_number_of_points.cc +++ /dev/null @@ -1,174 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/**************************************** - * Enrico Fucile - *************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* ni - MEMBERS = const char* nj - MEMBERS = const char* plpresent - MEMBERS = const char* pl - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_points -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in number_of_points */ - const char* ni; - const char* nj; - const char* plpresent; - const char* pl; -} grib_accessor_number_of_points; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_number_of_points = { - &grib_accessor_class_long, /* super */ - "number_of_points", /* name */ - sizeof(grib_accessor_number_of_points), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_number_of_points = &_grib_accessor_class_number_of_points; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_accessor_number_of_points* self = (grib_accessor_number_of_points*)a; - self->ni = grib_arguments_get_name(hand, c, n++); - self->nj = grib_arguments_get_name(hand, c, n++); - self->plpresent = grib_arguments_get_name(hand, c, n++); - self->pl = grib_arguments_get_name(hand, c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_number_of_points* self = (grib_accessor_number_of_points*)a; - - int ret = GRIB_SUCCESS; - long ni = 0, nj = 0, plpresent = 0; - size_t plsize = 0; - long* pl = NULL; - int i = 0; - grib_context* c = a->context; - grib_handle* hand = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(hand, self->ni, &ni)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(hand, self->nj, &nj)) != GRIB_SUCCESS) - return ret; - - if (self->plpresent && - ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS)) - return ret; - - if (grib_is_missing(hand, self->nj, &ret) && ret == GRIB_SUCCESS) { - grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 'missing'!", self->nj); - return GRIB_GEOCALCULUS_PROBLEM; - } - - if (nj == 0) { - grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_class_number_of_points: Key %s cannot be 0!", self->nj); - return GRIB_GEOCALCULUS_PROBLEM; - } - - if (plpresent) { - /*reduced*/ - plsize = nj; - pl = (long*)grib_context_malloc(c, sizeof(long) * plsize); - grib_get_long_array_internal(hand, self->pl, pl, &plsize); - *val = 0; - for (i = 0; i < plsize; i++) - *val += pl[i]; - grib_context_free(c, pl); - } - else { - /*regular*/ - *val = ni * nj; - } - - return ret; -} diff --git a/src/grib_accessor_class_number_of_values.cc b/src/grib_accessor_class_number_of_values.cc deleted file mode 100644 index fb1aff779..000000000 --- a/src/grib_accessor_class_number_of_values.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/********************************** - * Enrico Fucile - **********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* bitsPerValue - MEMBERS = const char* numberOfPoints - MEMBERS = const char* bitmapPresent - MEMBERS = const char* bitmap - MEMBERS = const char* numberOfCodedValues - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in number_of_values */ - const char* values; - const char* bitsPerValue; - const char* numberOfPoints; - const char* bitmapPresent; - const char* bitmap; - const char* numberOfCodedValues; -} grib_accessor_number_of_values; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_number_of_values = { - &grib_accessor_class_long, /* super */ - "number_of_values", /* name */ - sizeof(grib_accessor_number_of_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_number_of_values = &_grib_accessor_class_number_of_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - int n = 0; - grib_accessor_number_of_values* self = (grib_accessor_number_of_values*)a; - grib_handle* hand = grib_handle_of_accessor(a); - - self->values = grib_arguments_get_name(hand, c, n++); - self->bitsPerValue = grib_arguments_get_name(hand, c, n++); - self->numberOfPoints = grib_arguments_get_name(hand, c, n++); - self->bitmapPresent = grib_arguments_get_name(hand, c, n++); - self->bitmap = grib_arguments_get_name(hand, c, n++); - self->numberOfCodedValues = grib_arguments_get_name(hand, c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_number_of_values* self = (grib_accessor_number_of_values*)a; - int ret = GRIB_SUCCESS, i; - long npoints = 0, bitmap_present = 0; - size_t size = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &npoints)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->bitmapPresent, &bitmap_present)) != GRIB_SUCCESS) - return ret; - - if (bitmap_present) { - double* bitmap; - size = npoints; - bitmap = (double*)grib_context_malloc(a->context, sizeof(double) * size); - if ((ret = grib_get_double_array_internal(grib_handle_of_accessor(a), self->bitmap, bitmap, &size)) != GRIB_SUCCESS) { - grib_context_free(a->context, bitmap); - return ret; - } - *val = 0; - for (i = 0; i < size; i++) - if (bitmap[i] != 0) - (*val)++; - - grib_context_free(a->context, bitmap); - } - else { - *val = npoints; - } - - return ret; -} diff --git a/src/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/grib_accessor_class_number_of_values_data_raw_packing.cc deleted file mode 100644 index 5bde2a163..000000000 --- a/src/grib_accessor_class_number_of_values_data_raw_packing.cc +++ /dev/null @@ -1,166 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ -/***************************** - * Enrico Fucile - ****************************/ - -#include "grib_api_internal.h" -#define PRECISION_32_IEEE 1 -#define PRECISION_64_IEEE 2 -#define PRECISION_128_IEEE 3 - -#define COMPRESSION_NONE 0 -#define COMPRESSION_LZW 1 - -#define PRE_PROCESSING_NONE 0 -#define PRE_PROCESSING_DIFFERENCE 1 -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - MEMBERS=const char* values - MEMBERS=const char* precision - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_number_of_values_data_raw_packing -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in number_of_values_data_raw_packing */ - const char* values; - const char* precision; -} grib_accessor_number_of_values_data_raw_packing; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_number_of_values_data_raw_packing = { - &grib_accessor_class_gen, /* super */ - "number_of_values_data_raw_packing", /* name */ - sizeof(grib_accessor_number_of_values_data_raw_packing), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_number_of_values_data_raw_packing = &_grib_accessor_class_number_of_values_data_raw_packing; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long v, grib_arguments* args) -{ - int n = 0; - grib_accessor_number_of_values_data_raw_packing* self = (grib_accessor_number_of_values_data_raw_packing*)a; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->precision = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int err = 0; - grib_accessor_number_of_values_data_raw_packing* self = (grib_accessor_number_of_values_data_raw_packing*)a; - grib_accessor* adata = NULL; - long precision = 0; - int bytes = 0; - long byte_count = 0; - - adata = grib_find_accessor(grib_handle_of_accessor(a), self->values); - Assert(adata != NULL); - byte_count = grib_byte_count(adata); - - if ((err = grib_get_long_internal(grib_handle_of_accessor(a), self->precision, &precision)) != GRIB_SUCCESS) - return err; - - switch (precision) { - case 1: - bytes = 4; - break; - - case 2: - bytes = 8; - break; - - default: - return GRIB_NOT_IMPLEMENTED; - break; - } - - *val = byte_count / bytes; - - return err; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_octahedral_gaussian.cc b/src/grib_accessor_class_octahedral_gaussian.cc deleted file mode 100644 index 8035c9ab0..000000000 --- a/src/grib_accessor_class_octahedral_gaussian.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - IMPLEMENTS = pack_long - MEMBERS=const char* N - MEMBERS=const char* Ni - MEMBERS=const char* plpresent - MEMBERS=const char* pl - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_octahedral_gaussian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in octahedral_gaussian */ - const char* N; - const char* Ni; - const char* plpresent; - const char* pl; -} grib_accessor_octahedral_gaussian; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_octahedral_gaussian = { - &grib_accessor_class_long, /* super */ - "octahedral_gaussian", /* name */ - sizeof(grib_accessor_octahedral_gaussian), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_octahedral_gaussian = &_grib_accessor_class_octahedral_gaussian; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_octahedral_gaussian* self = (grib_accessor_octahedral_gaussian*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - self->N = grib_arguments_get_name(hand, c, n++); - self->Ni = grib_arguments_get_name(hand, c, n++); - self->plpresent = grib_arguments_get_name(hand, c, n++); - self->pl = grib_arguments_get_name(hand, c, n++); -} - -/* Returns 1 (=true) if input pl array is Octahedral, 0 otherwise. - * Possible cases for the deltas in an octahedral pl array: - * +4 .. +4 Top part, above equator - * +4 .. 0 Top part, above and including equator - * +4.. 0 -4.. Middle part, above, equator and below - * 0 -4.. Equator and below - * -4 ..-4 All below equator - * Anything else is considered not octahedral - */ -static int is_pl_octahedral(const long pl[], size_t size) -{ - long i; - long prev_diff = -1; - for (i = 1; i < size; ++i) { - const long diff = pl[i] - pl[i - 1]; - if (diff == 0) { - /* prev must be +4 or undef */ - if (!(prev_diff == +4 || i == 1)) { - return 0; - } - } - else { - if (labs(diff) != 4) { - return 0; - } - if (diff == +4) { - /* prev must be +4 or undef */ - if (!(prev_diff == +4 || i == 1)) { - return 0; - } - } - if (diff == -4) { - /* prev must be 0, -4 or undef */ - if (!(prev_diff == -4 || prev_diff == 0 || i == 1)) { - return 0; - } - } - } - prev_diff = diff; - } - return 1; /* it's octahedral */ -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_octahedral_gaussian* self = (grib_accessor_octahedral_gaussian*)a; - int ret = GRIB_SUCCESS; - long Ni; - long plpresent = 0; - long* pl = NULL; /* pl array */ - size_t plsize = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_context* c = a->context; - - if ((ret = grib_get_long_internal(hand, self->Ni, &Ni)) != GRIB_SUCCESS) - return ret; - - /* If Ni is not missing, then this is a plain gaussian grid and not reduced. */ - /* So it cannot be an octahedral grid */ - if (Ni != GRIB_MISSING_LONG) { - *val = 0; - return GRIB_SUCCESS; - } - - if ((ret = grib_get_long_internal(hand, self->plpresent, &plpresent)) != GRIB_SUCCESS) - return ret; - if (!plpresent) { - *val = 0; /* Not octahedral */ - return GRIB_SUCCESS; - } - - if ((ret = grib_get_size(hand, self->pl, &plsize)) != GRIB_SUCCESS) - return ret; - Assert(plsize); /* pl array must have at least one element */ - - pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize); - if (!pl) { - return GRIB_OUT_OF_MEMORY; - } - if ((ret = grib_get_long_array_internal(hand, self->pl, pl, &plsize)) != GRIB_SUCCESS) - return ret; - - /* pl[0] is guaranteed to exist. Have already asserted previously */ - *val = is_pl_octahedral(pl, plsize); - grib_context_free(c, pl); - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} diff --git a/src/grib_accessor_class_octet_number.cc b/src/grib_accessor_class_octet_number.cc deleted file mode 100644 index cce0e742b..000000000 --- a/src/grib_accessor_class_octet_number.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init - MEMBERS=const char* left - MEMBERS=long right - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_octet_number -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in octet_number */ - const char* left; - long right; -} grib_accessor_octet_number; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_octet_number = { - &grib_accessor_class_long, /* super */ - "octet_number", /* name */ - sizeof(grib_accessor_octet_number), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_octet_number = &_grib_accessor_class_octet_number; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_octet_number* self = (grib_accessor_octet_number*)a; - - int n = 0; - self->left = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->right = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_octet_number* self = (grib_accessor_octet_number*)a; - int ret = GRIB_SUCCESS; - long offset; - - offset = a->offset + self->right; - - if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->left, offset)) != GRIB_SUCCESS) - return ret; - - *val = offset; - *len = 1; - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_offset_file.cc b/src/grib_accessor_class_offset_file.cc deleted file mode 100644 index 8fd0a0018..000000000 --- a/src/grib_accessor_class_offset_file.cc +++ /dev/null @@ -1,141 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string - IMPLEMENTS = init - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_offset_file -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in offset_file */ -} grib_accessor_offset_file; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_offset_file = { - &grib_accessor_class_double, /* super */ - "offset_file", /* name */ - sizeof(grib_accessor_offset_file), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_offset_file = &_grib_accessor_class_offset_file; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - *val = (double)grib_handle_of_accessor(a)->offset; - *len = 1; - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* v, size_t* len) -{ - double val = 0; - size_t l = 1; - char repres[1024] = {0,}; - int err = 0; - const char* cclass_name = a->cclass->name; - - err = grib_unpack_double(a, &val, &l); - if (err) return err; - - snprintf(repres, sizeof(repres), "%.0f", val); - - l = strlen(repres) + 1; - if (l > *len) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, l, *len); - *len = l; - return GRIB_BUFFER_TOO_SMALL; - } - grib_context_log(a->context, GRIB_LOG_DEBUG, "%s: Casting double %s to string", __func__, a->name); - - *len = l; - - strcpy(v, repres); - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_offset_values.cc b/src/grib_accessor_class_offset_values.cc deleted file mode 100644 index 012698f79..000000000 --- a/src/grib_accessor_class_offset_values.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/********************************** - * Enrico Fucile - *********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; pack_double - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* missingValue - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_offset_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in offset_values */ - const char* values; - const char* missingValue; -} grib_accessor_offset_values; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_offset_values = { - &grib_accessor_class_double, /* super */ - "offset_values", /* name */ - sizeof(grib_accessor_offset_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_offset_values = &_grib_accessor_class_offset_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_offset_values* self = (grib_accessor_offset_values*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - int ret = 0; - *val = 0; - *len = 1; - return ret; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - double* values = NULL; - size_t size = 0; - double missingValue = 0; - long missingValuesPresent = 0; - int ret = 0, i = 0; - grib_accessor_offset_values* self = (grib_accessor_offset_values*)a; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (*val == 0) - return GRIB_SUCCESS; - - if ((ret = grib_get_double_internal(h, self->missingValue, &missingValue)) != GRIB_SUCCESS) { - return ret; - } - if ((ret = grib_get_long_internal(h, "missingValuesPresent", &missingValuesPresent)) != GRIB_SUCCESS) { - return ret; - } - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - for (i = 0; i < size; i++) { - if (missingValuesPresent) { - if (values[i] != missingValue) - values[i] += *val; - } - else { - values[i] += *val; - } - } - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) - return ret; - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_optimal_step_units.cc b/src/grib_accessor_class_optimal_step_units.cc deleted file mode 100644 index 9bcf338be..000000000 --- a/src/grib_accessor_class_optimal_step_units.cc +++ /dev/null @@ -1,287 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include "step.h" -#include "step_utilities.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = pack_long;unpack_long;dump - IMPLEMENTS = pack_string;unpack_string;dump - IMPLEMENTS = string_length;pack_expression;get_native_type;is_missing - IMPLEMENTS = init - MEMBERS = const char* forecast_time_value - MEMBERS = const char* forecast_time_unit - MEMBERS = const char* time_range_value - MEMBERS = const char* time_range_unit - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int is_missing(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int pack_expression(grib_accessor*, grib_expression*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_optimal_step_units -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in optimal_step_units */ - const char* forecast_time_value; - const char* forecast_time_unit; - const char* time_range_value; - const char* time_range_unit; -} grib_accessor_optimal_step_units; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_optimal_step_units = { - &grib_accessor_class_gen, /* super */ - "optimal_step_units", /* name */ - sizeof(grib_accessor_optimal_step_units), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - &pack_expression, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_optimal_step_units = &_grib_accessor_class_optimal_step_units; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_optimal_step_units* self = (grib_accessor_optimal_step_units*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->forecast_time_value = grib_arguments_get_name(hand, c, n++); - self->forecast_time_unit = grib_arguments_get_name(hand, c, n++); - self->time_range_value = grib_arguments_get_name(hand, c, n++); - self->time_range_unit = grib_arguments_get_name(hand, c, n++); - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static size_t string_length(grib_accessor* a) -{ - return 255; -} - -static int pack_expression(grib_accessor* a, grib_expression* e) -{ - const char* cval = NULL; - int ret = 0; - long lval = 0; - size_t len = 1; - grib_handle* hand = grib_handle_of_accessor(a); - const char* cclass_name = a->cclass->name; - - if (strcmp(e->cclass->name, "long") == 0) { - grib_expression_evaluate_long(hand, e, &lval); /* TODO: check return value */ - ret = grib_pack_long(a, &lval, &len); - } - else { - char tmp[1024]; - len = sizeof(tmp); - cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); - if (ret != GRIB_SUCCESS) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s.%s: Unable to evaluate string %s to be set in %s", - cclass_name, __func__, grib_expression_get_name(e), a->name); - return ret; - } - len = strlen(cval) + 1; - //if (hand->context->debug) - // printf("ECCODES DEBUG grib_accessor_class_codetable::pack_expression %s %s\n", a->name, cval); - ret = grib_pack_string(a, cval, &len); - } - return ret; -} - -static long staticStepUnits = eccodes::Unit{eccodes::Unit::Value::MISSING}.value(); -static long staticForceStepUnits = eccodes::Unit{eccodes::Unit::Value::MISSING}.value(); - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_handle* h = grib_handle_of_accessor(a); - auto supported_units = eccodes::Unit::list_supported_units(); - try { - eccodes::Unit unit{*val}; // throws if not supported - auto iter = std::find(supported_units.begin(), supported_units.end(), unit); - if (iter == supported_units.end()) { - throw std::runtime_error{"eccodes::Unit not supported"}; - } - } - catch (std::exception& e) { - std::string supported_units_str; - for (auto& u : supported_units) - supported_units_str += eccodes::Unit{u}.value() + ","; - supported_units_str.pop_back(); - - std::string msg = std::string{"Invalid unit: "} + std::to_string(*val) + " (" + e.what() + ")" + - ". Available units are: " + supported_units_str; - grib_context_log(a->context, GRIB_LOG_ERROR, msg.c_str()); - return GRIB_INVALID_ARGUMENT; - } - - int ret; - staticStepUnits = *val; - if ((ret = grib_set_long_internal(h, "forceStepUnits", *val)) != GRIB_SUCCESS) { - return ret; - } - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - try { - if (eccodes::Unit{staticStepUnits} != eccodes::Unit{eccodes::Unit::Value::MISSING}) { - *val = staticStepUnits; - return GRIB_SUCCESS; - } - - const grib_accessor_optimal_step_units* self = (grib_accessor_optimal_step_units*)a; - grib_handle* h = grib_handle_of_accessor(a); - - auto forecast_time_opt = get_step(h, self->forecast_time_value, self->forecast_time_unit); - auto time_range_opt = get_step(h, self->time_range_value, self->time_range_unit); - - if (forecast_time_opt && time_range_opt) { - auto [step_a, step_b] = find_common_units(forecast_time_opt.value().optimize_unit(), - (forecast_time_opt.value() + time_range_opt.value()).optimize_unit()); - *val = step_a.unit().value(); - } - else if (forecast_time_opt && !time_range_opt) { - *val = forecast_time_opt.value().optimize_unit().unit().value(); - } - else if (!forecast_time_opt && time_range_opt) { - *val = time_range_opt.value().optimize_unit().unit().value(); - } - else if (!forecast_time_opt && !time_range_opt) { - *val = eccodes::Unit{eccodes::Unit::Value::HOUR}.value(); - } - } - catch (std::exception& e) { - grib_context_log(a->context, GRIB_LOG_ERROR, e.what()); - return GRIB_INTERNAL_ERROR; - } - - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - try { - long unit = eccodes::Unit{val}.value(); - pack_long(a, &unit, len); - } - catch (std::exception& e) { - auto supported_units = eccodes::Unit::list_supported_units(); - std::string supported_units_str; - for (auto& u : supported_units) - supported_units_str += eccodes::Unit{u}.value() + ","; - supported_units_str.pop_back(); - - std::string msg = "Invalid unit: " + std::string(val) + " (" + e.what() + ")" + ". Available units are: " + supported_units_str; - grib_context_log(a->context, GRIB_LOG_ERROR, msg.c_str()); - return GRIB_INVALID_ARGUMENT; - } - - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - int ret = 0; - long unit = 0; - size_t unit_len = 0; - if ((ret = unpack_long(a, &unit, &unit_len)) != GRIB_SUCCESS) - return ret; - *len = snprintf(val, *len, "%s", eccodes::Unit{unit}.value().c_str()); - return GRIB_SUCCESS; -} - -// Step units are never missing -// If the user does not specify a step unit, we default to hours -static int is_missing(grib_accessor* a) -{ - return 0; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_pack_bufr_values.cc b/src/grib_accessor_class_pack_bufr_values.cc deleted file mode 100644 index a076e12ac..000000000 --- a/src/grib_accessor_class_pack_bufr_values.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - IMPLEMENTS = unpack_string;unpack_string_array;unpack_long; unpack_double - IMPLEMENTS = pack_long; pack_double - IMPLEMENTS = value_count; destroy; get_native_type; - MEMBERS = grib_accessor* data_accessor - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_pack_bufr_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in pack_bufr_values */ - grib_accessor* data_accessor; -} grib_accessor_pack_bufr_values; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_pack_bufr_values = { - &grib_accessor_class_gen, /* super */ - "pack_bufr_values", /* name */ - sizeof(grib_accessor_pack_bufr_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_pack_bufr_values = &_grib_accessor_class_pack_bufr_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - char* key; - grib_accessor_pack_bufr_values* self = (grib_accessor_pack_bufr_values*)a; - key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); - self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static void destroy(grib_context* context, grib_accessor* a) -{ -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_pack_bufr_values* self = (grib_accessor_pack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_pack_double(data, 0, 0); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_pack_bufr_values* self = (grib_accessor_pack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_pack_double(data, 0, 0); -} diff --git a/src/grib_accessor_class_packing_type.cc b/src/grib_accessor_class_packing_type.cc deleted file mode 100644 index a9a4a2deb..000000000 --- a/src/grib_accessor_class_packing_type.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = string_length - IMPLEMENTS = get_native_type - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* packing_type - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_packing_type -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in packing_type */ - const char* values; - const char* packing_type; -} grib_accessor_packing_type; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_packing_type = { - &grib_accessor_class_gen, /* super */ - "packing_type", /* name */ - sizeof(grib_accessor_packing_type), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_packing_type = &_grib_accessor_class_packing_type; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_packing_type* self = (grib_accessor_packing_type*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->packing_type = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static size_t string_length(grib_accessor* a) -{ - return 1024; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int pack_string(grib_accessor*a, const char* sval, size_t* len) -{ - grib_accessor_packing_type* self = (grib_accessor_packing_type*)a; - grib_handle* h = grib_handle_of_accessor(a); - double* values = NULL; - grib_context* c = a->context; - size_t size = 0; - int err = 0; - - if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return err; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) return GRIB_OUT_OF_MEMORY; - - if ((err = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - if ((err = grib_set_string_internal(h, self->packing_type, sval, len)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - if ((err = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return err; - } - - grib_context_free(c, values); - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_packing_type* self = (grib_accessor_packing_type*)a; - grib_handle* h = grib_handle_of_accessor(a); - - return grib_get_string(h, self->packing_type, val, len); -} diff --git a/src/grib_accessor_class_pad.cc b/src/grib_accessor_class_pad.cc deleted file mode 100644 index 473a507e1..000000000 --- a/src/grib_accessor_class_pad.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size - MEMBERS =grib_expression* expression - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_pad -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in pad */ - grib_expression* expression; -} grib_accessor_pad; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_pad = { - &grib_accessor_class_padding, /* super */ - "pad", /* name */ - sizeof(grib_accessor_pad), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_pad = &_grib_accessor_class_pad; - -/* END_CLASS_IMP */ - - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_pad* self = (grib_accessor_pad*)a; - - long length = 0; - - grib_expression_evaluate_long(grib_handle_of_accessor(a), self->expression, &length); - - return length > 0 ? length : 0; -} - - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_pad* self = (grib_accessor_pad*)a; - - self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); - a->length = preferred_size(a, 1); -} diff --git a/src/grib_accessor_class_padding.cc b/src/grib_accessor_class_padding.cc deleted file mode 100644 index 790ea9db2..000000000 --- a/src/grib_accessor_class_padding.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_bytes - IMPLEMENTS = init;update_size;resize; value_count - IMPLEMENTS = compare;string_length;byte_count - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static size_t string_length(grib_accessor*); -static long byte_count(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static void resize(grib_accessor*,size_t); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_padding -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ -} grib_accessor_padding; - -extern grib_accessor_class* grib_accessor_class_bytes; - -static grib_accessor_class _grib_accessor_class_padding = { - &grib_accessor_class_bytes, /* super */ - "padding", /* name */ - sizeof(grib_accessor_padding), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - &resize, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_padding = &_grib_accessor_class_padding; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - if (a->length != b->length) - return GRIB_COUNT_MISMATCH; - return GRIB_SUCCESS; -} - -static void update_size(grib_accessor* a, size_t new_size) -{ - a->length = new_size; -} - -static void resize(grib_accessor* a, size_t new_size) -{ - void* zero = grib_context_malloc_clear(a->context, new_size); - - grib_buffer_replace(a, (const unsigned char*)zero, new_size, - /*update_lengths=*/1, /*update_paddings=*/0); - grib_context_free(a->context, zero); - - grib_context_log(a->context, GRIB_LOG_DEBUG, - "grib_accessor_class_padding::resize new_size=%zu a->length=%ld %s %s", - new_size, a->length, a->cclass->name, a->name); - Assert(new_size == a->length); -} - -static int value_count(grib_accessor* a, long* c) -{ - *c = a->length; - return 0; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static size_t string_length(grib_accessor* a) -{ - return (size_t)a->length; -} diff --git a/src/grib_accessor_class_padto.cc b/src/grib_accessor_class_padto.cc deleted file mode 100644 index f6f9417b4..000000000 --- a/src/grib_accessor_class_padto.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size;dump - MEMBERS=grib_expression* expression - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_padto -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in padto */ - grib_expression* expression; -} grib_accessor_padto; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_padto = { - &grib_accessor_class_padding, /* super */ - "padto", /* name */ - sizeof(grib_accessor_padto), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_padto = &_grib_accessor_class_padto; - -/* END_CLASS_IMP */ - - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_padto* self = (grib_accessor_padto*)a; - - long length = 0; - long theEnd; - - grib_expression_evaluate_long(grib_handle_of_accessor(a), self->expression, &theEnd); - - length = theEnd - a->offset; - - /* printf("preferred_size: prefered: %ld current:%ld %s %s %ld\n", (long)length,(long)a->length,a->cclass->name,a->name,(long)a->offset); */ - - return length > 0 ? length : 0; -} - - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_padto* self = (grib_accessor_padto*)a; - - self->expression = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); - a->length = preferred_size(a, 1); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - /*grib_dump_string(dumper,a,NULL);*/ -} diff --git a/src/grib_accessor_class_padtoeven.cc b/src/grib_accessor_class_padtoeven.cc deleted file mode 100644 index c75e0e254..000000000 --- a/src/grib_accessor_class_padtoeven.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size - MEMBERS=const char* section_offset - MEMBERS=const char* section_length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_padtoeven -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in padtoeven */ - const char* section_offset; - const char* section_length; -} grib_accessor_padtoeven; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_padtoeven = { - &grib_accessor_class_padding, /* super */ - "padtoeven", /* name */ - sizeof(grib_accessor_padtoeven), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_padtoeven = &_grib_accessor_class_padtoeven; - -/* END_CLASS_IMP */ - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_padtoeven* self = (grib_accessor_padtoeven*)a; - long offset = 0; - long length = 0; - long seclen; - - grib_get_long_internal(grib_handle_of_accessor(a), self->section_offset, &offset); - grib_get_long_internal(grib_handle_of_accessor(a), self->section_length, &length); - - if ((length % 2) && from_handle) { - // grib_context_log(a->context, - // GRIB_LOG_ERROR,"GRIB message has an odd length section (%ld, %s)", - // (long)length,a->name); - return 0; - } - - /* printf("EVEN %ld %ld\n",(long) a->offset,(long) offset);*/ - seclen = a->offset - offset; - - return (seclen % 2) ? 1 : 0; -} - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_padtoeven* self = (grib_accessor_padtoeven*)a; - - self->section_offset = grib_arguments_get_name(grib_handle_of_accessor(a), args, 0); - self->section_length = grib_arguments_get_name(grib_handle_of_accessor(a), args, 1); - - a->length = preferred_size(a, 1); -} diff --git a/src/grib_accessor_class_padtomultiple.cc b/src/grib_accessor_class_padtomultiple.cc deleted file mode 100644 index 3104cdf2f..000000000 --- a/src/grib_accessor_class_padtomultiple.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size - MEMBERS=grib_expression* begin - MEMBERS=grib_expression* multiple - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_padtomultiple -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in padtomultiple */ - grib_expression* begin; - grib_expression* multiple; -} grib_accessor_padtomultiple; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_padtomultiple = { - &grib_accessor_class_padding, /* super */ - "padtomultiple", /* name */ - sizeof(grib_accessor_padtomultiple), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_padtomultiple = &_grib_accessor_class_padtomultiple; - -/* END_CLASS_IMP */ - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_padtomultiple* self = (grib_accessor_padtomultiple*)a; - long padding = 0; - long begin = 0; - long multiple = 0; - - grib_expression_evaluate_long(grib_handle_of_accessor(a), self->begin, &begin); - grib_expression_evaluate_long(grib_handle_of_accessor(a), self->multiple, &multiple); - - padding = a->offset - begin; - padding = ((padding + multiple - 1) / multiple) * multiple - padding; - - return padding == 0 ? multiple : padding; -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_padtomultiple* self = (grib_accessor_padtomultiple*)a; - - self->begin = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 0); - self->multiple = grib_arguments_get_expression(grib_handle_of_accessor(a), arg, 1); - a->length = preferred_size(a, 1); -} diff --git a/src/grib_accessor_class_position.cc b/src/grib_accessor_class_position.cc deleted file mode 100644 index 0f9565c37..000000000 --- a/src/grib_accessor_class_position.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - IMPLEMENTS = init;dump - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_position -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in position */ -} grib_accessor_position; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_position = { - &grib_accessor_class_gen, /* super */ - "position", /* name */ - sizeof(grib_accessor_position), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_position = &_grib_accessor_class_position; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - *val = a->offset; - *len = 1; - return GRIB_SUCCESS; -} - -// static int compare(grib_accessor* a, grib_accessor* b) -// { -// if (a->offset != b->offset) -// return GRIB_OFFSET_MISMATCH; -// return GRIB_SUCCESS; -// } diff --git a/src/grib_accessor_class_raw.cc b/src/grib_accessor_class_raw.cc deleted file mode 100644 index cdac6a100..000000000 --- a/src/grib_accessor_class_raw.cc +++ /dev/null @@ -1,219 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = get_native_type;init;update_size; pack_bytes - IMPLEMENTS = compare;unpack_bytes;byte_count;value_count - MEMBERS = const char* totalLength - MEMBERS = const char* sectionLength - MEMBERS = long relativeOffset - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_bytes(grib_accessor*, const unsigned char*, size_t* len); -static int unpack_bytes(grib_accessor*, unsigned char*, size_t* len); -static long byte_count(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_raw -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in raw */ - const char* totalLength; - const char* sectionLength; - long relativeOffset; -} grib_accessor_raw; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_raw = { - &grib_accessor_class_gen, /* super */ - "raw", /* name */ - sizeof(grib_accessor_raw), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - &pack_bytes, /* pack_bytes */ - &unpack_bytes, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_raw = &_grib_accessor_class_raw; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - int n = 0; - int err = 0; - long sectionLength; - grib_accessor_raw* self = (grib_accessor_raw*)a; - grib_expression* e; - grib_handle* hand = grib_handle_of_accessor(a); - - a->length = 0; - self->totalLength = grib_arguments_get_name(hand, arg, n++); - self->sectionLength = grib_arguments_get_name(hand, arg, n++); - - e = grib_arguments_get_expression(hand, arg, n++); - err = grib_expression_evaluate_long(hand, e, &(self->relativeOffset)); - if (err) - grib_context_log(hand->context, GRIB_LOG_ERROR, "Unable to evaluate relativeOffset"); - - grib_get_long(hand, self->sectionLength, §ionLength); - - a->length = sectionLength - self->relativeOffset; - if (a->length < 0) - a->length = 0; - - /* Assert(a->length>=0); */ -} - -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; - - 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; - - return retval; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int value_count(grib_accessor* a, long* len) -{ - *len = a->length; - return 0; -} - -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); - - return GRIB_SUCCESS; -} - -static void update_size(grib_accessor* a, size_t s) -{ - grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); - a->length = s; - Assert(a->length >= 0); -} - -void accessor_raw_set_length(grib_accessor* a, size_t len) -{ - a->length = len; -} - -long accessor_raw_get_offset(grib_accessor* a) -{ - return a->offset; -} - -static int pack_bytes(grib_accessor* a, const unsigned char* val, size_t* len) -{ - size_t length = *len; - long totalLength; - long sectionLength; - grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_raw* self = (grib_accessor_raw*)a; - long dlen = length - a->length; - - grib_get_long(h, self->totalLength, &totalLength); - totalLength += dlen; - grib_get_long(h, self->sectionLength, §ionLength); - sectionLength += dlen; - - grib_buffer_replace(a, val, length, 1, 1); - - grib_set_long(h, self->totalLength, totalLength); - grib_set_long(h, self->sectionLength, sectionLength); - a->length = length; - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_rdbtime_guess_date.cc b/src/grib_accessor_class_rdbtime_guess_date.cc deleted file mode 100644 index 7bd8a3c4a..000000000 --- a/src/grib_accessor_class_rdbtime_guess_date.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - MEMBERS=const char* typicalYear - MEMBERS=const char* typicalMonth - MEMBERS=const char* typicalDay - MEMBERS=const char* rdbDay - MEMBERS=long yearOrMonth - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_rdbtime_guess_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in rdbtime_guess_date */ - const char* typicalYear; - const char* typicalMonth; - const char* typicalDay; - const char* rdbDay; - long yearOrMonth; -} grib_accessor_rdbtime_guess_date; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_rdbtime_guess_date = { - &grib_accessor_class_long, /* super */ - "rdbtime_guess_date", /* name */ - sizeof(grib_accessor_rdbtime_guess_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_rdbtime_guess_date = &_grib_accessor_class_rdbtime_guess_date; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_rdbtime_guess_date* self = (grib_accessor_rdbtime_guess_date*)a; - int n = 0; - - self->typicalYear = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->typicalMonth = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->typicalDay = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->rdbDay = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->yearOrMonth = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - - /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_rdbtime_guess_date* self = (grib_accessor_rdbtime_guess_date*)a; - grib_handle* h = grib_handle_of_accessor(a); - int ret = 0; - long typicalYear, typicalMonth, typicalDay, rdbDay; - long rdbYear, rdbMonth; - - ret = grib_get_long(h, self->typicalYear, &typicalYear); - if (ret) - return ret; - ret = grib_get_long(h, self->typicalMonth, &typicalMonth); - if (ret) - return ret; - ret = grib_get_long(h, self->typicalDay, &typicalDay); - if (ret) - return ret; - ret = grib_get_long(h, self->rdbDay, &rdbDay); - if (ret) - return ret; - - if (rdbDay < typicalDay) { - if (typicalDay == 31 && typicalMonth == 12) { - rdbYear = typicalYear + 1; - rdbMonth = 1; - } - else { - rdbYear = typicalYear; - rdbMonth = typicalMonth + 1; - } - } - else { - rdbYear = typicalYear; - rdbMonth = typicalMonth; - } - - *val = self->yearOrMonth == 1 ? rdbYear : rdbMonth; - *len = 1; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ - /* do nothing*/ - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_reference_value_error.cc b/src/grib_accessor_class_reference_value_error.cc deleted file mode 100644 index 3cc4af20d..000000000 --- a/src/grib_accessor_class_reference_value_error.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS=const char* referenceValue - MEMBERS=const char* floatType - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_reference_value_error -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in reference_value_error */ - const char* referenceValue; - const char* floatType; -} grib_accessor_reference_value_error; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_reference_value_error = { - &grib_accessor_class_double, /* super */ - "reference_value_error", /* name */ - sizeof(grib_accessor_reference_value_error), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_reference_value_error = &_grib_accessor_class_reference_value_error; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_reference_value_error* self = (grib_accessor_reference_value_error*)a; - int n = 0; - - self->referenceValue = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->floatType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_reference_value_error* self = (grib_accessor_reference_value_error*)a; - int ret = 0; - double referenceValue = 0; - - if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), - self->referenceValue, &referenceValue)) != GRIB_SUCCESS) - return ret; - - if (!strcmp(self->floatType, "ibm")) - *val = grib_ibmfloat_error(referenceValue); - else if (!strcmp(self->floatType, "ieee")) - *val = grib_ieeefloat_error(referenceValue); - else - Assert(1 == 0); - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} diff --git a/src/grib_accessor_class_round.cc b/src/grib_accessor_class_round.cc deleted file mode 100644 index 98fe2fda5..000000000 --- a/src/grib_accessor_class_round.cc +++ /dev/null @@ -1,154 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_evaluate - IMPLEMENTS = unpack_double - IMPLEMENTS = unpack_string - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); - -typedef struct grib_accessor_round -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in evaluate */ - grib_arguments* arg; - /* Members defined in round */ -} grib_accessor_round; - -extern grib_accessor_class* grib_accessor_class_evaluate; - -static grib_accessor_class _grib_accessor_class_round = { - &grib_accessor_class_evaluate, /* super */ - "round", /* name */ - sizeof(grib_accessor_round), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_round = &_grib_accessor_class_round; - -/* END_CLASS_IMP */ - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_round* self = (grib_accessor_round*)a; - - int ret = GRIB_SUCCESS; - - size_t replen = 0; - double rounding_precision = 0; - double rounded = 0; - double toround = 0; - - const char* oval = NULL; - oval = grib_arguments_get_name(grib_handle_of_accessor(a), self->arg, 0); - - if ((ret = grib_get_double_internal(grib_handle_of_accessor(a), oval, &toround)) != 0) - return ret; - - rounding_precision = grib_arguments_get_long(grib_handle_of_accessor(a), self->arg, 1); - - rounded = floor(rounding_precision * toround + 0.5) / rounding_precision; - - *len = replen; - - *val = rounded; - - return ret; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - char result[1024]; - int ret = GRIB_SUCCESS; - size_t replen = 1; - - double value = 0; - - ret = unpack_double(a, &value, &replen); - - snprintf(result, sizeof(result), "%.3f", value); - - replen = strlen(result) + 1; - - if (*len < replen) { - *len = replen; - return GRIB_ARRAY_TOO_SMALL; - } - - *len = replen; - - snprintf(val, 1024, "%s", result); - - return ret; -} diff --git a/src/grib_accessor_class_scale.cc b/src/grib_accessor_class_scale.cc deleted file mode 100644 index 6fec75e94..000000000 --- a/src/grib_accessor_class_scale.cc +++ /dev/null @@ -1,237 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double;pack_double;is_missing - IMPLEMENTS = pack_long - IMPLEMENTS = init - MEMBERS=const char* value - MEMBERS=const char* multiplier - MEMBERS=const char* divisor - MEMBERS=const char* truncating - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_scale -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in scale */ - const char* value; - const char* multiplier; - const char* divisor; - const char* truncating; -} grib_accessor_scale; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_scale = { - &grib_accessor_class_double, /* super */ - "scale", /* name */ - sizeof(grib_accessor_scale), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_scale = &_grib_accessor_class_scale; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_scale* self = (grib_accessor_scale*)a; - int n = 0; - - self->value = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->multiplier = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->divisor = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->truncating = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_scale* self = (grib_accessor_scale*)a; - int ret = 0; - long value = 0; - long multiplier = 0; - long divisor = 0; - - if (*len < 1) { - ret = GRIB_ARRAY_TOO_SMALL; - grib_context_log(a->context, GRIB_LOG_ERROR, - "Accessor %s cannot gather value for %s and/or %s", - a->name, self->multiplier, self->divisor); - return ret; - } - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->divisor, &divisor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->multiplier, &multiplier)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->value, &value)) != GRIB_SUCCESS) - return ret; - - if (value == GRIB_MISSING_LONG) - *val = GRIB_MISSING_DOUBLE; - else - *val = ((double)(value * multiplier)) / divisor; - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - const double dval = (double)*val; - return pack_double(a, &dval, len); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_scale* self = (grib_accessor_scale*)a; - int ret = 0; - - long value = 0; - long divisor = 0; - long multiplier = 0; - long truncating = 0; - double x; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->divisor, &divisor); - if (ret != GRIB_SUCCESS) return ret; - - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->multiplier, &multiplier); - if (ret != GRIB_SUCCESS) return ret; - - if (self->truncating) { - ret = grib_get_long_internal(grib_handle_of_accessor(a), self->truncating, &truncating); - if (ret != GRIB_SUCCESS) return ret; - } - - if (multiplier == 0) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor %s: cannot divide by a zero multiplier %s", - a->name, self->multiplier); - return GRIB_ENCODING_ERROR; - } - - x = *val * (double)divisor / (double)multiplier; - if (*val == GRIB_MISSING_DOUBLE) - value = GRIB_MISSING_LONG; - else if (truncating) { - value = (long)x; - } - else { - value = x > 0 ? (long)(x + 0.5) : (long)(x - 0.5); - } - - ret = grib_set_long_internal(grib_handle_of_accessor(a), self->value, value); - if (ret) - grib_context_log(a->context, GRIB_LOG_ERROR, - "Accessor %s: cannot pack value for %s (%s)\n", - a->name, self->value, grib_get_error_message(ret)); - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} - -static int is_missing(grib_accessor* a) -{ - grib_accessor_scale* self = (grib_accessor_scale*)a; - grib_accessor* av = grib_find_accessor(grib_handle_of_accessor(a), self->value); - - if (!av) - return GRIB_NOT_FOUND; - return grib_is_missing_internal(av); - // int ret=0; - // long value=0; - // if((ret = grib_get_long_internal(grib_handle_of_accessor(a),self->value, &value))!= GRIB_SUCCESS){ - // grib_context_log(a->context, GRIB_LOG_ERROR, - // "Accessor %s cannot gather value for %s error %d \n", a->name, - // self->value, ret); - // return 0; - // } - // return (value == GRIB_MISSING_LONG); -} diff --git a/src/grib_accessor_class_scale_values.cc b/src/grib_accessor_class_scale_values.cc deleted file mode 100644 index 8c4b33fcb..000000000 --- a/src/grib_accessor_class_scale_values.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/********************************** - * Enrico Fucile - *********************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double; pack_double - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* missingValue - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_scale_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in scale_values */ - const char* values; - const char* missingValue; -} grib_accessor_scale_values; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_scale_values = { - &grib_accessor_class_double, /* super */ - "scale_values", /* name */ - sizeof(grib_accessor_scale_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_scale_values = &_grib_accessor_class_scale_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* args) -{ - int n = 0; - grib_accessor_scale_values* self = (grib_accessor_scale_values*)a; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->missingValue = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - int ret = 0; - *val = 1; - *len = 1; - return ret; -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - double* values = NULL; - double missingValue = 0; - long missingValuesPresent = 0; - size_t size = 0; - int ret = 0, i = 0; - grib_accessor_scale_values* self = (grib_accessor_scale_values*)a; - const grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (*val == 1) - return GRIB_SUCCESS; - - if ((ret = grib_get_double_internal(h, self->missingValue, &missingValue)) != GRIB_SUCCESS) { - return ret; - } - if ((ret = grib_get_long_internal(h, "missingValuesPresent", &missingValuesPresent)) != GRIB_SUCCESS) { - return ret; - } - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - for (i = 0; i < size; i++) { - if (missingValuesPresent) { - if (values[i] != missingValue) - values[i] *= *val; - } - else { - values[i] *= *val; - } - } - - if ((ret = grib_set_double_array_internal(h, self->values, values, size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - grib_context_free(c, values); - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_section.cc b/src/grib_accessor_class_section.cc deleted file mode 100644 index f9c8857a7..000000000 --- a/src/grib_accessor_class_section.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = next_offset;byte_count - IMPLEMENTS = destroy;sub_section - IMPLEMENTS = get_native_type - IMPLEMENTS = init;dump;update_size - IMPLEMENTS = next - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static grib_section* sub_section(grib_accessor* a); -static int get_native_type(grib_accessor*); -static long byte_count(grib_accessor*); -static long next_offset(grib_accessor*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static grib_accessor* next(grib_accessor*, int); - -typedef struct grib_accessor_section -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in section */ -} grib_accessor_section; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_section = { - &grib_accessor_class_gen, /* super */ - "section", /* name */ - sizeof(grib_accessor_section), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - &sub_section, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - &next, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_section = &_grib_accessor_class_section; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->sub_section = grib_section_create(grib_handle_of_accessor(a), a); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_section(dumper, a, a->sub_section->block); -} - -static long byte_count(grib_accessor* a) -{ - if (!a->length || grib_handle_of_accessor(a)->loader) { - if (a->name[1] == '_') - return 0; - - /* printf("adjusting sizes SECTION %s is %ld %ld\n",a->name,(long)a->offset,(long)a->length); */ - grib_section_adjust_sizes(a->sub_section, grib_handle_of_accessor(a)->loader != NULL, 0); - /* printf(" SECTION %s is %ld %ld\n",a->name,(long)a->offset,(long)a->length); */ - } - - /* printf("SECTION %s is %ld %d\n",a->name,a->length,a->sub_section->aclength != NULL); */ - return a->length; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + byte_count(a); -} - -static void destroy(grib_context* ct, grib_accessor* a) -{ - grib_section_delete(ct, a->sub_section); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_SECTION; -} - -static grib_section* sub_section(grib_accessor* a) -{ - return a->sub_section; -} - -static void update_size(grib_accessor* a, size_t length) -{ - size_t size = 1; - long len = length; - Assert(length <= 0x7fffffff); - if (a->sub_section->aclength) { - int e = grib_pack_long(a->sub_section->aclength, &len, &size); - Assert(e == GRIB_SUCCESS); - // printf("update_length %s %ld %ld\n", a->sub_section->aclength->name, - // (long)a->sub_section->aclength->offset, - // (long)a->sub_section->aclength->length); - } - - a->sub_section->length = a->length = length; - a->sub_section->padding = 0; - - // printf("update_size %s %ld\n", a->name, a->length); - - Assert(a->length >= 0); -} - -static grib_accessor* next(grib_accessor* a, int explore) -{ - grib_accessor* next = NULL; - if (explore) { - next = a->sub_section->block->first; - if (!next) - next = a->next; - } - else { - next = a->next; - } - if (!next) { - if (a->parent->owner) - next = a->parent->owner->cclass->next(a->parent->owner, 0); - } - return next; -} diff --git a/src/grib_accessor_class_section_length.cc b/src/grib_accessor_class_section_length.cc deleted file mode 100644 index 4e5957e71..000000000 --- a/src/grib_accessor_class_section_length.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_unsigned - IMPLEMENTS = init;dump - IMPLEMENTS = value_count - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_section_length -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in section_length */ -} grib_accessor_section_length; - -extern grib_accessor_class* grib_accessor_class_unsigned; - -static grib_accessor_class _grib_accessor_class_section_length = { - &grib_accessor_class_unsigned, /* super */ - "section_length", /* name */ - sizeof(grib_accessor_section_length), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_section_length = &_grib_accessor_class_section_length; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->parent->aclength = a; - a->length = len; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - Assert(a->length >= 0); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int value_count(grib_accessor* a, long* c) -{ - *c = 1; - return 0; -} diff --git a/src/grib_accessor_class_section_padding.cc b/src/grib_accessor_class_section_padding.cc deleted file mode 100644 index 682946df5..000000000 --- a/src/grib_accessor_class_section_padding.cc +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_padding - IMPLEMENTS = init;preferred_size - MEMBERS = int preserve - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static void init(grib_accessor*, const long, grib_arguments*); -static size_t preferred_size(grib_accessor*, int); - -typedef struct grib_accessor_section_padding -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in bytes */ - /* Members defined in padding */ - /* Members defined in section_padding */ - int preserve; -} grib_accessor_section_padding; - -extern grib_accessor_class* grib_accessor_class_padding; - -static grib_accessor_class _grib_accessor_class_section_padding = { - &grib_accessor_class_padding, /* super */ - "section_padding", /* name */ - sizeof(grib_accessor_section_padding), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - &preferred_size, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_section_padding = &_grib_accessor_class_section_padding; - -/* END_CLASS_IMP */ - -static size_t preferred_size(grib_accessor* a, int from_handle) -{ - grib_accessor_section_padding* self = (grib_accessor_section_padding*)a; - grib_accessor* b = a; - grib_accessor* section_length = 0; - long length = 0; - size_t size = 1; - - long alength = 0; - - if (!from_handle) { - if (self->preserve) - return a->length; - else - return 0; - } - - /* The section length should be a parameter */ - while (section_length == NULL && b != NULL) { - section_length = b->parent->aclength; - b = b->parent->owner; - } - - if (!section_length) { - /* printf("PADDING is no !section_length\n"); */ - return 0; - } - - if (grib_unpack_long(section_length, &length, &size) == GRIB_SUCCESS) { - if (length) - alength = length - a->offset + section_length->parent->owner->offset; - else - alength = 0; - - /*Assert(a->length>=0);*/ - - if (alength < 0) - alength = 0; - - /* printf("PADDING is %ld\n",a->length); */ - } - else { - /* printf("PADDING unpack fails\n"); */ - } - - return alength; -} - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_section_padding* self = (grib_accessor_section_padding*)a; - self->preserve = 1; /* This should be a parameter */ - a->length = preferred_size(a, 1); -} diff --git a/src/grib_accessor_class_section_pointer.cc b/src/grib_accessor_class_section_pointer.cc deleted file mode 100644 index e9b81614a..000000000 --- a/src/grib_accessor_class_section_pointer.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;get_native_type;unpack_string - IMPLEMENTS = byte_count; byte_offset - MEMBERS = const char* sectionOffset - MEMBERS = const char* sectionLength - MEMBERS = long sectionNumber - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_section_pointer -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in section_pointer */ - const char* sectionOffset; - const char* sectionLength; - long sectionNumber; -} grib_accessor_section_pointer; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_section_pointer = { - &grib_accessor_class_gen, /* super */ - "section_pointer", /* name */ - sizeof(grib_accessor_section_pointer), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_section_pointer = &_grib_accessor_class_section_pointer; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - int n = 0; - grib_accessor_section_pointer* self = (grib_accessor_section_pointer*)a; - - self->sectionOffset = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->sectionLength = grib_arguments_get_name(grib_handle_of_accessor(a), arg, n++); - self->sectionNumber = grib_arguments_get_long(grib_handle_of_accessor(a), arg, n++); - - Assert(self->sectionNumber < MAX_NUM_SECTIONS); - - grib_handle_of_accessor(a)->section_offset[self->sectionNumber] = (char*)self->sectionOffset; - grib_handle_of_accessor(a)->section_length[self->sectionNumber] = (char*)self->sectionLength; - - /* printf("++++++++++++++ GRIB_API: creating section_pointer%d %s %s\n", */ - /* self->sectionNumber,self->sectionLength,self->sectionLength); */ - - if (grib_handle_of_accessor(a)->sections_count < self->sectionNumber) - grib_handle_of_accessor(a)->sections_count = self->sectionNumber; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->flags |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; - a->length = 0; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_BYTES; -} - -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 < length) return GRIB_ARRAY_TOO_SMALL; - - p = grib_handle_of_accessor(a)->buffer->data + grib_byte_offset(a); - - for (i = 0; i < length; i++) { - snprintf (s,64,"%02x", *(p++)); - s+=2; - } - *len=length; - */ - snprintf(v, 64, "%ld_%ld", grib_byte_offset(a), grib_byte_count(a)); - return GRIB_SUCCESS; -} - -static long byte_count(grib_accessor* a) -{ - grib_accessor_section_pointer* self = (grib_accessor_section_pointer*)a; - long sectionLength = 0; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->sectionLength, §ionLength); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "unable to get %s %s", - self->sectionLength, grib_get_error_message(ret)); - return -1; - } - - return sectionLength; -} - -static long byte_offset(grib_accessor* a) -{ - grib_accessor_section_pointer* self = (grib_accessor_section_pointer*)a; - long sectionOffset = 0; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->sectionOffset, §ionOffset); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "unable to get %s %s", - self->sectionOffset, grib_get_error_message(ret)); - return -1; - } - - return sectionOffset; -} diff --git a/src/grib_accessor_class_sexagesimal2decimal.cc b/src/grib_accessor_class_sexagesimal2decimal.cc deleted file mode 100644 index 9e132d9c2..000000000 --- a/src/grib_accessor_class_sexagesimal2decimal.cc +++ /dev/null @@ -1,241 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ -/*********************************************************** - * Enrico Fucile - ***********************************************************/ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_to_double - IMPLEMENTS = init; unpack_string - IMPLEMENTS = dump - IMPLEMENTS = get_native_type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_sexagesimal2decimal -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in to_double */ - const char* key; - long start; - size_t length; - long scale; - /* Members defined in sexagesimal2decimal */ -} grib_accessor_sexagesimal2decimal; - -extern grib_accessor_class* grib_accessor_class_to_double; - -static grib_accessor_class _grib_accessor_class_sexagesimal2decimal = { - &grib_accessor_class_to_double, /* super */ - "sexagesimal2decimal", /* name */ - sizeof(grib_accessor_sexagesimal2decimal), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_sexagesimal2decimal = &_grib_accessor_class_sexagesimal2decimal; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_double(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - int err = 0; - grib_accessor_sexagesimal2decimal* self = (grib_accessor_sexagesimal2decimal*)a; - char buff[512] = {0,}; - size_t length = 0; - size_t size = 512; - char* p; - char* q; - double dd, mm = 0, ss = 0; - int dd_sign = 1; - - err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); - if (err) - return err; - q = buff + self->start; - if (self->length) - q[length] = 0; - p = q; - - while (*p != '-' && *p != ':' && *p != ' ' && *p != 0) { - p++; - } - - if (*p == 0) { - return GRIB_WRONG_CONVERSION; - } - *p = 0; - - dd = atoi(q); - p++; - q = p; - while (*p != '-' && *p != ':' && *p != ' ' && *p != 'N' && *p != 'S' && *p != 'E' && *p != 'W' && *p != 0) { - p++; - } - switch (*p) { - case ' ': - case '-': - case ':': - *p = 0; - mm = atoi(q) / 60.0; - dd += mm; - p++; - q = p; - break; - case 'N': - case 'E': - *p = 0; - dd_sign = 1; - mm = atoi(q) / 60.0; - dd += mm; - p++; - q = p; - break; - case 'S': - case 'W': - *p = 0; - mm = atoi(q) / 60.0; - dd += mm; - dd_sign = -1; - p++; - q = p; - break; - case 0: - break; - default: - return GRIB_WRONG_CONVERSION; - } - if (*p) { - while (*p != '-' && *p != ':' && *p != ' ' && *p != 'N' && *p != 'S' && *p != 'E' && *p != 'W' && *p != 0) { - p++; - } - switch (*p) { - case ' ': - case '-': - case ':': - *p = 0; - ss = atof(q) / 60.0; - dd += ss; - break; - case 'N': - case 'E': - *p = 0; - ss = atof(q) / 60.0; - dd += ss; - dd_sign = 1; - break; - case 'S': - case 'W': - *p = 0; - ss = atof(q) / 60.0; - dd += ss; - dd_sign = -1; - break; - case 0: - break; - default: - return GRIB_WRONG_CONVERSION; - } - } - dd *= dd_sign; - - snprintf(buff, sizeof(buff), "%.2f", dd); - length = strlen(buff); - - if (len[0] < length + 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", - len[0], a->name, a->length + 1); - len[0] = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - strcpy(val, buff); - - len[0] = length; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_signed.cc b/src/grib_accessor_class_signed.cc deleted file mode 100644 index 3439934e1..000000000 --- a/src/grib_accessor_class_signed.cc +++ /dev/null @@ -1,317 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size; is_missing - MEMBERS = grib_arguments* arg - MEMBERS = int nbytes; - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int is_missing(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_signed -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in signed */ - grib_arguments* arg; - int nbytes; -} grib_accessor_signed; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_signed = { - &grib_accessor_class_long, /* super */ - "signed", /* name */ - sizeof(grib_accessor_signed), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - &is_missing, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_signed = &_grib_accessor_class_signed; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_signed* self = (grib_accessor_signed*)a; - long count = 0; - - self->arg = arg; - grib_value_count(a, &count); - a->length = len * count; - self->nbytes = len; - Assert(a->length >= 0); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - long rlen = 0; - grib_value_count(a, &rlen); - if (rlen == 1) - grib_dump_long(dumper, a, NULL); - else - grib_dump_values(dumper, a); -} - -static const long ones[] = { - 0, - -0x7f, - -0x7fff, - -0x7fffff, - -0x7fffffff, -}; - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_signed* self = (grib_accessor_signed*)a; - unsigned long rlen = 0; - int err = 0; - long count = 0; - unsigned long i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - long pos = a->offset; - long missing = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - rlen = count; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %lu values", a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { - Assert(self->nbytes <= 4); - missing = ones[self->nbytes]; - } - - for (i = 0; i < rlen; i++) { - val[i] = (long)grib_decode_signed_long(hand->buffer->data, pos, self->nbytes); - if (missing) - if (val[i] == missing) - val[i] = GRIB_MISSING_LONG; - pos += self->nbytes; - } - - *len = rlen; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_signed* self = (grib_accessor_signed*)a; - int ret = 0; - long off = 0; - unsigned long rlen = 0; - int err = 0; - long count = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - long missing = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - rlen = count; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); - len[0] = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) { - Assert(self->nbytes <= 4); - missing = ones[self->nbytes]; - } - - if (rlen == 1) { - long v = val[0]; - if (missing) { - if (v == GRIB_MISSING_LONG) - v = missing; - } else { - // ECC-1605: Check overflow/underflow - const int nbits = self->nbytes * 8; - const long minval = -(1L << (nbits-1)) + 1; - const long maxval = (1L << (nbits-1)) - 1; - //printf(" key=%s: v=%ld (minval=%ld maxval=%ld)\n", a->name, v, minval, maxval); - if (v > maxval || v < minval) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Key \"%s\": Trying to encode value of %ld but the allowable range is %ld to %ld (number of bits=%d)", - a->name, v, minval, maxval, nbits); - return GRIB_ENCODING_ERROR; - } - } - - off = a->offset; - ret = grib_encode_signed_long(grib_handle_of_accessor(a)->buffer->data, v, off, a->length); - if (ret == GRIB_SUCCESS) - len[0] = 1; - if (*len > 1) - grib_context_log(a->context, GRIB_LOG_WARNING, "grib_accessor_signed : Trying to pack %d values in a scalar %s, packing first value", *len, a->name); - len[0] = 1; - return ret; - } - - /* TODO: We assume that there are no missing values if there are more that 1 value */ - - buflen = *len * a->length; - - buf = (unsigned char*)grib_context_malloc(a->context, buflen); - - for (i = 0; i < *len; i++) { - grib_encode_signed_long(buf, val[i], off, a->length); - off += a->length; - } - ret = grib_set_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), *len); - - if (ret == GRIB_SUCCESS) - grib_buffer_replace(a, buf, buflen, 1, 1); - else - *len = 0; - - grib_context_free(a->context, buf); - return ret; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int value_count(grib_accessor* a, long* len) -{ - grib_accessor_signed* self = (grib_accessor_signed*)a; - *len = 0; - if (!self->arg) { - *len = 1; - return 0; - } - return grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, self->arg, 0), len); -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; - Assert(a->length >= 0); -} - -static long next_offset(grib_accessor* a) -{ - return grib_byte_offset(a) + grib_byte_count(a); -} - -static int is_missing(grib_accessor* a) -{ - int i = 0; - unsigned char ff = 0xff; - unsigned long offset = a->offset; - grib_handle* hand = grib_handle_of_accessor(a); - - if (a->length == 0) { - Assert(a->vvalue != NULL); - return a->vvalue->missing; - } - - for (i = 0; i < a->length; i++) { - if (hand->buffer->data[offset] != ff) - return 0; - offset++; - } - - return 1; -} diff --git a/src/grib_accessor_class_signed_bits.cc b/src/grib_accessor_class_signed_bits.cc deleted file mode 100644 index 1750af3eb..000000000 --- a/src/grib_accessor_class_signed_bits.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size - MEMBERS = const char* numberOfBits - MEMBERS = const char* numberOfElements - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_signed_bits -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in signed_bits */ - const char* numberOfBits; - const char* numberOfElements; -} grib_accessor_signed_bits; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_signed_bits = { - &grib_accessor_class_long, /* super */ - "signed_bits", /* name */ - sizeof(grib_accessor_signed_bits), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_signed_bits = &_grib_accessor_class_signed_bits; - -/* END_CLASS_IMP */ - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static long compute_byte_count(grib_accessor* a) -{ - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - long numberOfBits; - long numberOfElements; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfBits); - return 0; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - return 0; - } - - return (numberOfBits * numberOfElements + 7) / 8; -} - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - int n = 0; - self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->length = compute_byte_count(a); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -#if 0 - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - int i; - int ret = 0; - long pos = a->offset * 8; - long rlen = 0; - long numberOfBits = 0; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - - if (numberOfBits == 0) { - for (i = 0; i < rlen; i++) - val[i] = 0; - return GRIB_SUCCESS; - } - - for (i = 0; i < rlen; i++) - val[i] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); - - *len = rlen; - - return GRIB_SUCCESS; -#endif -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -#if 0 - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - int ret = 0; - long off = 0; - long numberOfBits = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - unsigned long rlen = 0; - long count = 0; - - ret = value_count(a, &count); - if (ret) - return ret; - rlen = count; - if (*len != rlen) { - ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, rlen); - if (ret) - return ret; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - - buflen = compute_byte_count(a); - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen + sizeof(long)); - - for (i = 0; i < rlen; i++) - grib_encode_signed_longb(buf, val[i], &off, numberOfBits); - - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_free(a->context, buf); - - return ret; -#endif -} - -static int value_count(grib_accessor* a, long* numberOfElements) -{ - grib_accessor_signed_bits* self = (grib_accessor_signed_bits*)a; - *numberOfElements = 0; - - return grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; -} - -static long next_offset(grib_accessor* a) -{ - return byte_offset(a) + byte_count(a); -} diff --git a/src/grib_accessor_class_simple_packing_error.cc b/src/grib_accessor_class_simple_packing_error.cc deleted file mode 100644 index 64f96eeea..000000000 --- a/src/grib_accessor_class_simple_packing_error.cc +++ /dev/null @@ -1,163 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_scaling.h" -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS=const char* binaryScaleFactor - MEMBERS=const char* bitsPerValue - MEMBERS=const char* decimalScaleFactor - MEMBERS=const char* referenceValue - MEMBERS=const char* floatType - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_simple_packing_error -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in simple_packing_error */ - const char* binaryScaleFactor; - const char* bitsPerValue; - const char* decimalScaleFactor; - const char* referenceValue; - const char* floatType; -} grib_accessor_simple_packing_error; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_simple_packing_error = { - &grib_accessor_class_double, /* super */ - "simple_packing_error", /* name */ - sizeof(grib_accessor_simple_packing_error), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_simple_packing_error = &_grib_accessor_class_simple_packing_error; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_simple_packing_error* self = (grib_accessor_simple_packing_error*)a; - int n = 0; - grib_handle* h = grib_handle_of_accessor(a); - - self->bitsPerValue = grib_arguments_get_name(h, c, n++); - self->binaryScaleFactor = grib_arguments_get_name(h, c, n++); - self->decimalScaleFactor = grib_arguments_get_name(h, c, n++); - self->referenceValue = grib_arguments_get_name(h, c, n++); - self->floatType = grib_arguments_get_name(h, c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_simple_packing_error* self = (grib_accessor_simple_packing_error*)a; - - int ret = 0; - long binaryScaleFactor = 0; - long bitsPerValue = 0; - long decimalScaleFactor = 0; - double referenceValue = 0; - grib_handle* h = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(h, self->binaryScaleFactor, &binaryScaleFactor)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(h, self->bitsPerValue, &bitsPerValue)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(h, self->decimalScaleFactor, &decimalScaleFactor)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_double_internal(h, self->referenceValue, &referenceValue)) != GRIB_SUCCESS) - return ret; - - if (!strcmp(self->floatType, "ibm")) - *val = grib_ibmfloat_error(referenceValue); - else if (!strcmp(self->floatType, "ieee")) - *val = grib_ieeefloat_error(referenceValue); - else - Assert(1 == 0); - - if (bitsPerValue != 0) - *val = (*val + codes_power(binaryScaleFactor, 2)) * codes_power(-decimalScaleFactor, 10) * 0.5; - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} diff --git a/src/grib_accessor_class_size.cc b/src/grib_accessor_class_size.cc deleted file mode 100644 index 410cec3c3..000000000 --- a/src/grib_accessor_class_size.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS = const char* accessor - END_CLASS_DEF - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_size -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in size */ - const char* accessor; -} grib_accessor_size; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_size = { - &grib_accessor_class_long, /* super */ - "size", /* name */ - sizeof(grib_accessor_size), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_size = &_grib_accessor_class_size; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_size* self = (grib_accessor_size*)a; - self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - size_t size = 0; - grib_accessor_size* self = (grib_accessor_size*)a; - ret = grib_get_size(grib_handle_of_accessor(a), self->accessor, &size); - *val = (long)size; - *len = 1; - return ret; -} diff --git a/src/grib_accessor_class_smart_table_column.cc b/src/grib_accessor_class_smart_table_column.cc deleted file mode 100644 index 28e5a4798..000000000 --- a/src/grib_accessor_class_smart_table_column.cc +++ /dev/null @@ -1,294 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump;unpack_string_array;unpack_long - IMPLEMENTS = value_count; destroy; get_native_type; - MEMBERS = const char* smartTable - MEMBERS = int index - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_smart_table_column -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in smart_table_column */ - const char* smartTable; - int index; -} grib_accessor_smart_table_column; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_smart_table_column = { - &grib_accessor_class_gen, /* super */ - "smart_table_column", /* name */ - sizeof(grib_accessor_smart_table_column), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_smart_table_column = &_grib_accessor_class_smart_table_column; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_smart_table -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned */ - long nbytes; - grib_arguments* arg; - /* Members defined in smart_table */ - const char* values; - const char* tablename; - const char* masterDir; - const char* localDir; - const char* extraDir; - const char* extraTable; - int widthOfCode; - long* tableCodes; - size_t tableCodesSize; - grib_smart_table* table; - int dirty; -} grib_accessor_smart_table; - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - int n = 0; - grib_accessor_smart_table_column* self = (grib_accessor_smart_table_column*)a; - - self->smartTable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), params, n++); - - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - int type = get_native_type(a); - - switch (type) { - case GRIB_TYPE_LONG: - grib_dump_long(dumper, a, NULL); - break; - case GRIB_TYPE_STRING: - grib_dump_string_array(dumper, a, NULL); - break; - } -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - grib_accessor_smart_table_column* self = (grib_accessor_smart_table_column*)a; - grib_accessor_smart_table* tableAccessor = NULL; - grib_smart_table* table = NULL; - - size_t size = 1; - long* code; - int err = GRIB_SUCCESS; - char tmp[1024] = {0,}; - int i = 0; - - tableAccessor = (grib_accessor_smart_table*)grib_find_accessor(grib_handle_of_accessor(a), self->smartTable); - if (!tableAccessor) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "unable to find accessor %s", self->smartTable); - return GRIB_NOT_FOUND; - } - - err = grib_get_size_acc(grib_handle_of_accessor(a), (grib_accessor*)tableAccessor, &size); - if (err) - return err; - if (*len < size) { - return GRIB_BUFFER_TOO_SMALL; - } - - code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - if (!code) { - grib_context_log(a->context, GRIB_LOG_FATAL, "%s: Memory allocation error: %zu bytes", a->name, size); - return GRIB_OUT_OF_MEMORY; - } - - if ((err = grib_unpack_long((grib_accessor*)tableAccessor, code, &size)) != GRIB_SUCCESS) - return err; - - table = tableAccessor->table; - - for (i = 0; i < size; i++) { - if (table && (code[i] >= 0) && - (code[i] < table->numberOfEntries) && - table->entries[code[i]].column[self->index]) { - strcpy(tmp, table->entries[code[i]].column[self->index]); - } - else { - snprintf(tmp, sizeof(tmp), "%d", (int)code[i]); - } - - buffer[i] = grib_context_strdup(a->context, tmp); - } - *len = size; - grib_context_free(a->context, code); - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_smart_table_column* self = (grib_accessor_smart_table_column*)a; - grib_accessor_smart_table* tableAccessor = NULL; - grib_smart_table* table = NULL; - - size_t size = 1; - long* code; - int err = GRIB_SUCCESS; - int i = 0; - - for (i = 0; i < *len; i++) - val[i] = GRIB_MISSING_LONG; - - tableAccessor = (grib_accessor_smart_table*)grib_find_accessor(grib_handle_of_accessor(a), self->smartTable); - if (!tableAccessor) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "unable to find accessor %s", self->smartTable); - return GRIB_NOT_FOUND; - } - - err = grib_get_size_acc(grib_handle_of_accessor(a), (grib_accessor*)tableAccessor, &size); - if (err) - return err; - if (*len < size) { - return GRIB_BUFFER_TOO_SMALL; - } - - code = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - if (!code) return GRIB_OUT_OF_MEMORY; - - if ((err = grib_unpack_long((grib_accessor*)tableAccessor, code, &size)) != GRIB_SUCCESS) { - grib_context_free(a->context, code); - return err; - } - - table = tableAccessor->table; - - for (i = 0; i < size; i++) { - if (table && (code[i] >= 0) && - (code[i] < table->numberOfEntries) && - table->entries[code[i]].column[self->index]) { - val[i] = atol(table->entries[code[i]].column[self->index]); - } - } - *len = size; - grib_context_free(a->context, code); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_smart_table_column* self = (grib_accessor_smart_table_column*)a; - size_t size = 0; - int err = 0; - *count = 0; - - if (!self->smartTable) - return 0; - - err = grib_get_size(grib_handle_of_accessor(a), self->smartTable, &size); - *count = size; - return err; -} - -static void destroy(grib_context* context, grib_accessor* a) -{ - if (a->vvalue != NULL) { - grib_context_free(context, a->vvalue); - a->vvalue = NULL; - } -} - -static int get_native_type(grib_accessor* a) -{ - int type = GRIB_TYPE_LONG; - /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", - a->name,a->flags,GRIB_ACCESSOR_FLAG_STRING_TYPE);*/ - if (a->flags & GRIB_ACCESSOR_FLAG_STRING_TYPE) - type = GRIB_TYPE_STRING; - return type; -} diff --git a/src/grib_accessor_class_spd.cc b/src/grib_accessor_class_spd.cc deleted file mode 100644 index 22fa03dc5..000000000 --- a/src/grib_accessor_class_spd.cc +++ /dev/null @@ -1,270 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size - MEMBERS = const char* numberOfBits - MEMBERS = const char* numberOfElements - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_spd -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in spd */ - const char* numberOfBits; - const char* numberOfElements; -} grib_accessor_spd; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_spd = { - &grib_accessor_class_long, /* super */ - "spd", /* name */ - sizeof(grib_accessor_spd), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_spd = &_grib_accessor_class_spd; - -/* END_CLASS_IMP */ - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static long compute_byte_count(grib_accessor* a) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - long numberOfBits; - long numberOfElements; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfBits); - return 0; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - return 0; - } - numberOfElements++; - - return (numberOfBits * numberOfElements + 7) / 8; -} - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - int n = 0; - self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->length = compute_byte_count(a); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - int i; - int ret = 0; - long pos = a->offset * 8; - long rlen = 0; - long numberOfBits = 0; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size (%ld) for %s it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - if (numberOfBits > 64) { - grib_context_log(a->context, GRIB_LOG_ERROR,"Invalid number of bits: %ld",numberOfBits); - return GRIB_DECODING_ERROR; - } - - for (i = 0; i < rlen - 1; i++) - val[i] = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); - - val[rlen - 1] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits); - - *len = rlen; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - int ret = 0; - long off = 0; - long numberOfBits = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - long rlen = 0; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (*len != rlen) { - ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, (*len) - 1); - if (ret) return ret; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - - buflen = compute_byte_count(a); - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); - - for (i = 0; i < rlen - 1; i++) { - grib_encode_unsigned_longb(buf, val[i], &off, numberOfBits); - } - - grib_encode_signed_longb(buf, val[rlen - 1], &off, numberOfBits); - - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_free(a->context, buf); - - *len = rlen; - return ret; -} - -static int value_count(grib_accessor* a, long* numberOfElements) -{ - grib_accessor_spd* self = (grib_accessor_spd*)a; - int ret; - *numberOfElements = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - return ret; - } - (*numberOfElements)++; - - return ret; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; -} - -static long next_offset(grib_accessor* a) -{ - return byte_offset(a) + a->length; -} diff --git a/src/grib_accessor_class_spectral_truncation.cc b/src/grib_accessor_class_spectral_truncation.cc deleted file mode 100644 index 6cc902fa7..000000000 --- a/src/grib_accessor_class_spectral_truncation.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init - MEMBERS=const char* J - MEMBERS=const char* K - MEMBERS=const char* M - MEMBERS=const char* T - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_spectral_truncation -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in spectral_truncation */ - const char* J; - const char* K; - const char* M; - const char* T; -} grib_accessor_spectral_truncation; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_spectral_truncation = { - &grib_accessor_class_long, /* super */ - "spectral_truncation", /* name */ - sizeof(grib_accessor_spectral_truncation), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_spectral_truncation = &_grib_accessor_class_spectral_truncation; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_spectral_truncation* self = (grib_accessor_spectral_truncation*)a; - int n = 0; - - self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->K = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->M = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->T = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_spectral_truncation* self = (grib_accessor_spectral_truncation*)a; - int ret = 0; - - long J, K, M, T, Tc; - - if (*len < 1) - return GRIB_ARRAY_TOO_SMALL; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->J, &J)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->K, &K)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->M, &M)) != GRIB_SUCCESS) - return ret; - - Tc = -1; - if (J == K && K == M) { - /* Triangular truncation */ - Tc = (M + 1) * (M + 2); - } - if (K == J + M) { - /* Rhomboidal truncation */ - Tc = 2 * J * M; - } - if (J == K && K > M) { - /* Trapezoidal truncation */ - Tc = M * (2 * J - M); - } - *val = Tc; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->T, &T)) != GRIB_SUCCESS) { - if (Tc == -1) - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s. Spectral Truncation Type Unknown: %s=%ld %s=%ld %s=%ld", - a->name, self->J, J, self->K, K, self->M, M); - Tc = 0; - grib_set_long(grib_handle_of_accessor(a), self->T, Tc); - } - else { - if (Tc != -1 && Tc != T) - grib_set_long(grib_handle_of_accessor(a), self->T, Tc); - } - - if (ret == GRIB_SUCCESS) - *len = 1; - - return ret; -} diff --git a/src/grib_accessor_class_statistics_spectral.cc b/src/grib_accessor_class_statistics_spectral.cc deleted file mode 100644 index 435582bef..000000000 --- a/src/grib_accessor_class_statistics_spectral.cc +++ /dev/null @@ -1,277 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_vector - IMPLEMENTS = unpack_double; destroy - IMPLEMENTS = value_count;compare - IMPLEMENTS = init - MEMBERS = const char* values - MEMBERS = const char* J - MEMBERS = const char* K - MEMBERS = const char* M - MEMBERS = const char* JS - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_statistics_spectral -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; - /* Members defined in statistics_spectral */ - const char* values; - const char* J; - const char* K; - const char* M; - const char* JS; -} grib_accessor_statistics_spectral; - -extern grib_accessor_class* grib_accessor_class_abstract_vector; - -static grib_accessor_class _grib_accessor_class_statistics_spectral = { - &grib_accessor_class_abstract_vector, /* super */ - "statistics_spectral", /* name */ - sizeof(grib_accessor_statistics_spectral), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_statistics_spectral = &_grib_accessor_class_statistics_spectral; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_statistics_spectral* self = (grib_accessor_statistics_spectral*)a; - int n = 0; - - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->K = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->M = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->JS = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - - self->number_of_elements = 4; - self->v = (double*)grib_context_malloc(a->context, - sizeof(double) * self->number_of_elements); - - a->length = 0; - a->dirty = 1; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_statistics_spectral* self = (grib_accessor_statistics_spectral*)a; - int ret = 0, i = 0; - double* values; - size_t size = 0; - long J, K, M, N; - double avg, enorm, sd; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); - - if (!a->dirty) - return GRIB_SUCCESS; - - if (*len != self->number_of_elements) - return GRIB_ARRAY_TOO_SMALL; - - if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long(grib_handle_of_accessor(a), self->J, &J)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long(grib_handle_of_accessor(a), self->K, &K)) != GRIB_SUCCESS) - return ret; - - if ((ret = grib_get_long(grib_handle_of_accessor(a), self->M, &M)) != GRIB_SUCCESS) - return ret; - - if (J != M || M != K) - return GRIB_NOT_IMPLEMENTED; - - N = (M + 1) * (M + 2) / 2; - - if (2 * N != size) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "wrong number of components for spherical harmonics %ld != %ld", 2 * N, size); - return GRIB_WRONG_ARRAY_SIZE; - } - - values = (double*)grib_context_malloc(c, size * sizeof(double)); - if (!values) - return GRIB_OUT_OF_MEMORY; - - if ((ret = grib_get_double_array_internal(h, self->values, values, &size)) != GRIB_SUCCESS) { - grib_context_free(c, values); - return ret; - } - - avg = values[0]; - sd = 0; - - for (i = 2; i < 2 * J; i += 2) - sd += values[i] * values[i]; - - for (i = 2 * J; i < size; i += 2) - sd += 2 * values[i] * values[i] + 2 * values[i + 1] * values[i + 1]; - - enorm = sd + avg * avg; - - sd = sqrt(sd); - enorm = sqrt(enorm); - - a->dirty = 0; - - grib_context_free(c, values); - - self->v[0] = avg; - self->v[1] = enorm; - self->v[2] = sd; - self->v[3] = sd == 0 ? 1 : 0; - - for (i = 0; i < self->number_of_elements; i++) - val[i] = self->v[i]; - - return ret; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_statistics_spectral* self = (grib_accessor_statistics_spectral*)a; - *count = self->number_of_elements; - return 0; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_statistics_spectral* self = (grib_accessor_statistics_spectral*)a; - grib_context_free(c, self->v); -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = GRIB_SUCCESS; - double* aval = 0; - double* bval = 0; - - size_t alen = 0; - size_t blen = 0; - int err = 0; - long count = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - b->dirty = 1; - a->dirty = 1; - - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - - retval = GRIB_SUCCESS; - for (size_t i=0; icontext, aval); - grib_context_free(b->context, bval); - - return retval; -} diff --git a/src/grib_accessor_class_step_human_readable.cc b/src/grib_accessor_class_step_human_readable.cc deleted file mode 100644 index 557a58185..000000000 --- a/src/grib_accessor_class_step_human_readable.cc +++ /dev/null @@ -1,169 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include "step.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;unpack_string; get_native_type - MEMBERS = const char* stepUnits - MEMBERS = const char* step - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_step_human_readable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in step_human_readable */ - const char* stepUnits; - const char* step; -} grib_accessor_step_human_readable; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_step_human_readable = { - &grib_accessor_class_gen, /* super */ - "step_human_readable", /* name */ - sizeof(grib_accessor_step_human_readable), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_step_human_readable = &_grib_accessor_class_step_human_readable; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - grib_accessor_step_human_readable* self = (grib_accessor_step_human_readable*)a; - int n = 0; - grib_handle* h = grib_handle_of_accessor(a); - - self->stepUnits = grib_arguments_get_name(h, params, n++); - self->step = grib_arguments_get_name(h, params, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int get_step_human_readable(grib_handle* h, char* result, size_t* length) -{ - int err = 0; - size_t slen = 2; - long step, hour, minute, second; - - /* Change units to seconds (highest resolution) - * before computing the step value - */ - if ((err = grib_set_string(h, "stepUnits", "s", &slen)) != GRIB_SUCCESS) - return err; - if ((err = grib_get_long(h, "step", &step)) != GRIB_SUCCESS) - return err; - - hour = step/3600; - minute = step/60 % 60; - second = step % 60; - /* sprintf(result, "%ld:%ld:%ld", hour, minute, second); */ - - if (second) { - snprintf(result, 1024, "%ldh %ldm %lds", hour, minute, second); - } else { - if (minute) snprintf(result, 1024, "%ldh %ldm", hour, minute); - else snprintf(result, 1024, "%ldh", hour); - } - - *length = strlen(result); - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_step_human_readable* self = (grib_accessor_step_human_readable*)a; - grib_handle* h = grib_handle_of_accessor(a); - long stepUnits; - int err = 0; - - /* Save the current value of stepUnits */ - err = grib_get_long_internal(h, self->stepUnits, &stepUnits); - if (err) return err; - - /* This will change stepUnits to seconds for its calculation */ - err = get_step_human_readable(h, buffer, len); - - /* Restore stepUnits */ - grib_set_long(h, self->stepUnits, stepUnits); - return err; -} diff --git a/src/grib_accessor_class_sum.cc b/src/grib_accessor_class_sum.cc deleted file mode 100644 index 4d964fc0c..000000000 --- a/src/grib_accessor_class_sum.cc +++ /dev/null @@ -1,203 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_double - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = value_count - IMPLEMENTS = init - MEMBERS=const char* values - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_sum -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in sum */ - const char* values; -} grib_accessor_sum; - -extern grib_accessor_class* grib_accessor_class_double; - -static grib_accessor_class _grib_accessor_class_sum = { - &grib_accessor_class_double, /* super */ - "sum", /* name */ - sizeof(grib_accessor_sum), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_sum = &_grib_accessor_class_sum; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_sum* self = (grib_accessor_sum*)a; - int n = 0; - self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_sum* self = (grib_accessor_sum*)a; - int ret = 0; - size_t size = 0; - long* values = 0; - long i; - long count = 0; - - ret = value_count(a, &count); - if (ret) - return ret; - size = count; - - if (size == 0) { - *val = 0; - return GRIB_SUCCESS; - } - values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - if (!values) - return GRIB_OUT_OF_MEMORY; - - grib_get_long_array(grib_handle_of_accessor(a), self->values, values, &size); - - *val = 0; - for (i = 0; i < size; i++) - *val += values[i]; - - grib_context_free(a->context, values); - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_sum* self = (grib_accessor_sum*)a; - int ret = 0; - size_t size = 0; - double* values = 0; - long i; - long count = 0; - - ret = value_count(a, &count); - if (ret) - return ret; - size = count; - - if (size == 0) { - *val = 0; - return GRIB_SUCCESS; - } - values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); - if (!values) - return GRIB_OUT_OF_MEMORY; - - ret = grib_get_double_array(grib_handle_of_accessor(a), self->values, values, &size); - if (ret) { - grib_context_free(a->context, values); - return ret; - } - *val = 0; - for (i = 0; i < size; i++) - *val += values[i]; - - grib_context_free(a->context, values); - - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_sum* self = (grib_accessor_sum*)a; - size_t n = 0; - int ret = 0; - - ret = grib_get_size(grib_handle_of_accessor(a), self->values, &n); - *count = n; - - if (ret) - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s is unable to get size of %s", a->name, self->values); - - return ret; -} diff --git a/src/grib_accessor_class_suppressed.cc b/src/grib_accessor_class_suppressed.cc deleted file mode 100644 index a95269c5d..000000000 --- a/src/grib_accessor_class_suppressed.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = value_count;get_native_type - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init - MEMBERS= grib_arguments* args - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int value_count(grib_accessor*, long*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_suppressed -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in suppressed */ - grib_arguments* args; -} grib_accessor_suppressed; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_suppressed = { - &grib_accessor_class_long, /* super */ - "suppressed", /* name */ - sizeof(grib_accessor_suppressed), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_suppressed = &_grib_accessor_class_suppressed; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_suppressed* self = (grib_accessor_suppressed*)a; - self->args = c; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static void log_message(grib_accessor* a) -{ - grib_accessor_suppressed* self = (grib_accessor_suppressed*)a; - int i = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_context_log(a->context, GRIB_LOG_ERROR, - "key '%s' is unavailable in this version.", a->name); - grib_context_log(a->context, GRIB_LOG_ERROR, - "Please use the following key(s):"); - while (grib_arguments_get_name(hand, self->args, i)) { - grib_context_log(a->context, GRIB_LOG_ERROR, "\t- %s", - grib_arguments_get_name(hand, self->args, i)); - i++; - } -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - log_message(a); - return GRIB_NOT_FOUND; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - log_message(a); - return GRIB_NOT_FOUND; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - log_message(a); - return GRIB_NOT_FOUND; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} diff --git a/src/grib_accessor_class_time.cc b/src/grib_accessor_class_time.cc deleted file mode 100644 index a90f4415a..000000000 --- a/src/grib_accessor_class_time.cc +++ /dev/null @@ -1,211 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_string - IMPLEMENTS = init;dump - MEMBERS=const char* hour - MEMBERS=const char* minute - MEMBERS=const char* second - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_time -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in time */ - const char* hour; - const char* minute; - const char* second; -} grib_accessor_time; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_time = { - &grib_accessor_class_long, /* super */ - "time", /* name */ - sizeof(grib_accessor_time), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_time = &_grib_accessor_class_time; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_time* self = (grib_accessor_time*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->hour = grib_arguments_get_name(hand, c, n++); - self->minute = grib_arguments_get_name(hand, c, n++); - self->second = grib_arguments_get_name(hand, c, n++); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - int ret = 0; - grib_accessor_time* self = (grib_accessor_time*)a; - long hour = 0; - long minute = 0; - long second = 0; - grib_handle* hand = grib_handle_of_accessor(a); - - if ((ret = grib_get_long_internal(hand, self->hour, &hour)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->minute, &minute)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->second, &second)) != GRIB_SUCCESS) - return ret; - - /* We ignore the 'seconds' in our time calculation! */ - if (second != 0) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Key %s (%s): Truncating time: non-zero seconds(%ld) ignored", a->name, __func__, second); - } - - if (*len < 1) - return GRIB_WRONG_ARRAY_SIZE; - - *val = hour * 100 + minute; - - if (hour == 255) { - *val = 12 * 100; - } - if (hour != 255 && minute == 255) { - *val = hour * 100; - } - return GRIB_SUCCESS; -} - -/* TODO: Check for a valid date */ - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int ret = 0; - long v = val[0]; - grib_accessor_time* self = (grib_accessor_time*)a; - grib_handle* hand = grib_handle_of_accessor(a); - long hour = 0; - long minute = 0; - long second = 0; - - if (*len != 1) - return GRIB_WRONG_ARRAY_SIZE; - - hour = v / 100; - minute = v % 100; - second = 0; /* We ignore the 'seconds' in our time calculation! */ - - if ((ret = grib_set_long_internal(hand, self->hour, hour)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(hand, self->minute, minute)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_set_long_internal(hand, self->second, second)) != GRIB_SUCCESS) - return ret; - - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - long v = 0; - size_t lsize = 1, lmin = 5; - - unpack_long(a, &v, &lsize); - - if (*len < lmin) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - a->cclass->name, a->name, lmin, *len); - *len = lmin; - return GRIB_BUFFER_TOO_SMALL; - } - - snprintf(val, 64, "%04ld", v); - - len[0] = lmin; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_to_double.cc b/src/grib_accessor_class_to_double.cc deleted file mode 100644 index 69b06add9..000000000 --- a/src/grib_accessor_class_to_double.cc +++ /dev/null @@ -1,241 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - MEMBERS = const char* key - MEMBERS = long start - MEMBERS = size_t length - MEMBERS = long scale - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_to_double -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in to_double */ - const char* key; - long start; - size_t length; - long scale; -} grib_accessor_to_double; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_to_double = { - &grib_accessor_class_gen, /* super */ - "to_double", /* name */ - sizeof(grib_accessor_to_double), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_to_double = &_grib_accessor_class_to_double; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - - self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); - self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); - self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); - self->scale = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 3); - if (!self->scale) - self->scale = 1; - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - size_t size = 0; - - int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); - *count = size; - - return err; -} - -static size_t string_length(grib_accessor* a) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - size_t size = 0; - - if (self->length) - return self->length; - - grib_get_string_length_acc(a, &size); - return size; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - - int err = 0; - char buff[512] = {0,}; - size_t size = 512; - size_t length = string_length(a); - - if (*len < length + 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", - *len, a->name, a->length + 1); - *len = length + 1; - return GRIB_ARRAY_TOO_SMALL; - } - - err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); - if (err) - return err; - if (length > size) { - err = GRIB_STRING_TOO_SMALL; - length = size; - } - - memcpy(val, buff + self->start, length); - - val[length] = 0; - *len = length; - return err; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - char val[1024] = {0,}; - size_t l = sizeof(val); - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - *v = strtol(val, &last, 10); - if (*last) { - err = GRIB_WRONG_CONVERSION; - } - *v /= self->scale; - - return err; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - grib_accessor_to_double* self = (grib_accessor_to_double*)a; - char val[1024] = {0,}; - size_t l = sizeof(val); - char* last = NULL; - int err = grib_unpack_string(a, val, &l); - - if (err) - return err; - - *v = strtod(val, &last); - if (*last) { - err = GRIB_WRONG_CONVERSION; - } - *v /= self->scale; - - return err; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/grib_accessor_class_to_integer.cc b/src/grib_accessor_class_to_integer.cc deleted file mode 100644 index 76ce1205d..000000000 --- a/src/grib_accessor_class_to_integer.cc +++ /dev/null @@ -1,245 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - MEMBERS = const char* key - MEMBERS = long start - MEMBERS = size_t length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_to_integer -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in to_integer */ - const char* key; - long start; - size_t length; -} grib_accessor_to_integer; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_to_integer = { - &grib_accessor_class_gen, /* super */ - "to_integer", /* name */ - sizeof(grib_accessor_to_integer), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_to_integer = &_grib_accessor_class_to_integer; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_to_integer* self = (grib_accessor_to_integer*)a; - - self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); - self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); - self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_to_integer* self = (grib_accessor_to_integer*)a; - size_t size = 0; - - int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); - *count = size; - - return err; -} - -static size_t string_length(grib_accessor* a) -{ - grib_accessor_to_integer* self = (grib_accessor_to_integer*)a; - size_t size = 0; - - if (self->length) - return self->length; - - grib_get_string_length(grib_handle_of_accessor(a), self->key, &size); - return size; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_to_integer* self = (grib_accessor_to_integer*)a; - - int err = 0; - char buff[512] = {0,}; - size_t size = 512; - - size_t length = string_length(a); - - if (*len < length + 1) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, length+1, *len); - *len = length + 1; - return GRIB_BUFFER_TOO_SMALL; - } - - err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); - if (err) - return err; - if (length > size) { - /*err=GRIB_STRING_TOO_SMALL;*/ - length = size; - } - - memcpy(val, buff + self->start, length); - - val[length] = 0; - *len = length; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_long(grib_accessor* a, const long* v, size_t* len) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as an integer", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int pack_double(grib_accessor* a, const double* v, size_t* len) -{ - grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as a double", a->name); - return GRIB_NOT_IMPLEMENTED; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - char* last = NULL; - int err = unpack_string(a, val, &l); - - if (err) - return err; - - *v = strtol(val, &last, 10); - /* if (*last) {err=GRIB_WRONG_CONVERSION;} */ - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - size_t l = 1; - long val = 0; - int err = unpack_long(a, &val, &l); - - *v = (double)val; - return err; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/grib_accessor_class_to_string.cc b/src/grib_accessor_class_to_string.cc deleted file mode 100644 index 648edd1aa..000000000 --- a/src/grib_accessor_class_to_string.cc +++ /dev/null @@ -1,227 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_string - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_double - IMPLEMENTS = init;dump;string_length - IMPLEMENTS = value_count - IMPLEMENTS = next_offset - IMPLEMENTS = get_native_type - MEMBERS = const char* key - MEMBERS = long start - MEMBERS = size_t length - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_to_string -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in to_string */ - const char* key; - long start; - size_t length; -} grib_accessor_to_string; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_to_string = { - &grib_accessor_class_gen, /* super */ - "to_string", /* name */ - sizeof(grib_accessor_to_string), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_to_string = &_grib_accessor_class_to_string; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - grib_accessor_to_string* self = (grib_accessor_to_string*)a; - - self->key = grib_arguments_get_name(grib_handle_of_accessor(a), arg, 0); - self->start = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1); - self->length = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 2); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->length = 0; -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_to_string* self = (grib_accessor_to_string*)a; - size_t size = 0; - - int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); - *count = size; - - return err; -} - -static size_t string_length(grib_accessor* a) -{ - grib_accessor_to_string* self = (grib_accessor_to_string*)a; - - if (self->length) - return self->length; - - size_t size = 0; - grib_get_string_length(grib_handle_of_accessor(a), self->key, &size); - return size; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_string(dumper, a, NULL); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_STRING; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_to_string* self = (grib_accessor_to_string*)a; - - int err = 0; - char buff[512] = {0,}; - - size_t length = string_length(a); - - if (*len < length + 1) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, length+1, *len); - *len = length + 1; - return GRIB_BUFFER_TOO_SMALL; - } - - size_t size = sizeof(buff); - err = grib_get_string(grib_handle_of_accessor(a), self->key, buff, &size); - if (err) - return err; - if (length > size) { - /*err=GRIB_STRING_TOO_SMALL;*/ - length = size; - } - - memcpy(val, buff + self->start, length); - - val[length] = 0; - *len = length; - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* v, size_t* len) -{ - char val[1024] = {0,}; - size_t l = sizeof(val); - char* last = NULL; - int err = unpack_string(a, val, &l); - - if (err) - return err; - - *v = strtol(val, &last, 10); - if (*last) { - err = GRIB_WRONG_CONVERSION; - } - - return err; -} - -static int unpack_double(grib_accessor* a, double* v, size_t* len) -{ - size_t l = 1; - long val = 0; - int err = unpack_long(a, &val, &l); - - *v = (double)val; - return err; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} diff --git a/src/grib_accessor_class_transient.cc b/src/grib_accessor_class_transient.cc deleted file mode 100644 index c51886c20..000000000 --- a/src/grib_accessor_class_transient.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_variable - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - - -typedef struct grib_accessor_transient -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in variable */ - double dval; - float fval; - char* cval; - char* cname; - int type; - /* Members defined in transient */ -} grib_accessor_transient; - -extern grib_accessor_class* grib_accessor_class_variable; - -static grib_accessor_class _grib_accessor_class_transient = { - &grib_accessor_class_variable, /* super */ - "transient", /* name */ - sizeof(grib_accessor_transient), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_transient = &_grib_accessor_class_transient; - -/* END_CLASS_IMP */ diff --git a/src/grib_accessor_class_transient_darray.cc b/src/grib_accessor_class_transient_darray.cc deleted file mode 100644 index ba830849a..000000000 --- a/src/grib_accessor_class_transient_darray.cc +++ /dev/null @@ -1,214 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_long;pack_long;destroy - IMPLEMENTS = init;dump;value_count - IMPLEMENTS = get_native_type - MEMBERS=grib_darray* arr - MEMBERS=int type; - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_transient_darray -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in transient_darray */ - grib_darray* arr; - int type; -} grib_accessor_transient_darray; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_transient_darray = { - &grib_accessor_class_gen, /* super */ - "transient_darray", /* name */ - sizeof(grib_accessor_transient_darray), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_transient_darray = &_grib_accessor_class_transient_darray; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long length, grib_arguments* args) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - self->arr = NULL; - self->type = GRIB_TYPE_DOUBLE; - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_double(dumper, a, NULL); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - - if (self->arr) - grib_darray_delete(a->context, self->arr); - self->arr = grib_darray_new(a->context, *len, 10); - - for (size_t i = 0; i < *len; i++) - grib_darray_push(a->context, self->arr, val[i]); - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - - if (self->arr) - grib_darray_delete(a->context, self->arr); - self->arr = grib_darray_new(a->context, *len, 10); - - for (size_t i = 0; i < *len; i++) - grib_darray_push(a->context, self->arr, (double)val[i]); - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - long count = 0; - - value_count(a, &count); - - if (*len < count) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %ld, required %ld) ", a->name, *len, count); - return GRIB_ARRAY_TOO_SMALL; - } - - *len = count; - for (size_t i = 0; i < *len; i++) - val[i] = self->arr->v[i]; - - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - long count = 0; - - value_count(a, &count); - - if (*len < count) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s (setting %ld, required %ld) ", a->name, *len, count); - return GRIB_ARRAY_TOO_SMALL; - } - - *len = count; - for (size_t i = 0; i < *len; i++) - val[i] = (long)self->arr->v[i]; - - return GRIB_SUCCESS; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - if (self->arr) - grib_darray_delete(a->context, self->arr); -} - -static int value_count(grib_accessor* a, long* count) -{ - grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - if (self->arr) - *count = grib_darray_used_size(self->arr); - else - *count = 0; - - return 0; -} - -static int get_native_type(grib_accessor* a) -{ - const grib_accessor_transient_darray* self = (grib_accessor_transient_darray*)a; - return self->type; -} diff --git a/src/grib_accessor_class_trim.cc b/src/grib_accessor_class_trim.cc deleted file mode 100644 index 21948ab82..000000000 --- a/src/grib_accessor_class_trim.cc +++ /dev/null @@ -1,170 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_ascii - IMPLEMENTS = unpack_string;pack_string - IMPLEMENTS = init; string_length - MEMBERS= const char* input - MEMBERS= int trim_left - MEMBERS= int trim_right - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_trim -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in ascii */ - /* Members defined in trim */ - const char* input; - int trim_left; - int trim_right; -} grib_accessor_trim; - -extern grib_accessor_class* grib_accessor_class_ascii; - -static grib_accessor_class _grib_accessor_class_trim = { - &grib_accessor_class_ascii, /* super */ - "trim", /* name */ - sizeof(grib_accessor_trim), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_trim = &_grib_accessor_class_trim; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long l, grib_arguments* arg) -{ - int n = 0; - grib_accessor_trim* self = (grib_accessor_trim*)a; - grib_handle* h = grib_handle_of_accessor(a); - - self->input = grib_arguments_get_name(h, arg, n++); - self->trim_left = grib_arguments_get_long(h, arg, n++); - self->trim_right= grib_arguments_get_long(h, arg, n++); - DEBUG_ASSERT(self->trim_left == 0 || self->trim_left == 1); - DEBUG_ASSERT(self->trim_right == 0 || self->trim_right == 1); -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_trim* self = (grib_accessor_trim*)a; - - int err = 0; - grib_handle* h = grib_handle_of_accessor(a); - char input[256] = {0,}; - size_t size = sizeof(input) / sizeof(*input); - char* pInput = input; - - err = grib_get_string(h, self->input, input, &size); - if (err) return err; - - string_lrtrim(&pInput, self->trim_left, self->trim_right); - snprintf(val, 1024, "%s", pInput); - size = strlen(val); - *len = size + 1; - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - char input[256] = {0,}; - - size_t inputLen = 256; - char buf[256] = {0,}; - char* pBuf = NULL; - int err; - grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_trim* self = (grib_accessor_trim*)a; - grib_accessor* inputAccesstor = grib_find_accessor(h, self->input); - if (!inputAccesstor) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor for %s not found", self->input); - return GRIB_NOT_FOUND; - } - - if ((err = grib_get_string(h, self->input, input, &inputLen)) != GRIB_SUCCESS) - return err; - - snprintf(buf, sizeof(buf), "%s", val); - pBuf = buf; - string_lrtrim(&pBuf, self->trim_left, self->trim_right); - - return grib_pack_string(inputAccesstor, pBuf, len); -} - -static size_t string_length(grib_accessor* a) -{ - return 1024; -} diff --git a/src/grib_accessor_class_uint16.cc b/src/grib_accessor_class_uint16.cc deleted file mode 100644 index 4bac26b59..000000000 --- a/src/grib_accessor_class_uint16.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint16 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint16 */ -} grib_accessor_uint16; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint16 = { - &grib_accessor_class_gen, /* super */ - "uint16", /* name */ - sizeof(grib_accessor_uint16), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint16 = &_grib_accessor_class_uint16; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - /*long pos = a->offset;*/ - /*unsigned char* data = grib_handle_of_accessor(a)->buffer->data;*/ - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - *val = value; - *len = 1; - return GRIB_NOT_IMPLEMENTED; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_uint32.cc b/src/grib_accessor_class_uint32.cc deleted file mode 100644 index b45b7451f..000000000 --- a/src/grib_accessor_class_uint32.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint32 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint32 */ -} grib_accessor_uint32; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint32 = { - &grib_accessor_class_gen, /* super */ - "uint32", /* name */ - sizeof(grib_accessor_uint32), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint32 = &_grib_accessor_class_uint32; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - /* long pos = a->offset; */ - /* unsigned char* data = grib_handle_of_accessor(a)->buffer->data; */ - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - *val = value; - *len = 1; - return GRIB_NOT_IMPLEMENTED; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_uint32_little_endian.cc b/src/grib_accessor_class_uint32_little_endian.cc deleted file mode 100644 index 3e39e0586..000000000 --- a/src/grib_accessor_class_uint32_little_endian.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint32_little_endian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint32_little_endian */ -} grib_accessor_uint32_little_endian; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint32_little_endian = { - &grib_accessor_class_gen, /* super */ - "uint32_little_endian", /* name */ - sizeof(grib_accessor_uint32_little_endian), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint32_little_endian = &_grib_accessor_class_uint32_little_endian; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - /* long pos = a->offset; */ - /* unsigned char* data = grib_handle_of_accessor(a)->buffer->data; */ - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - *val = value; - *len = 1; - return GRIB_NOT_IMPLEMENTED; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_uint64.cc b/src/grib_accessor_class_uint64.cc deleted file mode 100644 index 20bd7e194..000000000 --- a/src/grib_accessor_class_uint64.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint64 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint64 */ -} grib_accessor_uint64; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint64 = { - &grib_accessor_class_gen, /* super */ - "uint64", /* name */ - sizeof(grib_accessor_uint64), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint64 = &_grib_accessor_class_uint64; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; - unsigned long long result = 0, tmp; - int i; - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < 8; i++) { - result <<= 8; - result |= data[pos + i]; - } - - value = result; - tmp = value; - - /* Result does not fit in long */ - if (tmp != result) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name, result); - return GRIB_DECODING_ERROR; - } - - *val = value; - *len = 1; - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_uint64_little_endian.cc b/src/grib_accessor_class_uint64_little_endian.cc deleted file mode 100644 index 0553aefbf..000000000 --- a/src/grib_accessor_class_uint64_little_endian.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint64_little_endian -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint64_little_endian */ -} grib_accessor_uint64_little_endian; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint64_little_endian = { - &grib_accessor_class_gen, /* super */ - "uint64_little_endian", /* name */ - sizeof(grib_accessor_uint64_little_endian), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint64_little_endian = &_grib_accessor_class_uint64_little_endian; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; - unsigned long long result = 0, tmp; - int i; - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 7; i >= 0; i--) { - result <<= 8; - result |= data[pos + i]; - } - - value = result; - tmp = value; - - /* Result does not fit in long */ - if (tmp != result) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Value for %s cannot be decoded as a 'long' (%llu)", a->name, result); - return GRIB_DECODING_ERROR; - } - - *val = value; - *len = 1; - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_uint8.cc b/src/grib_accessor_class_uint8.cc deleted file mode 100644 index 3f4195eff..000000000 --- a/src/grib_accessor_class_uint8.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_long - IMPLEMENTS = get_native_type - END_CLASS_DEF - -*/ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int unpack_long(grib_accessor*, long* val, size_t* len); - -typedef struct grib_accessor_uint8 -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in uint8 */ -} grib_accessor_uint8; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_uint8 = { - &grib_accessor_class_gen, /* super */ - "uint8", /* name */ - sizeof(grib_accessor_uint8), /* size */ - 0, /* inited */ - 0, /* init_class */ - 0, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_uint8 = &_grib_accessor_class_uint8; - -/* END_CLASS_IMP */ - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - long value = 0; - long pos = a->offset; - unsigned char* data = grib_handle_of_accessor(a)->buffer->data; - - if (*len < 1) { - return GRIB_ARRAY_TOO_SMALL; - } - - value = data[pos]; - - *val = value; - *len = 1; - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_accessor_class_unexpanded_descriptors.cc b/src/grib_accessor_class_unexpanded_descriptors.cc deleted file mode 100644 index b583ce5cd..000000000 --- a/src/grib_accessor_class_unexpanded_descriptors.cc +++ /dev/null @@ -1,242 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = next_offset - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size - MEMBERS = grib_accessor* unexpandedDescriptorsEncoded - MEMBERS = const char* createNewData - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_unexpanded_descriptors -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unexpanded_descriptors */ - grib_accessor* unexpandedDescriptorsEncoded; - const char* createNewData; -} grib_accessor_unexpanded_descriptors; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_unexpanded_descriptors = { - &grib_accessor_class_long, /* super */ - "unexpanded_descriptors", /* name */ - sizeof(grib_accessor_unexpanded_descriptors), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_unexpanded_descriptors = &_grib_accessor_class_unexpanded_descriptors; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - self->unexpandedDescriptorsEncoded = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); - self->createNewData = grib_arguments_get_name(hand, args, n++); - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a; - int ret = 0; - long pos = 0; - long rlen = 0; - long f, x, y; - long* v = val; - long i; - grib_handle* hand = grib_handle_of_accessor(a); - - pos = accessor_raw_get_offset(self->unexpandedDescriptorsEncoded) * 8; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (rlen == 0) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "No descriptors in section 3. Malformed message."); - return GRIB_MESSAGE_MALFORMED; - } - - if (*len < rlen) { - /* grib_context_log(a->context, GRIB_LOG_ERROR, */ - /* " wrong size (%ld) for %s it contains %d values ",*len, a->name , rlen); */ - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - for (i = 0; i < rlen; i++) { - f = grib_decode_unsigned_long(hand->buffer->data, &pos, 2); - x = grib_decode_unsigned_long(hand->buffer->data, &pos, 6); - y = grib_decode_unsigned_long(hand->buffer->data, &pos, 8); - *v++ = f * 100000 + x * 1000 + y; - } - *len = rlen; - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a; - int ret = 0; - long pos = 0; - unsigned long f, x, y; - unsigned char* buf = NULL; - grib_accessor* expanded = NULL; - size_t buflen = *len * 2; - size_t i = 0, length = *len; - long createNewData = 1; - grib_handle* hand = grib_handle_of_accessor(a); - - grib_get_long(hand, self->createNewData, &createNewData); - - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen); - - for (i = 0; i < length; i++) { - const long tmp = val[i] % 100000; - f = val[i] / 100000; - x = tmp / 1000; - y = tmp % 1000; - grib_encode_unsigned_longb(buf, f, &pos, 2); - grib_encode_unsigned_longb(buf, x, &pos, 6); - grib_encode_unsigned_longb(buf, y, &pos, 8); - } - - grib_pack_bytes(self->unexpandedDescriptorsEncoded, buf, &buflen); - grib_context_free(hand->context, buf); - - if (createNewData == 0) - return ret; - - expanded = grib_find_accessor(hand, "expandedCodes"); - Assert(expanded != NULL); - ret = grib_accessor_class_expanded_descriptors_set_do_expand(expanded, 1); - if (ret != GRIB_SUCCESS) - return ret; - - ret = grib_set_long(hand, "unpack", 3); /* BUFR new data */ - if (ret != GRIB_SUCCESS) - return ret; - - ret = grib_set_long(hand, "unpack", 1); /* Unpack structure */ - - return ret; -} - -static int value_count(grib_accessor* a, long* numberOfUnexpandedDescriptors) -{ - grib_accessor_unexpanded_descriptors* self = (grib_accessor_unexpanded_descriptors*)a; - long n = 0; - - grib_value_count(self->unexpandedDescriptorsEncoded, &n); - *numberOfUnexpandedDescriptors = n / 2; - - return 0; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; -} - -static long next_offset(grib_accessor* a) -{ - return byte_offset(a) + a->length; -} diff --git a/src/grib_accessor_class_unpack_bufr_values.cc b/src/grib_accessor_class_unpack_bufr_values.cc deleted file mode 100644 index cac0cdfd7..000000000 --- a/src/grib_accessor_class_unpack_bufr_values.cc +++ /dev/null @@ -1,207 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump - IMPLEMENTS = unpack_string;unpack_string_array;unpack_long; unpack_double - IMPLEMENTS = pack_long; pack_double - IMPLEMENTS = value_count; destroy; get_native_type; - MEMBERS = grib_accessor* data_accessor - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static int unpack_string_array(grib_accessor*, char**, size_t* len); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_unpack_bufr_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in unpack_bufr_values */ - grib_accessor* data_accessor; -} grib_accessor_unpack_bufr_values; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_unpack_bufr_values = { - &grib_accessor_class_gen, /* super */ - "unpack_bufr_values", /* name */ - sizeof(grib_accessor_unpack_bufr_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - &unpack_string_array, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_unpack_bufr_values = &_grib_accessor_class_unpack_bufr_values; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* params) -{ - char* key; - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); - self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); - - a->length = 0; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ -} - -static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_unpack_double(data, 0, 0); -} - -static int unpack_string(grib_accessor* a, char* buffer, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - strcpy(buffer, "0"); - *len=1; - - return grib_unpack_double(data, 0, 0); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_unpack_double(data, 0, 0); -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_unpack_double(data, 0, 0); -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static void destroy(grib_context* context, grib_accessor* a) -{ -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_LONG; -} - -// static const char* mode_to_str(int p) -// { -// if (p==CODES_BUFR_UNPACK_STRUCTURE) return "CODES_BUFR_UNPACK_STRUCTURE"; -// if (p==CODES_BUFR_UNPACK_FLAT) return "CODES_BUFR_UNPACK_FLAT"; -// if (p==CODES_BUFR_NEW_DATA) return "CODES_BUFR_NEW_DATA"; -// return "unknown proc flag"; -// } - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int unpackMode = CODES_BUFR_UNPACK_STRUCTURE; - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - if (*val == 2) - unpackMode = CODES_BUFR_UNPACK_FLAT; - if (*val == 3) - unpackMode = CODES_BUFR_NEW_DATA; - - accessor_bufr_data_array_set_unpackMode(data, unpackMode); - - return grib_unpack_double(data, 0, 0); -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_unpack_bufr_values* self = (grib_accessor_unpack_bufr_values*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; - - return grib_unpack_double(data, 0, 0); -} diff --git a/src/grib_accessor_class_unsigned_bits.cc b/src/grib_accessor_class_unsigned_bits.cc deleted file mode 100644 index 026d4ff67..000000000 --- a/src/grib_accessor_class_unsigned_bits.cc +++ /dev/null @@ -1,271 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long;pack_long - IMPLEMENTS = init;dump - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = value_count - IMPLEMENTS = byte_offset - IMPLEMENTS = update_size - MEMBERS = const char* numberOfBits - MEMBERS = const char* numberOfElements - - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); - -typedef struct grib_accessor_unsigned_bits -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in unsigned_bits */ - const char* numberOfBits; - const char* numberOfElements; -} grib_accessor_unsigned_bits; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_unsigned_bits = { - &grib_accessor_class_long, /* super */ - "unsigned_bits", /* name */ - sizeof(grib_accessor_unsigned_bits), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_unsigned_bits = &_grib_accessor_class_unsigned_bits; - -/* END_CLASS_IMP */ - - -static long compute_byte_count(grib_accessor* a) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - long numberOfBits; - long numberOfElements; - int ret = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfBits); - return 0; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, &numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - return 0; - } - - return (numberOfBits * numberOfElements + 7) / 8; -} - - -static void init(grib_accessor* a, const long len, grib_arguments* args) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - int n = 0; - self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->length = compute_byte_count(a); -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - int ret = 0; - long pos = a->offset * 8; - long rlen = 0; - long numberOfBits = 0; - - ret = value_count(a, &rlen); - if (ret) - return ret; - - if (*len < rlen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size (%ld) for %s, it contains %ld values", *len, a->name, rlen); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) - return ret; - if (numberOfBits == 0) { - int i; - for (i = 0; i < rlen; i++) - val[i] = 0; - return GRIB_SUCCESS; - } - - grib_decode_long_array(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits, rlen, val); - - *len = rlen; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - int ret = 0; - long off = 0; - long numberOfBits = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - long rlen = 0; - ret = value_count(a, &rlen); - if (ret) return ret; - - /* - if(*len < rlen) - { - grib_context_log(a->context, GRIB_LOG_ERROR, - "Wrong size for %s it contains %d values ", a->name , rlen ); - return GRIB_ARRAY_TOO_SMALL; - } - */ - if (*len != rlen) - ret = grib_set_long(grib_handle_of_accessor(a), self->numberOfElements, *len); - if (ret) return ret; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits); - if (ret) return ret; - if (numberOfBits == 0) { - grib_buffer_replace(a, NULL, 0, 1, 1); - return GRIB_SUCCESS; - } - - buflen = compute_byte_count(a); - buf = (unsigned char*)grib_context_malloc_clear(a->context, buflen + sizeof(long)); - - for (i = 0; i < *len; i++) - grib_encode_unsigned_longb(buf, val[i], &off, numberOfBits); - - grib_buffer_replace(a, buf, buflen, 1, 1); - - grib_context_free(a->context, buf); - - return ret; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int value_count(grib_accessor* a, long* numberOfElements) -{ - grib_accessor_unsigned_bits* self = (grib_accessor_unsigned_bits*)a; - int ret; - *numberOfElements = 0; - - ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfElements, numberOfElements); - if (ret) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s unable to get %s to compute size", a->name, self->numberOfElements); - } - - return ret; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static void update_size(grib_accessor* a, size_t s) -{ - a->length = s; -} - -static long next_offset(grib_accessor* a) -{ - return byte_offset(a) + a->length; -} diff --git a/src/grib_accessor_class_validity_date.cc b/src/grib_accessor_class_validity_date.cc deleted file mode 100644 index 8182228ae..000000000 --- a/src/grib_accessor_class_validity_date.cc +++ /dev/null @@ -1,235 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = init;dump - MEMBERS=const char* date - MEMBERS=const char* time - MEMBERS=const char* step - MEMBERS=const char* stepUnits - MEMBERS=const char* year - MEMBERS=const char* month - MEMBERS=const char* day - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_validity_date -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in validity_date */ - const char* date; - const char* time; - const char* step; - const char* stepUnits; - const char* year; - const char* month; - const char* day; -} grib_accessor_validity_date; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_validity_date = { - &grib_accessor_class_long, /* super */ - "validity_date", /* name */ - sizeof(grib_accessor_validity_date), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_validity_date = &_grib_accessor_class_validity_date; - -/* END_CLASS_IMP */ - -/* Table of multipliers to convert step units to minutes */ -static const double u2m[] = { - 1, /* index 0: minutes */ - 60, /* index 1: hour */ - 24 * 60, /* index 2: day */ - 24 * 60 * 30, /* index 3: month */ - -1, /* index 4: year */ - -1, /* index 5: decade */ - -1, /* index 6: 30 years */ - -1, /* index 7: century */ - -1, /* index 8: RESERVED */ - -1, /* index 9: RESERVED */ - 3 * 60, /* index 10: 3 hours */ - 6 * 60, /* index 11: 6 hours */ - 12 * 60, /* index 12: 12 hours */ - 1 / 60.0, /* index 13: seconds */ - 15, /* index 14: 15 mins */ - 30 /* index 15: 30 mins */ -}; - -static long convert_to_minutes(long step, long stepUnits) -{ - double result = 0; - if (stepUnits == 0) - return step; /* unit=minutes so no change */ - if (stepUnits == 1) - return step * 60; /* unit=hours */ - if (stepUnits == 13) - return step / 60; /* unit=seconds */ - /* Assert( stepUnits < sizeof(u2m)/sizeof(u2m[0]) ); */ - - result = step * u2m[stepUnits]; - return (long)result; -} - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_validity_date* self = (grib_accessor_validity_date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->date = grib_arguments_get_name(hand, c, n++); - self->time = grib_arguments_get_name(hand, c, n++); - self->step = grib_arguments_get_name(hand, c, n++); - self->stepUnits = grib_arguments_get_name(hand, c, n++); - self->year = grib_arguments_get_name(hand, c, n++); - self->month = grib_arguments_get_name(hand, c, n++); - self->day = grib_arguments_get_name(hand, c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_validity_date* self = (grib_accessor_validity_date*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - long date = 0; - long time = 0; - long step = 0; - long stepUnits = 0; - long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs; - - if (self->year) { - long year, month, day; - if ((ret = grib_get_long_internal(hand, self->year, &year)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->month, &month)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->day, &day)) != GRIB_SUCCESS) - return ret; - *val = year * 10000 + month * 100 + day; - return GRIB_SUCCESS; - } - if ((ret = grib_get_long_internal(hand, self->date, &date)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->time, &time)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long(hand, self->step, &step)) != GRIB_SUCCESS) { - if ((ret = grib_get_long_internal(hand, "endStep", &step)) != GRIB_SUCCESS) { - return ret; /* See ECC-817 */ - } - } - - if (self->stepUnits) { - if ((ret = grib_get_long_internal(hand, self->stepUnits, &stepUnits)) != GRIB_SUCCESS) - return ret; - step_mins = convert_to_minutes(step, stepUnits); - } - - minutes = time % 100; - hours = time / 100; - tmp = minutes + step_mins; /* add the step to our minutes */ - tmp_hrs = tmp / 60; /* how many hours and mins is that? */ - hours += tmp_hrs; /* increment hours */ - - date = grib_date_to_julian(date); - /* does the new 'hours' exceed 24? if so increment julian */ - while (hours >= 24) { - date++; - hours -= 24; - } - /* GRIB-29: Negative forecast time */ - while (hours < 0) { - date--; - hours += 24; - } - - if (*len < 1) - return GRIB_ARRAY_TOO_SMALL; - - *val = grib_julian_to_date(date); - - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_validity_time.cc b/src/grib_accessor_class_validity_time.cc deleted file mode 100644 index 0b2c9697f..000000000 --- a/src/grib_accessor_class_validity_time.cc +++ /dev/null @@ -1,255 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_long - IMPLEMENTS = unpack_long - IMPLEMENTS = unpack_string - IMPLEMENTS = init;dump - MEMBERS=const char* date - MEMBERS=const char* time - MEMBERS=const char* step - MEMBERS=const char* stepUnits - MEMBERS=const char* hours - MEMBERS=const char* minutes - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_validity_time -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in long */ - /* Members defined in validity_time */ - const char* date; - const char* time; - const char* step; - const char* stepUnits; - const char* hours; - const char* minutes; -} grib_accessor_validity_time; - -extern grib_accessor_class* grib_accessor_class_long; - -static grib_accessor_class _grib_accessor_class_validity_time = { - &grib_accessor_class_long, /* super */ - "validity_time", /* name */ - sizeof(grib_accessor_validity_time), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - &unpack_long, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_validity_time = &_grib_accessor_class_validity_time; - -/* END_CLASS_IMP */ - -/* Table of multipliers to convert step units to minutes */ -static const double u2m[] = { - 1, /* index 0: minutes */ - 60, /* index 1: hour */ - 24 * 60, /* index 2: day */ - 24 * 60 * 30, /* index 3: month */ - -1, /* index 4: year */ - -1, /* index 5: decade */ - -1, /* index 6: 30 years */ - -1, /* index 7: century */ - -1, /* index 8: RESERVED */ - -1, /* index 9: RESERVED */ - 3 * 60, /* index 10: 3 hours */ - 6 * 60, /* index 11: 6 hours */ - 12 * 60, /* index 12: 12 hours */ - 1 / 60.0, /* index 13: seconds */ - 15, /* index 14: 15 mins */ - 30 /* index 15: 30 mins */ -}; - -static long convert_to_minutes(long step, long stepUnits) -{ - double result = 0; - if (stepUnits == 0) - return step; /* unit=minutes so no change */ - if (stepUnits == 1) - return step * 60; /* unit=hours */ - if (stepUnits == 13) - return step / 60; /* unit=seconds*/ - /* Assert( stepUnits < sizeof(u2m)/sizeof(u2m[0]) ); */ - - result = step * u2m[stepUnits]; - return (long)result; -} - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_validity_time* self = (grib_accessor_validity_time*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; - - self->date = grib_arguments_get_name(hand, c, n++); - self->time = grib_arguments_get_name(hand, c, n++); - self->step = grib_arguments_get_name(hand, c, n++); - self->stepUnits = grib_arguments_get_name(hand, c, n++); - self->hours = grib_arguments_get_name(hand, c, n++); - self->minutes = grib_arguments_get_name(hand, c, n++); - - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_long(dumper, a, NULL); -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_validity_time* self = (grib_accessor_validity_time*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - long date = 0; - long time = 0; - long step = 0; - long stepUnits = 0; - long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs, tmp_mins; - - if (self->hours) { - if ((ret = grib_get_long_internal(hand, self->hours, &hours)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->minutes, &minutes)) != GRIB_SUCCESS) - return ret; - *val = hours * 100 + minutes; - return GRIB_SUCCESS; - } - if ((ret = grib_get_long_internal(hand, self->date, &date)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long_internal(hand, self->time, &time)) != GRIB_SUCCESS) - return ret; - if ((ret = grib_get_long(hand, self->step, &step)) != GRIB_SUCCESS) { - if ((ret = grib_get_long_internal(hand, "endStep", &step)) != GRIB_SUCCESS) { - return ret; /* See ECC-817 */ - } - } - - /* Seconds will always be zero. So convert to minutes */ - if (self->stepUnits) { - if ((ret = grib_get_long_internal(hand, self->stepUnits, &stepUnits)) != GRIB_SUCCESS) - return ret; - step_mins = convert_to_minutes(step, stepUnits); - } - - minutes = time % 100; - hours = time / 100; - tmp = minutes + step_mins; /* add the step to our minutes */ - tmp_hrs = tmp / 60; /* how many hours and mins is that? */ - tmp_mins = tmp % 60; - hours += tmp_hrs; /* increment hours */ - if (hours > 0) { - hours = hours % 24; /* wrap round if >= 24 */ - } - else { - /* GRIB-29: Negative forecast time */ - while (hours < 0) { - hours += 24; - } - } - time = hours * 100 + tmp_mins; - - if (*len < 1) - return GRIB_ARRAY_TOO_SMALL; - - *val = time; - - return GRIB_SUCCESS; -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - int err = 0; - long v = 0; - size_t lsize = 1, lmin = 5; - - err = unpack_long(a, &v, &lsize); - if (err) return err; - - if (*len < lmin) { - const char* cclass_name = a->cclass->name; - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, lmin, *len); - *len = lmin; - return GRIB_BUFFER_TOO_SMALL; - } - - snprintf(val, 64, "%04ld", v); - - len[0] = lmin; - return GRIB_SUCCESS; -} diff --git a/src/grib_accessor_class_values.cc b/src/grib_accessor_class_values.cc deleted file mode 100644 index 3e69cf56e..000000000 --- a/src/grib_accessor_class_values.cc +++ /dev/null @@ -1,263 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init - IMPLEMENTS = dump - IMPLEMENTS = next_offset - IMPLEMENTS = byte_count - IMPLEMENTS = byte_offset - IMPLEMENTS = get_native_type - IMPLEMENTS = update_size - IMPLEMENTS = compare - IMPLEMENTS = pack_long - MEMBERS= int carg - MEMBERS= const char* seclen - MEMBERS= const char* offsetdata - MEMBERS= const char* offsetsection - MEMBERS= int dirty - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static long byte_count(grib_accessor*); -static long byte_offset(grib_accessor*); -static long next_offset(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static void update_size(grib_accessor*, size_t); -static int compare(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_values -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in values */ - int carg; - const char* seclen; - const char* offsetdata; - const char* offsetsection; - int dirty; -} grib_accessor_values; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_values = { - &grib_accessor_class_gen, /* super */ - "values", /* name */ - sizeof(grib_accessor_values), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - &next_offset, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - &byte_count, /* get number of bytes */ - &byte_offset, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - &update_size, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_values = &_grib_accessor_class_values; - -/* END_CLASS_IMP */ -static long init_length(grib_accessor* a) -{ - grib_accessor_values* self = (grib_accessor_values*)a; - int ret = 0; - - long seclen = 0; - long offsetsection = 0; - long offsetdata = 0; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->seclen, &seclen))) - return ret; - - if (seclen == 0) { - /* printf("init_length seclen=0\n"); */ - return 0; - } - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetsection, &offsetsection))) - return ret; - - if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->offsetdata, &offsetdata))) - return ret; - - /* When reparsing */ - if (offsetdata < offsetsection) { - /* printf("init_length offsetdata < offsetsection=0\n"); */ - Assert(grib_handle_of_accessor(a)->loader); - return 0; - } - - return seclen - (offsetdata - offsetsection); -} - -static void init(grib_accessor* a, const long v, grib_arguments* params) -{ - grib_accessor_values* self = (grib_accessor_values*)a; - self->carg = 0; - - self->seclen = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); - self->offsetdata = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); - self->offsetsection = grib_arguments_get_name(grib_handle_of_accessor(a), params, self->carg++); - self->dirty = 1; - - a->length = init_length(a); - /* Assert(a->length>=0); */ -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_DOUBLE; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_dump_values(dumper, a); -} - -static long byte_count(grib_accessor* a) -{ - grib_context_log(a->context, GRIB_LOG_DEBUG, "byte_count of %s = %ld", a->name, a->length); - return a->length; -} - -static long byte_offset(grib_accessor* a) -{ - return a->offset; -} - -static long next_offset(grib_accessor* a) -{ - return a->offset + a->length; -} - -static void update_size(grib_accessor* a, size_t s) -{ - grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); - a->length = s; - Assert(a->length >= 0); -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - double* aval = 0; - double* bval = 0; - - size_t alen = 0; - size_t blen = 0; - int err = 0; - long count = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - - retval = GRIB_SUCCESS; - while (alen != 0) { - if (*bval != *aval) - retval = GRIB_DOUBLE_VALUE_MISMATCH; - alen--; - } - - grib_context_free(a->context, aval); - grib_context_free(b->context, bval); - - return retval; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - int ret = 0; - grib_accessor_values* self = (grib_accessor_values*)a; - int i; - double* dval = (double*)grib_context_malloc(a->context, *len * sizeof(double)); - - for (i = 0; i < *len; i++) - dval[i] = (double)val[i]; - - ret = grib_pack_double(a, dval, len); - - grib_context_free(a->context, dval); - - self->dirty = 1; - - return ret; -} diff --git a/src/grib_accessor_class_variable.cc b/src/grib_accessor_class_variable.cc deleted file mode 100644 index 9d12e04cf..000000000 --- a/src/grib_accessor_class_variable.cc +++ /dev/null @@ -1,456 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -#include -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = unpack_double;pack_double - IMPLEMENTS = unpack_float; pack_float - IMPLEMENTS = unpack_string;pack_string;string_length - IMPLEMENTS = unpack_long;pack_long;destroy;byte_count - IMPLEMENTS = init;dump;value_count;get_native_type - IMPLEMENTS = compare; make_clone - MEMBERS=double dval - MEMBERS=float fval - MEMBERS=char* cval - MEMBERS=char* cname - MEMBERS=int type - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static int pack_double(grib_accessor*, const double* val, size_t* len); -static int pack_float(grib_accessor*, const float* val, size_t* len); -static int pack_long(grib_accessor*, const long* val, size_t* len); -static int pack_string(grib_accessor*, const char*, size_t* len); -static int unpack_double(grib_accessor*, double* val, size_t* len); -static int unpack_float(grib_accessor*, float* val, size_t* len); -static int unpack_long(grib_accessor*, long* val, size_t* len); -static int unpack_string(grib_accessor*, char*, size_t* len); -static size_t string_length(grib_accessor*); -static long byte_count(grib_accessor*); -static int value_count(grib_accessor*, long*); -static void destroy(grib_context*, grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int compare(grib_accessor*, grib_accessor*); -static grib_accessor* make_clone(grib_accessor*, grib_section*, int*); - -typedef struct grib_accessor_variable -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in variable */ - double dval; - float fval; - char* cval; - char* cname; - int type; -} grib_accessor_variable; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_variable = { - &grib_accessor_class_gen, /* super */ - "variable", /* name */ - sizeof(grib_accessor_variable), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - &string_length, /* get length of string */ - &value_count, /* get number of values */ - &byte_count, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - &pack_long, /* pack_long */ - &unpack_long, /* unpack_long */ - &pack_double, /* pack_double */ - &pack_float, /* pack_float */ - &unpack_double, /* unpack_double */ - &unpack_float, /* unpack_float */ - &pack_string, /* pack_string */ - &unpack_string, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - &compare, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - &make_clone, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_variable = &_grib_accessor_class_variable; - -/* END_CLASS_IMP */ - -#define MAX_VARIABLE_STRING_LENGTH 255 - -static void init(grib_accessor* a, const long length, grib_arguments* args) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - grib_handle* hand = grib_handle_of_accessor(a); - grib_expression* expression = grib_arguments_get_expression(hand, args, 0); - const char* p = 0; - size_t len = 1; - long l; - int ret = 0; - double d; - self->cname = NULL; - - a->length = 0; - if (self->type == GRIB_TYPE_UNDEFINED && expression) { - self->type = grib_expression_native_type(hand, expression); - - switch (self->type) { - 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; - - 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: %s", - a->name, grib_get_error_message(ret)); - return; - } - len = strlen(p) + 1; - pack_string(a, p, &len); - break; - } - } - } -} - -void accessor_variable_set_type(grib_accessor* a, int type) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - self->type = type; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - switch (self->type) { - case GRIB_TYPE_DOUBLE: - grib_dump_double(dumper, a, NULL); - break; - - case GRIB_TYPE_LONG: - grib_dump_long(dumper, a, NULL); - break; - - default: - grib_dump_string(dumper, a, NULL); - break; - } -} - -static int pack_double(grib_accessor* a, const double* val, size_t* len) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - const double dval = *val; - - if (*len != 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values", a->name, 1); - *len = 1; - return GRIB_ARRAY_TOO_SMALL; - } - - self->dval = dval; - if (dval < (double)LONG_MIN || dval > (double)LONG_MAX) - self->type = GRIB_TYPE_DOUBLE; - else - self->type = ((long)dval == dval) ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE; - - return GRIB_SUCCESS; -} - -static int pack_float(grib_accessor* a, const float* val, size_t* len) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - const double fval = *val; - - if (*len != 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); - *len = 1; - return GRIB_ARRAY_TOO_SMALL; - } - - self->fval = fval; - if (fval < (float)LONG_MIN || fval > (float)LONG_MAX) - self->type = GRIB_TYPE_DOUBLE; - else - self->type = ((long)fval == fval) ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE; - - return GRIB_SUCCESS; -} - -static int pack_long(grib_accessor* a, const long* val, size_t* len) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - - if (*len != 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 1; - return GRIB_ARRAY_TOO_SMALL; - } - - self->dval = *val; - self->fval = *val; - self->type = GRIB_TYPE_LONG; - - return GRIB_SUCCESS; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - *val = self->dval; - *len = 1; - return GRIB_SUCCESS; -} - -static int unpack_float(grib_accessor* a, float* val, size_t* len) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s, it contains %d values", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - *val = self->fval; - *len = 1; - return GRIB_SUCCESS; -} - -static int unpack_long(grib_accessor* a, long* val, size_t* len) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - - if (*len < 1) { - grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size for %s it contains %d values ", a->name, 1); - *len = 0; - return GRIB_ARRAY_TOO_SMALL; - } - *val = (long)self->dval; - *len = 1; - return GRIB_SUCCESS; -} - -static int get_native_type(grib_accessor* a) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - return self->type; -} - -static void destroy(grib_context* c, grib_accessor* a) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - int i = 0; - - grib_context_free(c, self->cval); - if (self->cname) - grib_context_free(c, self->cname); /* ECC-765 */ - - /* Note: BUFR operator descriptors are variables and have attributes so need to free them */ - while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { - grib_accessor_delete(c, a->attributes[i]); - a->attributes[i] = NULL; - ++i; - } -} - -static int unpack_string(grib_accessor* a, char* val, size_t* len) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - - char buf[80]; - char* p = buf; - size_t slen = 0; - - if (self->type == GRIB_TYPE_STRING) { - p = self->cval; - } - else { - snprintf(p, 64, "%g", self->dval); - } - - slen = strlen(p) + 1; - if (*len < slen) { - grib_context_log(a->context, GRIB_LOG_ERROR, - "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - a->cclass->name, a->name, slen, *len); - *len = slen; - return GRIB_BUFFER_TOO_SMALL; - } - strcpy(val, p); - *len = slen; - - return GRIB_SUCCESS; -} - -static int pack_string(grib_accessor* a, const char* val, size_t* len) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - grib_context* c = a->context; - - grib_context_free(c, self->cval); - self->cval = grib_context_strdup(c, val); - self->dval = atof(val); - self->fval = atof(val); - self->type = GRIB_TYPE_STRING; - self->cname = NULL; - return GRIB_SUCCESS; -} - -static int value_count(grib_accessor* a, long* count) -{ - *count = 1; - return 0; -} - -static size_t string_length(grib_accessor* a) -{ - grib_accessor_variable* self = (grib_accessor_variable*)a; - if (self->type == GRIB_TYPE_STRING) - return strlen(self->cval); - else - return MAX_VARIABLE_STRING_LENGTH; -} - -static long byte_count(grib_accessor* a) -{ - return a->length; -} - -static int compare(grib_accessor* a, grib_accessor* b) -{ - int retval = 0; - double* aval = 0; - double* bval = 0; - - size_t alen = 0; - size_t blen = 0; - int err = 0; - long count = 0; - - err = grib_value_count(a, &count); - if (err) - return err; - alen = count; - - err = grib_value_count(b, &count); - if (err) - return err; - blen = count; - - if (alen != blen) - return GRIB_COUNT_MISMATCH; - - aval = (double*)grib_context_malloc(a->context, alen * sizeof(double)); - bval = (double*)grib_context_malloc(b->context, blen * sizeof(double)); - - grib_unpack_double(a, aval, &alen); - grib_unpack_double(b, bval, &blen); - - retval = GRIB_SUCCESS; - while (alen != 0) { - if (*bval != *aval) - retval = GRIB_DOUBLE_VALUE_MISMATCH; - alen--; - } - - grib_context_free(a->context, aval); - grib_context_free(b->context, bval); - - return retval; -} - -static grib_accessor* make_clone(grib_accessor* a, grib_section* s, int* err) -{ - grib_accessor* the_clone = NULL; - grib_accessor_variable* self = (grib_accessor_variable*)a; - grib_accessor_variable* variableAccessor = NULL; - grib_action creator = {0,}; - creator.op = (char*)"variable"; - creator.name_space = (char*)""; - creator.set = 0; - - creator.name = grib_context_strdup(a->context, a->name); - the_clone = grib_accessor_factory(s, &creator, 0, NULL); - the_clone->parent = NULL; - the_clone->h = s->h; - the_clone->flags = a->flags; - variableAccessor = (grib_accessor_variable*)the_clone; - variableAccessor->cname = creator.name; /* ECC-765: Store for later freeing memory */ - - *err = 0; - variableAccessor->type = self->type; - if (self->type == GRIB_TYPE_STRING && self->cval != NULL) { - variableAccessor->cval = grib_context_strdup(a->context, self->cval); - } - else { - variableAccessor->dval = self->dval; - variableAccessor->fval = self->fval; - } - - return the_clone; -} diff --git a/src/grib_accessor_class_vector.cc b/src/grib_accessor_class_vector.cc deleted file mode 100644 index 1cc69a4c7..000000000 --- a/src/grib_accessor_class_vector.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -/************************************** - * Enrico Fucile - **************************************/ - - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_abstract_vector - IMPLEMENTS = init - IMPLEMENTS = unpack_double - MEMBERS = const char* vector - MEMBERS = int index - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int unpack_double(grib_accessor*, double* val, size_t* len); -static void init(grib_accessor*, const long, grib_arguments*); - -typedef struct grib_accessor_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; - /* Members defined in vector */ - const char* vector; - int index; -} grib_accessor_vector; - -extern grib_accessor_class* grib_accessor_class_abstract_vector; - -static grib_accessor_class _grib_accessor_class_vector = { - &grib_accessor_class_abstract_vector, /* super */ - "vector", /* name */ - sizeof(grib_accessor_vector), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - 0, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - 0, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - &unpack_double, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - 0, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_vector = &_grib_accessor_class_vector; - -/* END_CLASS_IMP */ - -typedef struct grib_accessor_abstract_vector -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in double */ - /* Members defined in abstract_vector */ - double* v; - int number_of_elements; -} grib_accessor_abstract_vector; - -static void init(grib_accessor* a, const long l, grib_arguments* c) -{ - grib_accessor_vector* self = (grib_accessor_vector*)a; - int n = 0; - - self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; - a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; - a->length = 0; -} - -static int unpack_double(grib_accessor* a, double* val, size_t* len) -{ - int err = 0; - size_t size = 0; - double* stat; - grib_accessor_vector* self = (grib_accessor_vector*)a; - grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); - grib_accessor_abstract_vector* v = (grib_accessor_abstract_vector*)va; - - Assert(self->index >= 0); - - if (self->index >= v->number_of_elements) { - grib_context_log(a->context, GRIB_LOG_FATAL, "index=%d number_of_elements=%d for %s", self->index, v->number_of_elements, a->name); - Assert(self->index < v->number_of_elements); - } - - if (va->dirty) { - grib_get_size(grib_handle_of_accessor(a), self->vector, &size); - stat = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); - err = grib_unpack_double(va, stat, &size); - grib_context_free(a->context, stat); - if (err) - return err; - } - - *val = v->v[self->index]; - - return err; -} diff --git a/src/grib_accessor_class_when.cc b/src/grib_accessor_class_when.cc deleted file mode 100644 index 1bf0d999e..000000000 --- a/src/grib_accessor_class_when.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = accessor - SUPER = grib_accessor_class_gen - IMPLEMENTS = init;dump; - IMPLEMENTS = get_native_type - IMPLEMENTS = notify_change - END_CLASS_DEF - - */ - -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "accessor.class" and rerun ./make_class.pl - -*/ - -static int get_native_type(grib_accessor*); -static void dump(grib_accessor*, grib_dumper*); -static void init(grib_accessor*, const long, grib_arguments*); -static int notify_change(grib_accessor*, grib_accessor*); - -typedef struct grib_accessor_when -{ - grib_accessor att; - /* Members defined in gen */ - /* Members defined in when */ -} grib_accessor_when; - -extern grib_accessor_class* grib_accessor_class_gen; - -static grib_accessor_class _grib_accessor_class_when = { - &grib_accessor_class_gen, /* super */ - "when", /* name */ - sizeof(grib_accessor_when), /* size */ - 0, /* inited */ - 0, /* init_class */ - &init, /* init */ - 0, /* post_init */ - 0, /* destroy */ - &dump, /* dump */ - 0, /* next_offset */ - 0, /* get length of string */ - 0, /* get number of values */ - 0, /* get number of bytes */ - 0, /* get offset to bytes */ - &get_native_type, /* get native type */ - 0, /* get sub_section */ - 0, /* pack_missing */ - 0, /* is_missing */ - 0, /* pack_long */ - 0, /* unpack_long */ - 0, /* pack_double */ - 0, /* pack_float */ - 0, /* unpack_double */ - 0, /* unpack_float */ - 0, /* pack_string */ - 0, /* unpack_string */ - 0, /* pack_string_array */ - 0, /* unpack_string_array */ - 0, /* pack_bytes */ - 0, /* unpack_bytes */ - 0, /* pack_expression */ - ¬ify_change, /* notify_change */ - 0, /* update_size */ - 0, /* preferred_size */ - 0, /* resize */ - 0, /* nearest_smaller_value */ - 0, /* next accessor */ - 0, /* compare vs. another accessor */ - 0, /* unpack only ith value (double) */ - 0, /* unpack only ith value (float) */ - 0, /* unpack a given set of elements (double) */ - 0, /* unpack a given set of elements (float) */ - 0, /* unpack a subarray */ - 0, /* clear */ - 0, /* clone accessor */ -}; - - -grib_accessor_class* grib_accessor_class_when = &_grib_accessor_class_when; - -/* END_CLASS_IMP */ - -static void init(grib_accessor* a, const long len, grib_arguments* arg) -{ - a->length = 0; - a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; - a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; -} - -static void dump(grib_accessor* a, grib_dumper* dumper) -{ - /* grib_dump_when(dumper,a,NULL); */ -} - -static int notify_change(grib_accessor* a, grib_accessor* changed) -{ - return grib_action_notify_change(a->creator, a, changed); -} - -static int get_native_type(grib_accessor* a) -{ - return GRIB_TYPE_UNDEFINED; -} diff --git a/src/grib_accessor_classes_hash.cc b/src/grib_accessor_classes_hash.cc index 2643a32fb..5617c9456 100644 --- a/src/grib_accessor_classes_hash.cc +++ b/src/grib_accessor_classes_hash.cc @@ -35,7 +35,7 @@ #include "grib_accessor_class.h" #line 6 "accessor_class_list.gperf" -struct accessor_class_hash { char *name; grib_accessor_class **cclass;}; +struct accessor_class_hash { const char *name; grib_accessor_class **cclass;}; #define TOTAL_KEYWORDS 205 #define MIN_WORD_LENGTH 1 diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index 0b516c99b..335da5954 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -240,26 +240,23 @@ typedef struct grib_action_file grib_action_file; typedef struct grib_action_file_list grib_action_file_list; typedef struct grib_block_of_accessors grib_block_of_accessors; typedef struct grib_buffer grib_buffer; -typedef struct grib_accessor_class grib_accessor_class; +class grib_accessor_class; typedef struct grib_action grib_action; typedef struct grib_action_class grib_action_class; typedef struct grib_section grib_section; -typedef struct grib_packer grib_packer; typedef struct grib_codetable grib_codetable; typedef struct grib_smart_table grib_smart_table; -typedef struct grib_accessor grib_accessor; +class grib_accessor; typedef struct grib_iterator_class grib_iterator_class; typedef struct grib_nearest_class grib_nearest_class; typedef struct grib_dumper grib_dumper; typedef struct grib_dumper_class grib_dumper_class; typedef struct grib_dependency grib_dependency; -typedef struct string_feed string_feed; typedef struct codes_condition codes_condition; -/* typedef void (*dynamic_key_proc) (const char*, void*) -*/ +/* typedef void (*dynamic_key_proc) (const char*, void*) */ typedef void (*nearest_init_class_proc)(grib_nearest_class*); typedef int (*nearest_init_proc)(grib_nearest* i, grib_handle*, grib_arguments*); @@ -282,53 +279,6 @@ typedef long (*iterator_has_next_proc)(grib_iterator* i); typedef int (*grib_pack_proc)(grib_handle* h, const double* in, size_t inlen, void* out, size_t* outlen); typedef int (*grib_unpack_proc)(grib_handle* h, const void* in, size_t inlen, double* out, size_t* outlen); -typedef void (*accessor_destroy_proc)(grib_context*, grib_accessor*); - -typedef int (*accessor_unpack_long_proc)(grib_accessor*, long*, size_t* len); -typedef int (*accessor_unpack_double_proc)(grib_accessor*, double*, size_t* len); -typedef int (*accessor_unpack_float_proc)(grib_accessor*, float*, size_t* len); - -typedef int (*accessor_unpack_double_element_proc)(grib_accessor*, size_t, double*); -typedef int (*accessor_unpack_float_element_proc)(grib_accessor*, size_t, float*); -typedef int (*accessor_unpack_double_element_set_proc)(grib_accessor*, const size_t*, size_t, double*); -typedef int (*accessor_unpack_float_element_set_proc)(grib_accessor*, const size_t*, size_t, float*); - -typedef int (*accessor_unpack_double_subarray_proc)(grib_accessor*, double*, size_t, size_t); -typedef int (*accessor_unpack_string_proc)(grib_accessor*, char*, size_t* len); -typedef int (*accessor_unpack_string_array_proc)(grib_accessor*, char**, size_t* len); -typedef int (*accessor_unpack_bytes_proc)(grib_accessor*, unsigned char*, size_t* len); -typedef int (*accessor_get_native_type_proc)(grib_accessor*); -typedef int (*accessor_notify_change_proc)(grib_accessor*, grib_accessor*); -typedef void (*accessor_update_size_proc)(grib_accessor*, size_t); -typedef size_t (*accessor_preferred_size_proc)(grib_accessor*, int); -typedef void (*accessor_resize_proc)(grib_accessor*, size_t); - -typedef grib_accessor* (*accessor_next_proc)(grib_accessor*, int); -typedef grib_section* (*accessor_sub_section_proc)(grib_accessor*); - -typedef int (*accessor_pack_missing_proc)(grib_accessor*); -typedef int (*accessor_pack_is_missing_proc)(grib_accessor*); -typedef int (*accessor_pack_long_proc)(grib_accessor*, const long*, size_t* len); -typedef int (*accessor_pack_double_proc)(grib_accessor*, const double*, size_t* len); -typedef int (*accessor_pack_float_proc)(grib_accessor*, const float*, size_t* len); -typedef int (*accessor_pack_string_proc)(grib_accessor*, const char*, size_t* len); -typedef int (*accessor_pack_string_array_proc)(grib_accessor*, const char**, size_t* len); -typedef int (*accessor_pack_bytes_proc)(grib_accessor*, const unsigned char*, size_t* len); -typedef int (*accessor_pack_expression_proc)(grib_accessor*, grib_expression*); -typedef int (*accessor_clear_proc)(grib_accessor*); -typedef grib_accessor* (*accessor_clone_proc)(grib_accessor*, grib_section*, int*); - -typedef void (*accessor_init_class_proc)(grib_accessor_class*); - -typedef int (*accessor_compare_proc)(grib_accessor*, grib_accessor*); -typedef size_t (*accessor_string_proc)(grib_accessor*); -typedef int (*accessor_value_with_ret_proc)(grib_accessor*, long*); -typedef long (*accessor_value_proc)(grib_accessor*); -typedef void (*accessor_dump_proc)(grib_accessor*, grib_dumper*); -typedef void (*accessor_init_proc)(grib_accessor*, const long len, grib_arguments*); -typedef void (*accessor_post_init_proc)(grib_accessor*); - -typedef int (*accessor_nearest_proc)(grib_accessor*, double, double*); typedef long (*grib_binop_long_proc)(long, long); typedef long (*grib_unop_long_proc)(long); @@ -338,9 +288,6 @@ typedef double (*grib_unop_double_proc)(double); typedef int (*grib_binop_string_proc)(char*, char*); -typedef struct second_order_packed second_order_packed; -typedef void grib_expression_visit_proc(void* udata, grib_expression* e); - struct grib_key_value_list { const char* name; @@ -355,7 +302,7 @@ struct grib_key_value_list grib_key_value_list* next; }; -struct second_order_packed +/* struct second_order_packed { unsigned long nbits_per_widths; unsigned long nbits_per_group_size; @@ -364,20 +311,7 @@ struct second_order_packed unsigned long* array_of_group_size; unsigned long* array_of_group_width; long* array_of_group_refs; -}; - -/** -* an grib_compression -* Structure supporting the packing and unpacking procedures -* -* @see grib_action_create_data -*/ -struct grib_packer -{ - const char* name; - grib_pack_proc pack; /** < packing procedure */ - grib_unpack_proc unpack; /** < unpacking procedure */ -}; +}; */ /* --------------- */ typedef struct grib_loader grib_loader; @@ -394,7 +328,7 @@ struct grib_loader }; /** -* an action +* An action * Structure supporting the creation of accessor, resulting of a statement during a definition file parsing * * @see grib_action_class @@ -414,16 +348,7 @@ struct grib_action char* debug_info; /** purely for debugging and tracing */ }; -typedef struct grib_accessors_list grib_accessors_list; - -struct grib_accessors_list -{ - grib_accessor* accessor; - int rank; - grib_accessors_list* next; - grib_accessors_list* prev; - grib_accessors_list* last; -}; +class grib_accessors_list; typedef int (*action_create_accessors_handle_proc)(grib_section* p, grib_action* a, grib_loader* h); typedef int (*action_notify_change_proc)(grib_action* a, grib_accessor* observer, grib_accessor* observed); @@ -437,7 +362,7 @@ typedef grib_action* (*action_reparse_proc)(grib_action* a, grib_accessor*, int* typedef int (*action_execute_proc)(grib_action* a, grib_handle*); /** -* an action_class +* An action_class * Structure supporting the specific behaviour of an action * * @see grib_action @@ -464,22 +389,22 @@ struct grib_action_class }; /** -* a buffer +* A buffer * Structure containing the data of a message */ struct grib_buffer { - int property; /** < property parameter of buffer */ - int validity; /** < validity parameter of buffer */ - int growable; /** < buffer can be grown */ - size_t length; /** < Buffer length */ - size_t ulength; /** < length used of the buffer */ - size_t ulength_bits; /** < length used of the buffer in bits */ - unsigned char* data; /** < the data byte array */ + int property; /** < property parameter of buffer */ + int validity; /** < validity parameter of buffer */ + int growable; /** < buffer can be grown */ + size_t length; /** < Buffer length */ + size_t ulength; /** < length used of the buffer */ + size_t ulength_bits; /** < length used of the buffer in bits */ + unsigned char* data; /** < the data byte array */ }; /** -* an Accessor +* An accessor * Structure supporting each single data unit and allowing its access * @see grib_accessor_class */ @@ -498,34 +423,6 @@ struct grib_virtual_value int type; }; -struct grib_accessor -{ - const char* name; /** < name of the accessor */ - const char* name_space; /** < namespace to which the accessor belongs */ - grib_context* context; - grib_handle* h; - grib_action* creator; /** < action that created the accessor */ - long length; /** < byte length of the accessor */ - long offset; /** < offset of the data in the buffer */ - grib_section* parent; /** < section to which the accessor is attached */ - grib_accessor* next; /** < next accessor in list */ - grib_accessor* previous; /** < next accessor in list */ - grib_accessor_class* cclass; /** < behaviour of the accessor */ - unsigned long flags; /** < Various flags */ - grib_section* sub_section; - - const char* all_names[MAX_ACCESSOR_NAMES]; /** < name of the accessor */ - const char* all_name_spaces[MAX_ACCESSOR_NAMES]; /** < namespace to which the accessor belongs */ - int dirty; - - grib_accessor* same; /** < accessors with the same name */ - long loop; /** < used in lists */ - grib_virtual_value* vvalue; /** < virtual value used when transient flag on **/ - const char* set; - grib_accessor* attributes[MAX_ACCESSOR_ATTRIBUTES]; /** < attributes are accessors */ - grib_accessor* parent_as_attribute; -}; - #define GRIB_ACCESSOR_FLAG_READ_ONLY (1 << 1) #define GRIB_ACCESSOR_FLAG_DUMP (1 << 2) #define GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC (1 << 3) @@ -547,7 +444,7 @@ struct grib_accessor #define GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION (1 << 19) /** -* a section accessor +* A section accessor * Structure supporting hierarchical naming of the accessors * @see grib_accessor */ @@ -555,9 +452,9 @@ struct grib_section { grib_accessor* owner; grib_handle* h; /** < Handles of all accessors and buffer */ - grib_accessor* aclength; /** < block of the length of the block */ - grib_block_of_accessors* block; /** < block */ - grib_action* branch; /** < branch that created the block */ + grib_accessor* aclength; /** < block of the length of the block */ + grib_block_of_accessors* block; /** < block */ + grib_action* branch; /** < branch that created the block */ size_t length; size_t padding; }; @@ -567,17 +464,14 @@ struct grib_iterator_class grib_iterator_class** super; const char* name; size_t size; - int inited; iterator_init_class_proc init_class; - - iterator_init_proc init; - iterator_destroy_proc destroy; - - iterator_next_proc next; - iterator_previous_proc previous; - iterator_reset_proc reset; - iterator_has_next_proc has_next; + iterator_init_proc init; + iterator_destroy_proc destroy; + iterator_next_proc next; + iterator_previous_proc previous; + iterator_reset_proc reset; + iterator_has_next_proc has_next; }; struct grib_nearest_class @@ -585,14 +479,11 @@ struct grib_nearest_class grib_nearest_class** super; const char* name; size_t size; - int inited; nearest_init_class_proc init_class; - - nearest_init_proc init; - nearest_destroy_proc destroy; - - nearest_find_proc find; + nearest_init_proc init; + nearest_destroy_proc destroy; + nearest_find_proc find; }; /* --------------- */ @@ -640,18 +531,18 @@ struct grib_dumper_class struct grib_iterator { - grib_arguments* args; /** args of iterator */ + grib_arguments* args; /** args of iterator */ grib_handle* h; - long e; /** current element */ - size_t nv; /** number of values */ - double* data; /** data values */ + long e; /** current element */ + size_t nv; /** number of values */ + double* data; /** data values */ grib_iterator_class* cclass; unsigned long flags; }; struct grib_nearest { - grib_arguments* args; /** args of iterator */ + grib_arguments* args; /** args of iterator */ grib_handle* h; grib_context* context; double* values; @@ -823,10 +714,9 @@ void codes_assertion_failed(const char* message, const char* file, int line); struct grib_handle { - grib_context* context; /** < context attached to this handle */ - grib_buffer* buffer; /** < buffer attached to the handle */ + grib_context* context; /** < context attached to this handle */ + grib_buffer* buffer; /** < buffer attached to the handle */ grib_section* root; /** the root section*/ - grib_section* rules; /** the rules section*/ grib_dependency* dependencies; /** List of dependencies */ grib_handle* main; /** Used during reparsing */ grib_handle* kid; /** Used during reparsing */ @@ -853,79 +743,13 @@ struct grib_handle /* For GRIB2 multi-field messages */ struct grib_multi_handle { - grib_context* context; /** < context attached to this handle */ - grib_buffer* buffer; /** < buffer attached to the handle */ + grib_context* context; /** < context attached to this handle */ + grib_buffer* buffer; /** < buffer attached to the handle */ size_t offset; size_t length; }; -struct grib_accessor_class -{ - grib_accessor_class** super; - const char* name; - size_t size; - - int inited; - accessor_init_class_proc init_class; - - accessor_init_proc init; - accessor_post_init_proc post_init; - accessor_destroy_proc destroy; - - accessor_dump_proc dump; - accessor_value_proc next_offset; - - accessor_string_proc string_length; - accessor_value_with_ret_proc value_count; - - accessor_value_proc byte_count; - accessor_value_proc byte_offset; - - accessor_get_native_type_proc get_native_type; - - accessor_sub_section_proc sub_section; - - accessor_pack_missing_proc pack_missing; - accessor_pack_is_missing_proc is_missing; - - accessor_pack_long_proc pack_long; - accessor_unpack_long_proc unpack_long; - - accessor_pack_double_proc pack_double; - accessor_pack_float_proc pack_float; - accessor_unpack_double_proc unpack_double; - accessor_unpack_float_proc unpack_float; - - accessor_pack_string_proc pack_string; - accessor_unpack_string_proc unpack_string; - - accessor_pack_string_array_proc pack_string_array; - accessor_unpack_string_array_proc unpack_string_array; - - accessor_pack_bytes_proc pack_bytes; - accessor_unpack_bytes_proc unpack_bytes; - - accessor_pack_expression_proc pack_expression; - - accessor_notify_change_proc notify_change; - accessor_update_size_proc update_size; - - accessor_preferred_size_proc preferred_size; - accessor_resize_proc resize; - - accessor_nearest_proc nearest_smaller_value; - accessor_next_proc next; - accessor_compare_proc compare; - accessor_unpack_double_element_proc unpack_double_element; - accessor_unpack_float_element_proc unpack_float_element; - accessor_unpack_double_element_set_proc unpack_double_element_set; - accessor_unpack_float_element_set_proc unpack_float_element_set; - accessor_unpack_double_subarray_proc unpack_double_subarray; - accessor_clear_proc clear; - accessor_clone_proc make_clone; -}; - typedef struct grib_multi_support grib_multi_support; struct grib_multi_support { @@ -1089,24 +913,17 @@ struct grib_expression_class 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_add_dependency_proc add_dependency; - - expression_native_type_proc native_type; - expression_get_name_proc get_name; - - expression_evaluate_long_proc evaluate_long; + expression_init_proc init; + expression_destroy_proc destroy; + expression_print_proc print; + 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; @@ -1223,44 +1040,6 @@ struct grib_fieldset grib_field** fields; }; -/* concept index structures */ - -typedef struct grib_concept_index_key grib_concept_index_key; -typedef struct grib_concept_index grib_concept_index; -typedef struct grib_conditions_tree grib_conditions_tree; -typedef struct grib_concept_entry grib_concept_entry; -typedef struct grib_concept_key grib_concept_key; - -struct grib_concept_index_entry -{ - char* name; - char* value; - int type; - grib_concept_entry* next; -}; - -struct grib_concept_index_key -{ - char* name; - int type; - grib_concept_key* next; -}; - -struct grib_concept_index -{ - grib_context* context; - grib_concept_key* keys; - grib_conditions_tree* conditions; -}; - -struct grib_conditions_tree -{ - char* value; - void* object; - grib_conditions_tree* next; - grib_conditions_tree* next_key; -}; - /* support for in-memory definition and tables */ extern int codes_memfs_exists(const char* path); @@ -1301,7 +1080,6 @@ struct grib_field_list grib_field_list* next; }; - struct grib_index { grib_context* context; @@ -1388,10 +1166,8 @@ struct bufr_keys_iterator grib_trie* seen; }; -/* ----------*/ -/* md5 */ +/* --------- md5 --------*/ typedef unsigned long cvs_uint32; - struct cvs_MD5Context { cvs_uint32 buf[4]; @@ -1425,7 +1201,6 @@ struct grib_case }; /* ----------*/ - typedef struct code_table_entry { char* abbreviation; @@ -1444,7 +1219,7 @@ struct grib_codetable typedef struct grib_smart_table_entry { - /*int code;*/ + /*int code;*/ char* abbreviation; char* column[MAX_SMART_TABLE_COLUMNS]; } grib_smart_table_entry; @@ -1510,6 +1285,8 @@ typedef struct j2k_encode_helper #ifdef __cplusplus } +#include "accessor/grib_accessor.h" +#include "accessor/grib_accessors_list.h" #endif #endif diff --git a/src/grib_buffer.cc b/src/grib_buffer.cc index 525e59f31..cb313141c 100644 --- a/src/grib_buffer.cc +++ b/src/grib_buffer.cc @@ -123,14 +123,14 @@ static void update_offsets(grib_accessor* a, long len) grib_context_log(a->context, GRIB_LOG_DEBUG, "::::: grib_buffer : accessor %s is moving by %d bytes to %ld", a->name, len, a->offset); if (s) update_offsets(s->block->first, len); - a = a->next; + a = a->next_; } } static void update_offsets_after(grib_accessor* a, long len) { while (a) { - update_offsets(a->next, len); + update_offsets(a->next_, len); a = a->parent->owner; } } @@ -152,10 +152,10 @@ static void update_offsets_after(grib_accessor* a, long len) // { // int ret; // if(s->owner) -// plen = grib_get_next_position_offset(s->block->last) - s->owner->offset; +// plen = s->block->last->get_next_position_offset() - s->owner->offset; // else -// plen = grib_get_next_position_offset(s->block->last); -// if((ret = grib_pack_long(s->aclength, &plen, &len)) != GRIB_SUCCESS) +// plen = s->block->last->get_next_position_offset(); +// if((ret = s->aclength->pack_long(&plen, &len)) != GRIB_SUCCESS) // ; // // if(s->h->context->debug) @@ -174,19 +174,19 @@ static void update_offsets_after(grib_accessor* a, long len) // { // int ret; // if(s->owner) -// plen = grib_get_next_position_offset(s->block->last) - s->owner->offset; +// plen = s->block->last->get_next_position_offset() - s->owner->offset; // else -// plen = grib_get_next_position_offset(s->block->last); +// plen = s->block->last->get_next_position_offset(); // /* if(s->owner) */ // /* s->owner->length = plen; */ // /* if(s->aclength) */ -// if((ret = grib_pack_long(s->aclength, &plen, &len)) != GRIB_SUCCESS) +// if((ret = s->aclength->pack_long(&plen, &len)) != GRIB_SUCCESS) // ; // if(s->h->context->debug) // { // printf("SECTION updating length %ld .. %s\n",plen,s->owner->name); // printf("NEXT_POS = %ld, owner offset= %ld %s %s\n", -// grib_get_next_position_offset(s->block->last), +// s->block->last->get_next_position_offset(), // s->owner ? s->owner->offset : 0L, s->owner->name, // s->block->last->name); // } @@ -199,7 +199,7 @@ int grib_buffer_replace(grib_accessor* a, const unsigned char* data, size_t newsize, int update_lengths, int update_paddings) { size_t offset = a->offset; - long oldsize = grib_get_next_position_offset(a) - offset; + long oldsize = a->get_next_position_offset() - offset; long increase = (long)newsize - (long)oldsize; grib_buffer* buffer = grib_handle_of_accessor(a)->buffer; @@ -231,7 +231,7 @@ int grib_buffer_replace(grib_accessor* a, const unsigned char* data, if (increase) { update_offsets_after(a, increase); if (update_lengths) { - grib_update_size(a, newsize); + a->update_size(newsize); int err = grib_section_adjust_sizes(grib_handle_of_accessor(a)->root, 1, 0); if (err) return err; if (update_paddings) diff --git a/src/grib_bufr_descriptor.cc b/src/grib_bufr_descriptor.cc index fcaeeac46..6b7f2b3ce 100644 --- a/src/grib_bufr_descriptor.cc +++ b/src/grib_bufr_descriptor.cc @@ -9,8 +9,9 @@ */ -#include "grib_scaling.h" #include "grib_api_internal.h" +#include "accessor/grib_accessor_class_bufr_data_array.h" +#include "grib_scaling.h" bufr_descriptor* grib_bufr_descriptor_new(grib_accessor* tables_accessor, int code, int silent, int* err) { diff --git a/src/grib_bufr_descriptors_array.cc b/src/grib_bufr_descriptors_array.cc index 0134048a2..637cf14eb 100644 --- a/src/grib_bufr_descriptors_array.cc +++ b/src/grib_bufr_descriptors_array.cc @@ -22,8 +22,7 @@ bufr_descriptors_array* grib_bufr_descriptors_array_new(grib_context* c, size_t v = (bufr_descriptors_array*)grib_context_malloc(c, sizeof(bufr_descriptors_array)); if (!v) { - grib_context_log(c, GRIB_LOG_ERROR, - "bufr_descriptors_array_new unable to allocate %ld bytes\n", sizeof(bufr_descriptors_array)); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptors_array)); return NULL; } v->context = c; @@ -34,7 +33,7 @@ bufr_descriptors_array* grib_bufr_descriptors_array_new(grib_context* c, size_t v->number_of_pop_front = 0; if (!v->v) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_bufr_descriptors_array_new unable to allocate %ld bytes\n", sizeof(bufr_descriptor) * size); + "%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptor) * size); return NULL; } return v; @@ -73,8 +72,7 @@ static bufr_descriptors_array* grib_bufr_descriptors_array_resize_to(bufr_descri newv = (bufr_descriptor**)grib_context_malloc_clear(c, newsize * sizeof(bufr_descriptor*)); if (!newv) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_bufr_descriptors_array_resize unable to allocate %ld bytes\n", sizeof(bufr_descriptor*) * newsize); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(bufr_descriptor*) * newsize); return NULL; } diff --git a/src/grib_context.cc b/src/grib_context.cc index 0c1921138..a22fcc654 100644 --- a/src/grib_context.cc +++ b/src/grib_context.cc @@ -453,7 +453,7 @@ grib_context* grib_context_get_default() #ifdef ECCODES_SAMPLES_PATH if (!default_grib_context.grib_samples_path) - default_grib_context.grib_samples_path = ECCODES_SAMPLES_PATH; + default_grib_context.grib_samples_path = (char*)ECCODES_SAMPLES_PATH; #endif default_grib_context.grib_definition_files_path = codes_getenv("ECCODES_DEFINITION_PATH"); @@ -535,11 +535,10 @@ grib_context* grib_context_get_default() } #endif - grib_context_log(&default_grib_context, GRIB_LOG_DEBUG, "Definitions path: %s", - default_grib_context.grib_definition_files_path); - grib_context_log(&default_grib_context, GRIB_LOG_DEBUG, "Samples path: %s", - default_grib_context.grib_samples_path); - + if (default_grib_context.debug) { + fprintf(stderr, "ECCODES DEBUG Definitions path: %s\n", default_grib_context.grib_definition_files_path); + fprintf(stderr, "ECCODES DEBUG Samples path: %s\n", default_grib_context.grib_samples_path); + } default_grib_context.keys_count = 0; default_grib_context.keys = grib_hash_keys_new(&(default_grib_context), &(default_grib_context.keys_count)); @@ -840,7 +839,6 @@ void grib_context_reset(grib_context* c) void grib_context_delete(grib_context* c) { - size_t i = 0; if (!c) c = grib_context_get_default(); @@ -852,7 +850,7 @@ void grib_context_delete(grib_context* c) if (c != &default_grib_context) grib_context_free_persistent(&default_grib_context, c); - for(i=0; ihash_array[i] = NULL; c->hash_array_count = 0; grib_itrie_delete(c->hash_array_index); diff --git a/src/grib_darray.cc b/src/grib_darray.cc index f2250862d..5aac8265a 100644 --- a/src/grib_darray.cc +++ b/src/grib_darray.cc @@ -45,8 +45,7 @@ grib_darray* grib_darray_new(grib_context* c, size_t size, size_t incsize) c = grib_context_get_default(); v = (grib_darray*)grib_context_malloc_clear(c, sizeof(grib_darray)); if (!v) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_darray_new unable to allocate %zu bytes", sizeof(grib_darray)); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(grib_darray)); return NULL; } v->size = size; @@ -55,8 +54,7 @@ grib_darray* grib_darray_new(grib_context* c, size_t size, size_t incsize) v->context = c; v->v = (double*)grib_context_malloc_clear(c, sizeof(double) * size); if (!v->v) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_darray_new unable to allocate %zu bytes", sizeof(double) * size); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(double) * size); return NULL; } return v; @@ -73,7 +71,7 @@ static grib_darray* grib_darray_resize(grib_darray* v) v->size = newsize; if (!v->v) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_darray_resize unable to allocate %zu bytes", sizeof(double) * newsize); + "%s: Unable to allocate %zu bytes", __func__, sizeof(double) * newsize); return NULL; } return v; diff --git a/src/grib_dependency.cc b/src/grib_dependency.cc index 4c417173e..37c89dbbf 100644 --- a/src/grib_dependency.cc +++ b/src/grib_dependency.cc @@ -124,7 +124,7 @@ int grib_dependency_notify_change(grib_accessor* observed) while (d) { if (d->run) { /*printf("grib_dependency_notify_change %s %s %p\n", observed->name, d->observer ? d->observer->name : "?", (void*)d->observer);*/ - if (d->observer && (ret = grib_accessor_notify_change(d->observer, observed)) != GRIB_SUCCESS) + if (d->observer && (ret = d->observer->notify_change(observed)) != GRIB_SUCCESS) return ret; } d = d->next; @@ -149,7 +149,7 @@ int grib_dependency_notify_change_h(grib_handle* h, grib_accessor* observed) while (d) { if (d->run) { /*printf("grib_dependency_notify_change %s %s %p\n",observed->name,d->observer ? d->observer->name : "?", (void*)d->observer);*/ - if (d->observer && (ret = grib_accessor_notify_change(d->observer, observed)) != GRIB_SUCCESS) + if (d->observer && (ret = d->observer->notify_change(observed)) != GRIB_SUCCESS) return ret; } d = d->next; diff --git a/src/grib_dumper_class.cc b/src/grib_dumper_class.cc index abd1cbf02..4af527151 100644 --- a/src/grib_dumper_class.cc +++ b/src/grib_dumper_class.cc @@ -52,8 +52,8 @@ void grib_dump_accessors_block(grib_dumper* dumper, grib_block_of_accessors* blo { grib_accessor* a = block->first; while (a) { - grib_accessor_dump(a, dumper); - a = a->next; + a->dump(dumper); + a = a->next_; } } @@ -61,8 +61,8 @@ void grib_dump_accessors_list(grib_dumper* dumper, grib_accessors_list* al) { grib_accessors_list* cur = al; while (cur) { - grib_accessor_dump(cur->accessor, dumper); - cur = cur->next; + cur->accessor->dump(dumper); + cur = cur->next_; } } @@ -70,7 +70,7 @@ int grib_print(grib_handle* h, const char* name, grib_dumper* d) { grib_accessor* act = grib_find_accessor(h, name); if (act) { - grib_accessor_dump(act, d); + act->dump(d); return GRIB_SUCCESS; } return GRIB_NOT_FOUND; @@ -106,7 +106,7 @@ void grib_dump_keys(grib_handle* h, FILE* f, const char* mode, unsigned long fla for (i = 0; i < num_keys; ++i) { acc = grib_find_accessor(h, keys[i]); if (acc) - grib_accessor_dump(acc, dumper); + acc->dump(dumper); } grib_dumper_delete(dumper); } diff --git a/src/grib_dumper_class_bufr_decode_C.cc b/src/grib_dumper_class_bufr_decode_C.cc index 49805279b..6811cdf94 100644 --- a/src/grib_dumper_class_bufr_decode_C.cc +++ b/src/grib_dumper_class_bufr_decode_C.cc @@ -150,11 +150,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -220,11 +220,11 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -279,7 +279,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -305,7 +305,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -368,11 +368,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -428,7 +428,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -477,7 +477,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -497,7 +497,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); if (self->isLeaf == 0) { if ((r = compute_bufr_key_rank(h, self->keys, a->name)) != 0) @@ -545,7 +545,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -656,7 +656,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_decode_filter.cc b/src/grib_dumper_class_bufr_decode_filter.cc index 0fff0fc14..87cb0e2fe 100644 --- a/src/grib_dumper_class_bufr_decode_filter.cc +++ b/src/grib_dumper_class_bufr_decode_filter.cc @@ -140,11 +140,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->begin = 0; @@ -199,11 +199,11 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -244,7 +244,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -270,7 +270,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->begin = 0; @@ -353,7 +353,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->begin = 0; self->empty = 0; @@ -399,7 +399,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -457,7 +457,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -569,7 +569,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix /* fprintf(out,"\"%s\" : ",a->attributes[i]->name); */ flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_decode_fortran.cc b/src/grib_dumper_class_bufr_decode_fortran.cc index b07f59b49..dbc4ed271 100644 --- a/src/grib_dumper_class_bufr_decode_fortran.cc +++ b/src/grib_dumper_class_bufr_decode_fortran.cc @@ -142,11 +142,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -202,11 +202,11 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -249,7 +249,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -275,7 +275,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -331,11 +331,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -384,7 +384,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -429,7 +429,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -485,7 +485,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -595,7 +595,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_decode_python.cc b/src/grib_dumper_class_bufr_decode_python.cc index 632cbe98b..3e2edc70a 100644 --- a/src/grib_dumper_class_bufr_decode_python.cc +++ b/src/grib_dumper_class_bufr_decode_python.cc @@ -150,11 +150,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -213,11 +213,11 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); } self->empty = 0; @@ -265,7 +265,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -291,7 +291,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -345,11 +345,11 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size <= 1) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } self->empty = 0; @@ -397,7 +397,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -445,7 +445,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -498,7 +498,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -605,7 +605,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_encode_C.cc b/src/grib_dumper_class_bufr_encode_C.cc index d07825434..915649814 100644 --- a/src/grib_dumper_class_bufr_encode_C.cc +++ b/src/grib_dumper_class_bufr_encode_C.cc @@ -102,13 +102,14 @@ static void init_class(grib_dumper_class* c) {} static int init(grib_dumper* d) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - grib_context* c = d->context; - self->section_offset = 0; - self->empty = 1; - d->count = 1; - self->isLeaf = 0; - self->isAttribute = 0; - self->keys = (grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list)); + + grib_context* c = d->context; + self->section_offset = 0; + self->empty = 1; + d->count = 1; + self->isLeaf = 0; + self->isAttribute = 0; + self->keys = (grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list)); return GRIB_SUCCESS; } @@ -116,9 +117,9 @@ static int init(grib_dumper* d) static int destroy(grib_dumper* d) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - grib_string_list* next = self->keys; - grib_string_list* cur = NULL; - grib_context* c = d->context; + grib_string_list* next = self->keys; + grib_string_list* cur = NULL; + grib_context* c = d->context; while (next) { cur = next; next = next->next; @@ -152,10 +153,11 @@ static char* dval_to_string(grib_context* c, double v) static void dump_values(grib_dumper* d, grib_accessor* a) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - double value = 0; + + double value = 0; size_t size = 0, size2 = 0; - double* values = NULL; - int err = 0; + double* values = NULL; + int err = 0; int i, r, icount; int cols = 2; long count = 0; @@ -166,15 +168,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -248,10 +250,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* prefix) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - double value = 0; + + double value = 0; size_t size = 0, size2 = 0; - double* values = NULL; - int err = 0; + double* values = NULL; + int err = 0; int i, icount; int cols = 2; long count = 0; @@ -261,15 +264,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -333,16 +336,17 @@ static int is_hidden(grib_accessor* a) static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - long value = 0; + + long value = 0; size_t size = 0, size2 = 0; - long* values = NULL; - int err = 0; + long* values = NULL; + int err = 0; int i, r, icount; - int cols = 4; - long count = 0; - char* sval = NULL; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); + int cols = 4; + long count = 0; + char* sval = NULL; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); int doing_unexpandedDescriptors = 0; if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) { /* key does not have the dump attribute */ @@ -353,7 +357,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0); - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -381,10 +385,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -471,10 +475,11 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* prefix) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - long value = 0; + + long value = 0; size_t size = 0, size2 = 0; - long* values = NULL; - int err = 0; + long* values = NULL; + int err = 0; int i, icount; int cols = 4; long count = 0; @@ -483,15 +488,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -552,8 +557,9 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - double value = 0; - size_t size = 1; + + double value = 0; + size_t size = 1; int r; char* sval; grib_handle* h = grib_handle_of_accessor(a); @@ -562,7 +568,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -608,7 +614,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -627,7 +633,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); for (i = 0; i < size - 1; i++) { fprintf(self->dumper.out, " svalues[%lu]=\"%s\"; \n", (unsigned long)i, values[i]); } @@ -667,12 +673,13 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - char* value = NULL; - char* p = NULL; - size_t size = 0; - grib_context* c = a->context; + + char* value = NULL; + char* p = NULL; + size_t size = 0; + grib_context* c = a->context; int r = 0, err = 0; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); const char* acc_name = a->name; grib_get_string_length_acc(a, &size); @@ -690,7 +697,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, acc_name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -814,7 +821,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix) { - int i = 0; + int i = 0; grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; unsigned long flags; while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { @@ -826,7 +833,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; @@ -846,7 +853,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix static void header(grib_dumper* d, grib_handle* h) { grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d; - char sampleName[200] = { 0 }; + char sampleName[200] = { 0 }; long localSectionPresent, edition, bufrHeaderCentre, isSatellite; Assert(h->product_kind == PRODUCT_BUFR); diff --git a/src/grib_dumper_class_bufr_encode_filter.cc b/src/grib_dumper_class_bufr_encode_filter.cc index 49c4d19ef..a90ab0f56 100644 --- a/src/grib_dumper_class_bufr_encode_filter.cc +++ b/src/grib_dumper_class_bufr_encode_filter.cc @@ -144,15 +144,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -234,15 +234,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -306,7 +306,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -333,10 +333,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -416,15 +416,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -489,7 +489,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->begin = 0; self->empty = 0; @@ -538,7 +538,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -563,7 +563,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); fprintf(self->dumper.out, "{"); depth += 2; @@ -624,7 +624,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->begin = 0; self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, a->name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -759,7 +759,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix /* fprintf(out,"\"%s\" : ",a->attributes[i]->name); */ flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_encode_fortran.cc b/src/grib_dumper_class_bufr_encode_fortran.cc index c689867b8..1e6cd3bd7 100644 --- a/src/grib_dumper_class_bufr_encode_fortran.cc +++ b/src/grib_dumper_class_bufr_encode_fortran.cc @@ -103,13 +103,14 @@ static void init_class(grib_dumper_class* c) {} static int init(grib_dumper* d) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - grib_context* c = d->context; - self->section_offset = 0; - self->empty = 1; - d->count = 1; - self->isLeaf = 0; - self->isAttribute = 0; - self->keys = (grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list)); + + grib_context* c = d->context; + self->section_offset = 0; + self->empty = 1; + d->count = 1; + self->isLeaf = 0; + self->isAttribute = 0; + self->keys = (grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list)); return GRIB_SUCCESS; } @@ -117,9 +118,10 @@ static int init(grib_dumper* d) static int destroy(grib_dumper* d) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - grib_string_list* next = self->keys; - grib_string_list* cur = NULL; - grib_context* c = d->context; + + grib_string_list* next = self->keys; + grib_string_list* cur = NULL; + grib_context* c = d->context; while (next) { cur = next; next = next->next; @@ -200,10 +202,11 @@ static char* break_line(grib_context* c, const char* input) static void dump_values(grib_dumper* d, grib_accessor* a) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - double value = 0; + + double value = 0; size_t size = 0, size2 = 0; - double* values = NULL; - int err = 0; + double* values = NULL; + int err = 0; int i, r, icount; int cols = 2; long count = 0; @@ -214,15 +217,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -295,10 +298,11 @@ static void dump_values(grib_dumper* d, grib_accessor* a) static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* prefix) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - double value = 0; + + double value = 0; size_t size = 0, size2 = 0; - double* values = NULL; - int err = 0; + double* values = NULL; + int err = 0; int i, icount; int cols = 2; long count = 0; @@ -308,15 +312,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -381,16 +385,17 @@ static int is_hidden(grib_accessor* a) static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - long value = 0; + + long value = 0; size_t size = 0, size2 = 0; - long* values = NULL; - int err = 0; + long* values = NULL; + int err = 0; int i, r, icount; - int cols = 4; - long count = 0; - char* sval = NULL; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); + int cols = 4; + long count = 0; + char* sval = NULL; + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); int doing_unexpandedDescriptors = 0; if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) { /* key does not have the dump attribute */ @@ -401,7 +406,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0); - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -428,10 +433,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -516,10 +521,11 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* prefix) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - long value = 0; + + long value = 0; size_t size = 0, size2 = 0; - long* values = NULL; - int err = 0; + long* values = NULL; + int err = 0; int i, icount; int cols = 4; long count = 0; @@ -529,15 +535,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -603,8 +609,9 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - double value = 0; - size_t size = 1; + + double value = 0; + size_t size = 1; int r; char* sval; grib_handle* h = grib_handle_of_accessor(a); @@ -613,7 +620,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -658,7 +665,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -678,7 +685,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); for (i = 0; i < size - 1; i++) { fprintf(self->dumper.out, " \"%s\", &\n", values[i]); @@ -715,10 +722,11 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - char* value = NULL; - char* p = NULL; - size_t size = 0; - grib_context* c = a->context; + + char* value = NULL; + char* p = NULL; + size_t size = 0; + grib_context* c = a->context; int r; int err = 0; grib_handle* h = grib_handle_of_accessor(a); @@ -739,7 +747,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, acc_name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -860,7 +868,7 @@ static void dump_section(grib_dumper* d, grib_accessor* a, grib_block_of_accesso static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix) { - int i = 0; + int i = 0; grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; unsigned long flags; while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { @@ -872,7 +880,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; @@ -892,7 +900,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix static void header(grib_dumper* d, grib_handle* h) { grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d; - char sampleName[200] = { 0 }; + char sampleName[200] = { 0 }; long localSectionPresent, edition, bufrHeaderCentre, isSatellite; grib_get_long(h, "localSectionPresent", &localSectionPresent); diff --git a/src/grib_dumper_class_bufr_encode_python.cc b/src/grib_dumper_class_bufr_encode_python.cc index 34367c913..565bc34ac 100644 --- a/src/grib_dumper_class_bufr_encode_python.cc +++ b/src/grib_dumper_class_bufr_encode_python.cc @@ -164,15 +164,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -258,15 +258,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -351,7 +351,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0); - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -378,10 +378,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -478,15 +478,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -558,7 +558,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; r = compute_bufr_key_rank(h, self->keys, a->name); @@ -603,7 +603,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -620,7 +620,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); for (i = 0; i < size - 1; i++) { fprintf(self->dumper.out, " \"%s\", \n", values[i]); @@ -680,7 +680,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; r = compute_bufr_key_rank(h, self->keys, acc_name); if (grib_is_missing_string(a, (unsigned char*)value, size)) { @@ -814,7 +814,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix self->isLeaf = a->attributes[i]->attributes[0] == NULL ? 1 : 0; flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_bufr_simple.cc b/src/grib_dumper_class_bufr_simple.cc index ca4701f38..868b81ba5 100644 --- a/src/grib_dumper_class_bufr_simple.cc +++ b/src/grib_dumper_class_bufr_simple.cc @@ -141,15 +141,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -231,15 +231,15 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char* if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); @@ -304,7 +304,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) { @@ -314,7 +314,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) /* Note: the "subsetNumber" key is only there for UNCOMPRESSED BUFR messages */ if (self->numberOfSubsets > 1 && strcmp(a->name, "subsetNumber") == 0) { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); DEBUG_ASSERT(!err); fprintf(self->dumper.out, "%s=%ld\n", a->name, value); DEBUG_ASSERT(!grib_is_missing_long(a, value)); @@ -340,10 +340,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -432,15 +432,15 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -504,7 +504,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); self->empty = 0; @@ -554,7 +554,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 || (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -576,7 +576,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); fprintf(self->dumper.out, "{"); for (i = 0; i < size - 1; i++) { @@ -631,7 +631,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); if (err) { fprintf(self->dumper.out, " *** ERR=%d (%s) [dump_string on '%s']", err, grib_get_error_message(err), acc_name); return; @@ -768,7 +768,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a, const char* prefix /* fprintf(out,"\"%s\" : ",a->attributes[i]->name); */ flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long_attribute(d, a->attributes[i], prefix); break; diff --git a/src/grib_dumper_class_debug.cc b/src/grib_dumper_class_debug.cc index 77206c829..ead1c7cf4 100644 --- a/src/grib_dumper_class_debug.cc +++ b/src/grib_dumper_class_debug.cc @@ -188,14 +188,14 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) (d->option_flags & GRIB_DUMP_FLAG_READ_ONLY) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size); + err = a->unpack_long(values, &size); } else { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } set_begin_end(d, a); @@ -234,14 +234,14 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } } else { - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%ld-%ld %s %s = MISSING", self->begin, self->theEnd, a->creator->op, a->name); else fprintf(self->dumper.out, "%ld-%ld %s %s = %ld", self->begin, self->theEnd, a->creator->op, a->name, value); if (comment) fprintf(self->dumper.out, " [%s]", comment); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) - fprintf(self->dumper.out, " (%s)", grib_get_type_name(grib_accessor_get_native_type(a))); + fprintf(self->dumper.out, " (%s)", grib_get_type_name(a->get_native_type())); if ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) fprintf(self->dumper.out, " %s", "(can be missing)"); if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) @@ -266,7 +266,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_debug* self = (grib_dumper_debug*)d; long value = 0; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); int i; if (a->length == 0 && @@ -303,7 +303,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_debug* self = (grib_dumper_debug*)d; double value = 0; size_t size = 1; - int err = grib_unpack_double(a, &value, &size); + int err = a->unpack_double(&value, &size); int i; if (a->length == 0 && @@ -315,14 +315,14 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) for (i = 0; i < d->depth; i++) fprintf(self->dumper.out, " "); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%ld-%ld %s %s = MISSING", self->begin, self->theEnd, a->creator->op, a->name); else fprintf(self->dumper.out, "%ld-%ld %s %s = %g", self->begin, self->theEnd, a->creator->op, a->name, value); if (comment) fprintf(self->dumper.out, " [%s]", comment); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) - fprintf(self->dumper.out, " (%s)", grib_get_type_name(grib_accessor_get_native_type(a))); + fprintf(self->dumper.out, " (%s)", grib_get_type_name(a->get_native_type())); if (err) fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_double]", err, grib_get_error_message(err)); aliases(d, a); @@ -342,7 +342,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) return; grib_get_string_length_acc(a, &size); - if ((size < 2) && grib_is_missing_internal(a)) { + if ((size < 2) && a->is_missing_internal()) { /* GRIB-302: transients and missing keys. Need to re-adjust the size */ size = 10; /* big enough to hold the string "missing" */ } @@ -350,7 +350,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) value = (char*)grib_context_malloc_clear(a->context, size); if (!value) return; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); if (err) strcpy(value, ""); @@ -372,7 +372,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) if (comment) fprintf(self->dumper.out, " [%s]", comment); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) - fprintf(self->dumper.out, " (%s)", grib_get_type_name(grib_accessor_get_native_type(a))); + fprintf(self->dumper.out, " (%s)", grib_get_type_name(a->get_native_type())); if (err) fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_string]", err, grib_get_error_message(err)); @@ -412,7 +412,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, "\n"); - err = grib_unpack_bytes(a, buf, &size); + err = a->unpack_bytes(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_bytes]\n}", err, grib_get_error_message(err)); @@ -463,7 +463,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_double(d, a, NULL); @@ -489,7 +489,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) fprintf(self->dumper.out, "\n"); - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_debug::dump_values]\n}", err, grib_get_error_message(err)); @@ -567,10 +567,10 @@ static void set_begin_end(grib_dumper* d, grib_accessor* a) grib_dumper_debug* self = (grib_dumper_debug*)d; if ((d->option_flags & GRIB_DUMP_FLAG_OCTET) != 0) { self->begin = a->offset - self->section_offset + 1; - self->theEnd = grib_get_next_position_offset(a) - self->section_offset; + self->theEnd = a->get_next_position_offset() - self->section_offset; } else { self->begin = a->offset; - self->theEnd = grib_get_next_position_offset(a); + self->theEnd = a->get_next_position_offset(); } } diff --git a/src/grib_dumper_class_default.cc b/src/grib_dumper_class_default.cc index e9bfdc702..819344cbe 100644 --- a/src/grib_dumper_class_default.cc +++ b/src/grib_dumper_class_default.cc @@ -147,7 +147,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; print_offset(self->dumper.out, d, a); @@ -159,10 +159,10 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -195,7 +195,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) grib_context_free(a->context, values); } else { - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); else fprintf(self->dumper.out, "%s = %ld;", a->name, value); @@ -224,12 +224,12 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) int err = 0; int isDouble = 0; - switch (grib_accessor_get_native_type(a)) { + switch (a->get_native_type()) { case GRIB_TYPE_LONG: - grib_unpack_long(a, &lvalue, &size); + a->unpack_long(&lvalue, &size); break; case GRIB_TYPE_DOUBLE: - grib_unpack_double(a, &dvalue, &size); + a->unpack_double(&dvalue, &size); isDouble = 1; break; default: @@ -269,7 +269,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) else fprintf(self->dumper.out, " "); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); else { if (isDouble) @@ -292,7 +292,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_default* self = (grib_dumper_default*)d; double value = 0; size_t size = 1; - int err = grib_unpack_double(a, &value, &size); + int err = a->unpack_double(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; @@ -318,7 +318,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) else fprintf(self->dumper.out, " "); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); else fprintf(self->dumper.out, "%s = %g;", a->name, value); @@ -341,7 +341,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm int tab = 0; long count = 0; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -354,7 +354,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; @@ -420,7 +420,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) return; } - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; while (*p) { @@ -449,7 +449,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) else fprintf(self->dumper.out, " "); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING;", a->name); else fprintf(self->dumper.out, "%s = %s;", a->name, value); @@ -499,7 +499,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) // fprintf(self->dumper.out,"\n"); -// err = grib_unpack_bytes(a,buf,&size); +// err = a->unpack_bytes(buf,&size); // if(err){ // grib_context_free(d->context,buf); // fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_default::dump_bytes]\n}",err,grib_get_error_message(err)); @@ -549,7 +549,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_double(d, a, NULL); @@ -562,7 +562,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) { char type_name[32] = ""; - const long native_type = grib_accessor_get_native_type(a); + const long native_type = a->get_native_type(); if (native_type == GRIB_TYPE_LONG) strcpy(type_name, "(int)"); else if (native_type == GRIB_TYPE_DOUBLE) @@ -596,7 +596,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) fprintf(self->dumper.out, "\n"); - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); @@ -690,7 +690,7 @@ static void print_offset(FILE* out, grib_dumper* d, grib_accessor* a) grib_handle* h = grib_handle_of_accessor(a); theBegin = a->offset - self->section_offset + 1; - theEnd = grib_get_next_position_offset(a) - self->section_offset; + theEnd = a->get_next_position_offset() - self->section_offset; if ((d->option_flags & GRIB_DUMP_FLAG_HEXADECIMAL) != 0 && a->length != 0) { if (theBegin == theEnd) { diff --git a/src/grib_dumper_class_grib_encode_C.cc b/src/grib_dumper_class_grib_encode_C.cc index 5ecb6953d..5c41e11a0 100644 --- a/src/grib_dumper_class_grib_encode_C.cc +++ b/src/grib_dumper_class_grib_encode_C.cc @@ -130,7 +130,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_grib_encode_C* self = (grib_dumper_grib_encode_C*)d; long value; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return; @@ -161,7 +161,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_grib_encode_C* self = (grib_dumper_grib_encode_C*)d; long value; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); int i; char buf[1024]; @@ -201,7 +201,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_grib_encode_C* self = (grib_dumper_grib_encode_C*)d; double value; size_t size = 1; - int err = grib_unpack_double(a, &value, &size); + int err = a->unpack_double(&value, &size); if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return; @@ -221,7 +221,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_grib_encode_C* self = (grib_dumper_grib_encode_C*)d; char value[1024]; size_t size = sizeof(value); - int err = grib_unpack_string(a, value, &size); + int err = a->unpack_string(value, &size); if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return; @@ -260,7 +260,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) return; } - err = grib_unpack_bytes(a, buf, &size); + err = a->unpack_bytes(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_grib_encode_C::dump_bytes]\n}", err, grib_get_error_message(err)); @@ -305,7 +305,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) || ((a->flags & GRIB_ACCESSOR_FLAG_DATA) && (d->option_flags & GRIB_DUMP_FLAG_NO_DATA))) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { @@ -313,7 +313,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) return; } - type = grib_accessor_get_native_type(a); + type = a->get_native_type(); switch (type) { case GRIB_TYPE_LONG: snprintf(stype, sizeof(stype), "%s", "long"); @@ -331,7 +331,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) return; } - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); diff --git a/src/grib_dumper_class_json.cc b/src/grib_dumper_class_json.cc index be1b5bcc4..dd0210521 100644 --- a/src/grib_dumper_class_json.cc +++ b/src/grib_dumper_class_json.cc @@ -129,15 +129,15 @@ static void dump_values(grib_dumper* d, grib_accessor* a) return; h = grib_handle_of_accessor(a); - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); - err = grib_unpack_double(a, values, &size2); + err = a->unpack_double(values, &size2); } else { - err = grib_unpack_double(a, &value, &size2); + err = a->unpack_double(&value, &size2); } Assert(size2 == size); (void)err; /* TODO */ @@ -222,15 +222,15 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size2); + err = a->unpack_long(values, &size2); } else { - err = grib_unpack_long(a, &value, &size2); + err = a->unpack_long(&value, &size2); } Assert(size2 == size); @@ -327,7 +327,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_unpack_double(a, &value, &size); + a->unpack_double(&value, &size); if (self->begin == 0 && self->empty == 0 && self->isAttribute == 0) fprintf(self->dumper.out, ",\n"); @@ -374,7 +374,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { dump_string(d, a, comment); @@ -401,7 +401,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); if (self->isLeaf == 0) { fprintf(self->dumper.out, "%-*s", depth, " "); @@ -458,7 +458,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) * if (size==0) return; * value=(char*)grib_context_malloc_clear(a->context,size); * if (!value) { - * grib_context_log(a->context,GRIB_LOG_ERROR,"unable to allocate %d bytes",(int)size); + * grib_context_log(a->context,GRIB_LOG_ERROR,"Unable to allocate %zu bytes",size); * return; * } */ @@ -470,7 +470,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) self->empty = 0; - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); if (err) { snprintf(value, sizeof(value), " *** ERR=%d (%s) [dump_string on '%s']", err, grib_get_error_message(err), a->name); @@ -582,7 +582,7 @@ static void dump_attributes(grib_dumper* d, grib_accessor* a) fprintf(out, "\"%s\" : ", a->attributes[i]->name); flags = a->attributes[i]->flags; a->attributes[i]->flags |= GRIB_ACCESSOR_FLAG_DUMP; - switch (grib_accessor_get_native_type(a->attributes[i])) { + switch (a->attributes[i]->get_native_type()) { case GRIB_TYPE_LONG: dump_long(d, a->attributes[i], 0); break; diff --git a/src/grib_dumper_class_serialize.cc b/src/grib_dumper_class_serialize.cc index 6dc4d5c87..57f10cee0 100644 --- a/src/grib_dumper_class_serialize.cc +++ b/src/grib_dumper_class_serialize.cc @@ -102,7 +102,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_serialize* self = (grib_dumper_serialize*)d; long value = 0; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) return; @@ -136,7 +136,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_serialize* self = (grib_dumper_serialize*)d; long value; size_t size = 1; - int err = grib_unpack_long(a, &value, &size); + int err = a->unpack_long(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) return; @@ -171,7 +171,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_serialize* self = (grib_dumper_serialize*)d; double value; size_t size = 1; - int err = grib_unpack_double(a, &value, &size); + int err = a->unpack_double(&value, &size); if ((a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) != 0) return; @@ -200,7 +200,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) grib_dumper_serialize* self = (grib_dumper_serialize*)d; char value[1024] = {0,}; size_t size = sizeof(value); - int err = grib_unpack_string(a, value, &size); + int err = a->unpack_string(value, &size); int i; char* p = value; @@ -261,7 +261,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, "\n"); - err = grib_unpack_bytes(a, buf, &size); + err = a->unpack_bytes(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_serialize::dump_bytes]\n}", err, grib_get_error_message(err)); @@ -319,7 +319,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (self->format) { @@ -376,7 +376,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) fprintf(self->dumper.out, "\n"); - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); diff --git a/src/grib_dumper_class_wmo.cc b/src/grib_dumper_class_wmo.cc index 814ed016f..3949e97a2 100644 --- a/src/grib_dumper_class_wmo.cc +++ b/src/grib_dumper_class_wmo.cc @@ -152,15 +152,15 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size > 1) { values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size); - err = grib_unpack_long(a, values, &size); + err = a->unpack_long(values, &size); } else { - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); } if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0 && @@ -192,7 +192,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment) } } else { - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING", a->name); else fprintf(self->dumper.out, "%s = %ld", a->name, value); @@ -228,7 +228,7 @@ static void dump_bits(grib_dumper* d, grib_accessor* a, const char* comment) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - err = grib_unpack_long(a, &value, &size); + err = a->unpack_long(&value, &size); set_begin_end(d, a); //for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," "); @@ -274,7 +274,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - err = grib_unpack_double(a, &value, &size); + err = a->unpack_double(&value, &size); set_begin_end(d, a); //for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," "); @@ -283,7 +283,7 @@ static void dump_double(grib_dumper* d, grib_accessor* a, const char* comment) if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) fprintf(self->dumper.out, "%s (double) ", a->creator->op); - if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) + if (((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && a->is_missing_internal()) fprintf(self->dumper.out, "%s = MISSING", a->name); else fprintf(self->dumper.out, "%s = %g", a->name, value); @@ -317,7 +317,7 @@ static void dump_string(grib_dumper* d, grib_accessor* a, const char* comment) grib_context_log(a->context, GRIB_LOG_ERROR, "unable to allocate %zu bytes", size); return; } - err = grib_unpack_string(a, value, &size); + err = a->unpack_string(value, &size); p = value; set_begin_end(d, a); @@ -381,7 +381,7 @@ static void dump_bytes(grib_dumper* d, grib_accessor* a, const char* comment) fprintf(self->dumper.out, "\n"); - err = grib_unpack_bytes(a, buf, &size); + err = a->unpack_bytes(buf, &size); if (err) { grib_context_free(d->context, buf); fprintf(self->dumper.out, " *** ERR=%d (%s) [grib_dumper_wmo::dump_bytes]\n}", err, grib_get_error_message(err)); @@ -433,7 +433,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; - grib_value_count(a, &count); + a->value_count(&count); size = count; if (size == 1) { @@ -452,7 +452,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) print_offset(self->dumper.out, self->begin, self->theEnd, 12); // ECC-1749 if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) { char type_name[32] = ""; - const long native_type = grib_accessor_get_native_type(a); + const long native_type = a->get_native_type(); if (native_type == GRIB_TYPE_LONG) strcpy(type_name, "(int)"); else if (native_type == GRIB_TYPE_DOUBLE) @@ -476,7 +476,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a) fprintf(self->dumper.out, "\n"); - err = grib_unpack_double(a, buf, &size); + err = a->unpack_double(buf, &size); if (err) { grib_context_free(d->context, buf); @@ -566,11 +566,11 @@ static void set_begin_end(grib_dumper* d, grib_accessor* a) grib_dumper_wmo* self = (grib_dumper_wmo*)d; if ((d->option_flags & GRIB_DUMP_FLAG_OCTET) != 0) { self->begin = a->offset - self->section_offset + 1; - self->theEnd = grib_get_next_position_offset(a) - self->section_offset; + self->theEnd = a->get_next_position_offset() - self->section_offset; } else { self->begin = a->offset; - self->theEnd = grib_get_next_position_offset(a); + self->theEnd = a->get_next_position_offset(); } } @@ -604,7 +604,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; c = a->context; - grib_value_count(a, &count); + a->value_count(&count); if (count == 0) return; size = count; @@ -619,7 +619,7 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm return; } - err = grib_unpack_string_array(a, values, &size); + err = a->unpack_string_array(values, &size); // print_offset(self->dumper.out,d,a); print_offset(self->dumper.out, self->begin, self->theEnd); diff --git a/src/grib_expression_class.h b/src/grib_expression_class.h index 6856b1b06..8660a7864 100644 --- a/src/grib_expression_class.h +++ b/src/grib_expression_class.h @@ -1,8 +1,6 @@ /* This file is automatically generated by ./make_class.pl, do not edit */ extern grib_expression_class* grib_expression_class_accessor; extern grib_expression_class* grib_expression_class_binop; -extern grib_expression_class* grib_expression_class_column; -extern grib_expression_class* grib_expression_class_constant; extern grib_expression_class* grib_expression_class_double; extern grib_expression_class* grib_expression_class_functor; extern grib_expression_class* grib_expression_class_is_in_dict; diff --git a/src/grib_expression_class_accessor.cc b/src/grib_expression_class_accessor.cc index 67ffbea9a..064cc2051 100644 --- a/src/grib_expression_class_accessor.cc +++ b/src/grib_expression_class_accessor.cc @@ -41,20 +41,14 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static string get_name(grib_expression* e); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); +static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); typedef struct grib_expression_accessor{ grib_expression base; @@ -70,7 +64,6 @@ static grib_expression_class _grib_expression_class_accessor = { "accessor", /* name */ sizeof(grib_expression_accessor),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -84,10 +77,6 @@ static grib_expression_class _grib_expression_class_accessor = { grib_expression_class* grib_expression_class_accessor = &_grib_expression_class_accessor; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static const char* get_name(grib_expression* g) @@ -185,10 +174,11 @@ grib_expression* new_accessor_expression(grib_context* c, const char* name, long static int native_type(grib_expression* g, grib_handle* h) { grib_expression_accessor* e = (grib_expression_accessor*)g; - int type = 0; + int type = 0; int err; - if ((err = grib_get_native_type(h, e->name, &type)) != GRIB_SUCCESS) + if ((err = grib_get_native_type(h, e->name, &type)) != GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_ERROR, - "Error in native_type %s : %s", e->name, grib_get_error_message(err)); + "Error in evaluating the type of '%s': %s", e->name, grib_get_error_message(err)); + } return type; } diff --git a/src/grib_expression_class_binop.cc b/src/grib_expression_class_binop.cc index e95bebbd3..5caefd701 100644 --- a/src/grib_expression_class_binop.cc +++ b/src/grib_expression_class_binop.cc @@ -41,18 +41,12 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); typedef struct grib_expression_binop{ grib_expression base; @@ -70,7 +64,6 @@ static grib_expression_class _grib_expression_class_binop = { "binop", /* name */ sizeof(grib_expression_binop),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -84,17 +77,12 @@ static grib_expression_class _grib_expression_class_binop = { grib_expression_class* grib_expression_class_binop = &_grib_expression_class_binop; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) { long v1 = 0; long v2 = 0; - int ret; grib_expression_binop* e = (grib_expression_binop*)g; // #if DEBUGGING @@ -111,7 +99,7 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) // printf("\n"); // } - ret = grib_expression_evaluate_long(h, e->left, &v1); + int ret = grib_expression_evaluate_long(h, e->left, &v1); if (ret != GRIB_SUCCESS) return ret; @@ -127,8 +115,6 @@ static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) { double v1 = 0.0; double v2 = 0.0; - int ret; - grib_expression_binop* e = (grib_expression_binop*)g; // #if DEBUGGING @@ -145,7 +131,7 @@ static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) // printf("\n"); // } - ret = grib_expression_evaluate_double(h, e->left, &v1); + int ret = grib_expression_evaluate_double(h, e->left, &v1); if (ret != GRIB_SUCCESS) return ret; diff --git a/src/grib_expression_class_double.cc b/src/grib_expression_class_double.cc index 0c0f87a16..89747194b 100644 --- a/src/grib_expression_class_double.cc +++ b/src/grib_expression_class_double.cc @@ -37,18 +37,12 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); typedef struct grib_expression_double{ grib_expression base; @@ -62,7 +56,6 @@ static grib_expression_class _grib_expression_class_double = { "double", /* name */ sizeof(grib_expression_double),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -76,10 +69,6 @@ static grib_expression_class _grib_expression_class_double = { grib_expression_class* grib_expression_class_double = &_grib_expression_class_double; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) diff --git a/src/grib_expression_class_functor.cc b/src/grib_expression_class_functor.cc index 16153620d..530654ea2 100644 --- a/src/grib_expression_class_functor.cc +++ b/src/grib_expression_class_functor.cc @@ -37,17 +37,11 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); typedef struct grib_expression_functor{ grib_expression base; @@ -62,7 +56,6 @@ static grib_expression_class _grib_expression_class_functor = { "functor", /* name */ sizeof(grib_expression_functor),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -76,10 +69,6 @@ static grib_expression_class _grib_expression_class_functor = { grib_expression_class* grib_expression_class_functor = &_grib_expression_class_functor; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) @@ -103,18 +92,31 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) return ret; } + if (STR_EQUAL(e->name, "size")) { + *lres = 0; + const char* keyName = grib_arguments_get_name(h, e->args, 0); + if (keyName) { + size_t size = 0; + int err = grib_get_size(h, keyName, &size); + if (err) return err; + *lres = (long)size; + return GRIB_SUCCESS; + } + return GRIB_INVALID_ARGUMENT; + } + if (STR_EQUAL(e->name, "missing")) { - const char* p = grib_arguments_get_name(h, e->args, 0); - if (p) { + const char* keyName = grib_arguments_get_name(h, e->args, 0); + if (keyName) { long val = 0; int err = 0; if (h->product_kind == PRODUCT_BUFR) { - int ismiss = grib_is_missing(h, p, &err); + int ismiss = grib_is_missing(h, keyName, &err); if (err) return err; *lres = ismiss; return GRIB_SUCCESS; } - err = grib_get_long_internal(h, p, &val); + err = grib_get_long_internal(h, keyName, &val); if (err) return err; // Note: This does not cope with keys like typeOfSecondFixedSurface // which are codetable entries with values like 255: this value is @@ -131,11 +133,10 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) } if (STR_EQUAL(e->name, "defined")) { - const char* p = grib_arguments_get_name(h, e->args, 0); - - if (p) { - const grib_accessor* a = grib_find_accessor(h, p); - *lres = a != NULL ? 1 : 0; + const char* keyName = grib_arguments_get_name(h, e->args, 0); + if (keyName) { + const grib_accessor* a = grib_find_accessor(h, keyName); + *lres = a != NULL ? 1 : 0; return GRIB_SUCCESS; } *lres = 0; @@ -167,11 +168,51 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) return GRIB_SUCCESS; } + if (STR_EQUAL(e->name, "is_one_of")) { + *lres = 0; + const char* keyName = grib_arguments_get_name(h, e->args, 0); + if (!keyName) return GRIB_INVALID_ARGUMENT; + int type = 0; + int err = grib_get_native_type(h, keyName, &type); + if (err) return err; + int n = grib_arguments_get_count(e->args); + if (type == GRIB_TYPE_STRING) { + char keyValue[254] = {0,}; + size_t len = sizeof(keyValue); + err = grib_get_string(h, keyName, keyValue, &len); + if (err) return err; + for (int i = 1; i < n; ++i) { // skip 1st argument which is the key + const char* sValue = grib_arguments_get_string(h, e->args, i); + if (sValue && STR_EQUAL(keyValue, sValue)) { + *lres = 1; + return GRIB_SUCCESS; + } + } + } + else if (type == GRIB_TYPE_LONG) { + long keyValue = 0; + err = grib_get_long(h, keyName, &keyValue); + if (err) return err; + for (int i = 1; i < n; ++i) { // skip 1st argument which is the key + long lValue = grib_arguments_get_long(h, e->args, i); + if (keyValue == lValue) { + *lres = 1; + return GRIB_SUCCESS; + } + } + } + else if (type == GRIB_TYPE_DOUBLE) { + return GRIB_NOT_IMPLEMENTED; + } + return GRIB_SUCCESS; + } + if (STR_EQUAL(e->name, "gribex_mode_on")) { *lres = h->context->gribex_mode_on ? 1 : 0; return GRIB_SUCCESS; } + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_expression_class_functor::%s failed for '%s'", __func__, e->name); return GRIB_NOT_IMPLEMENTED; } diff --git a/src/grib_expression_class_is_in_dict.cc b/src/grib_expression_class_is_in_dict.cc index 27856cc2d..142287cdc 100644 --- a/src/grib_expression_class_is_in_dict.cc +++ b/src/grib_expression_class_is_in_dict.cc @@ -39,19 +39,13 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static string get_name(grib_expression* e); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); +static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); typedef struct grib_expression_is_in_dict{ grib_expression base; @@ -66,7 +60,6 @@ static grib_expression_class _grib_expression_class_is_in_dict = { "is_in_dict", /* name */ sizeof(grib_expression_is_in_dict),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ 0, /* destructor */ &print, @@ -80,10 +73,6 @@ static grib_expression_class _grib_expression_class_is_in_dict = { grib_expression_class* grib_expression_class_is_in_dict = &_grib_expression_class_is_in_dict; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ diff --git a/src/grib_expression_class_is_in_list.cc b/src/grib_expression_class_is_in_list.cc index 46310bcd3..f5339c309 100644 --- a/src/grib_expression_class_is_in_list.cc +++ b/src/grib_expression_class_is_in_list.cc @@ -40,20 +40,14 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static string get_name(grib_expression* e); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); +static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); typedef struct grib_expression_is_in_list{ grib_expression base; @@ -68,7 +62,6 @@ static grib_expression_class _grib_expression_class_is_in_list = { "is_in_list", /* name */ sizeof(grib_expression_is_in_list),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -82,10 +75,6 @@ static grib_expression_class _grib_expression_class_is_in_list = { grib_expression_class* grib_expression_class_is_in_list = &_grib_expression_class_is_in_list; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ diff --git a/src/grib_expression_class_is_integer.cc b/src/grib_expression_class_is_integer.cc index 460170e6e..da81cc4cb 100644 --- a/src/grib_expression_class_is_integer.cc +++ b/src/grib_expression_class_is_integer.cc @@ -41,20 +41,14 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static string get_name(grib_expression* e); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); +static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); typedef struct grib_expression_is_integer{ grib_expression base; @@ -70,7 +64,6 @@ static grib_expression_class _grib_expression_class_is_integer = { "is_integer", /* name */ sizeof(grib_expression_is_integer),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -84,10 +77,6 @@ static grib_expression_class _grib_expression_class_is_integer = { grib_expression_class* grib_expression_class_is_integer = &_grib_expression_class_is_integer; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static const char* get_name(grib_expression* g) @@ -103,7 +92,6 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result) char mybuf[1024] = {0,}; size_t size = 1024; char* p = 0; - long val = 0; char* start = 0; if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) @@ -114,14 +102,13 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* result) if (e->length > 0) start[e->length] = 0; - val = strtol(start, &p, 10); + strtol(start, &p, 10); if (*p != 0) *result = 0; else *result = 1; - (void)val; return err; } diff --git a/src/grib_expression_class_length.cc b/src/grib_expression_class_length.cc index 23ac0f591..c9e967c77 100644 --- a/src/grib_expression_class_length.cc +++ b/src/grib_expression_class_length.cc @@ -41,20 +41,14 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static string get_name(grib_expression* e); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); +static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); typedef struct grib_expression_length{ grib_expression base; @@ -70,7 +64,6 @@ static grib_expression_class _grib_expression_class_length = { "length", /* name */ sizeof(grib_expression_length),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -84,10 +77,6 @@ static grib_expression_class _grib_expression_class_length = { grib_expression_class* grib_expression_class_length = &_grib_expression_class_length; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static const char* get_name(grib_expression* g) diff --git a/src/grib_expression_class_logical_and.cc b/src/grib_expression_class_logical_and.cc index 5cf98db69..902119a5e 100644 --- a/src/grib_expression_class_logical_and.cc +++ b/src/grib_expression_class_logical_and.cc @@ -15,7 +15,6 @@ START_CLASS_DEF CLASS = expression - IMPLEMENTS = init_class IMPLEMENTS = destroy IMPLEMENTS = native_type IMPLEMENTS = evaluate_long @@ -39,18 +38,12 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); typedef struct grib_expression_logical_and{ grib_expression base; @@ -65,7 +58,6 @@ static grib_expression_class _grib_expression_class_logical_and = { "logical_and", /* name */ sizeof(grib_expression_logical_and),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -79,10 +71,6 @@ static grib_expression_class _grib_expression_class_logical_and = { grib_expression_class* grib_expression_class_logical_and = &_grib_expression_class_logical_and; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) @@ -94,7 +82,6 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) int ret; grib_expression_logical_and* e = (grib_expression_logical_and*)g; - switch (grib_expression_native_type(h, e->left)) { case GRIB_TYPE_LONG: ret = grib_expression_evaluate_long(h, e->left, &v1); @@ -141,11 +128,8 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) { long lres = 0; - int ret = 0; - - ret = evaluate_long(g, h, &lres); + int ret = evaluate_long(g, h, &lres); *dres = (double)lres; - return ret; } diff --git a/src/grib_expression_class_logical_or.cc b/src/grib_expression_class_logical_or.cc index 75c2a6520..772a73d8a 100644 --- a/src/grib_expression_class_logical_or.cc +++ b/src/grib_expression_class_logical_or.cc @@ -15,7 +15,6 @@ START_CLASS_DEF CLASS = expression - IMPLEMENTS = init_class IMPLEMENTS = destroy IMPLEMENTS = native_type IMPLEMENTS = evaluate_long @@ -39,18 +38,12 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); typedef struct grib_expression_logical_or{ grib_expression base; @@ -65,7 +58,6 @@ static grib_expression_class _grib_expression_class_logical_or = { "logical_or", /* name */ sizeof(grib_expression_logical_or),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -79,10 +71,6 @@ static grib_expression_class _grib_expression_class_logical_or = { grib_expression_class* grib_expression_class_logical_or = &_grib_expression_class_logical_or; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) @@ -141,11 +129,8 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) { long lres = 0; - int ret = 0; - - ret = evaluate_long(g, h, &lres); + int ret = evaluate_long(g, h, &lres); *dres = (double)lres; - return ret; } @@ -154,7 +139,7 @@ static void print(grib_context* c, grib_expression* g, grib_handle* f) grib_expression_logical_or* e = (grib_expression_logical_or*)g; printf("("); grib_expression_print(c, e->left, f); - printf(" && "); + printf(" || "); grib_expression_print(c, e->right, f); printf(")"); } diff --git a/src/grib_expression_class_long.cc b/src/grib_expression_class_long.cc index e2c43b9ce..3b61a83d1 100644 --- a/src/grib_expression_class_long.cc +++ b/src/grib_expression_class_long.cc @@ -37,18 +37,12 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); typedef struct grib_expression_long{ grib_expression base; @@ -62,7 +56,6 @@ static grib_expression_class _grib_expression_class_long = { "long", /* name */ sizeof(grib_expression_long),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -76,10 +69,6 @@ static grib_expression_class _grib_expression_class_long = { grib_expression_class* grib_expression_class_long = &_grib_expression_class_long; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) diff --git a/src/grib_expression_class_string.cc b/src/grib_expression_class_string.cc index 962afeaf8..79d42e247 100644 --- a/src/grib_expression_class_string.cc +++ b/src/grib_expression_class_string.cc @@ -36,17 +36,11 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); typedef struct grib_expression_string{ grib_expression base; @@ -60,7 +54,6 @@ static grib_expression_class _grib_expression_class_string = { "string", /* name */ sizeof(grib_expression_string),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -74,10 +67,6 @@ static grib_expression_class _grib_expression_class_string = { grib_expression_class* grib_expression_class_string = &_grib_expression_class_string; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static const char* evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) diff --git a/src/grib_expression_class_string_compare.cc b/src/grib_expression_class_string_compare.cc index 1c6202b23..421669aca 100644 --- a/src/grib_expression_class_string_compare.cc +++ b/src/grib_expression_class_string_compare.cc @@ -38,18 +38,12 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); typedef struct grib_expression_string_compare{ grib_expression base; @@ -64,7 +58,6 @@ static grib_expression_class _grib_expression_class_string_compare = { "string_compare", /* name */ sizeof(grib_expression_string_compare),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -78,10 +71,6 @@ static grib_expression_class _grib_expression_class_string_compare = { grib_expression_class* grib_expression_class_string_compare = &_grib_expression_class_string_compare; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ /* Note: A fast cut-down version of strcmp which does NOT return -1 */ diff --git a/src/grib_expression_class_sub_string.cc b/src/grib_expression_class_sub_string.cc index 988a5d0ba..a5a0da732 100644 --- a/src/grib_expression_class_sub_string.cc +++ b/src/grib_expression_class_sub_string.cc @@ -36,17 +36,11 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); typedef struct grib_expression_sub_string{ grib_expression base; @@ -60,7 +54,6 @@ static grib_expression_class _grib_expression_class_sub_string = { "sub_string", /* name */ sizeof(grib_expression_sub_string),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -74,10 +67,6 @@ static grib_expression_class _grib_expression_class_sub_string = { grib_expression_class* grib_expression_class_sub_string = &_grib_expression_class_sub_string; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static const char* evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) diff --git a/src/grib_expression_class_true.cc b/src/grib_expression_class_true.cc index a57ce9c60..6b418cb2c 100644 --- a/src/grib_expression_class_true.cc +++ b/src/grib_expression_class_true.cc @@ -36,18 +36,12 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); typedef struct grib_expression_true{ grib_expression base; @@ -60,7 +54,6 @@ static grib_expression_class _grib_expression_class_true = { "true", /* name */ sizeof(grib_expression_true),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, @@ -74,10 +67,6 @@ static grib_expression_class _grib_expression_class_true = { grib_expression_class* grib_expression_class_true = &_grib_expression_class_true; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) diff --git a/src/grib_expression_class_unop.cc b/src/grib_expression_class_unop.cc index 2abd4dbc9..ae7678043 100644 --- a/src/grib_expression_class_unop.cc +++ b/src/grib_expression_class_unop.cc @@ -17,6 +17,7 @@ CLASS = expression IMPLEMENTS = destroy IMPLEMENTS = native_type + IMPLEMENTS = get_name IMPLEMENTS = evaluate_long IMPLEMENTS = evaluate_double IMPLEMENTS = print @@ -39,18 +40,13 @@ or edit "expression.class" and rerun ./make_class.pl typedef const char* string; /* to keep make_class.pl happy */ - -static void init_class (grib_expression_class*); - -static void destroy(grib_context*,grib_expression* e); - -static void print(grib_context*,grib_expression*,grib_handle*); -static void add_dependency(grib_expression* e, grib_accessor* observer); - -static int native_type(grib_expression*,grib_handle*); - -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); +static void destroy(grib_context*,grib_expression* e); +static void print(grib_context*,grib_expression*,grib_handle*); +static void add_dependency(grib_expression* e, grib_accessor* observer); +static string get_name(grib_expression* e); +static int native_type(grib_expression*,grib_handle*); +static int evaluate_long(grib_expression*,grib_handle*,long*); +static int evaluate_double(grib_expression*,grib_handle*,double*); typedef struct grib_expression_unop{ grib_expression base; @@ -66,13 +62,12 @@ static grib_expression_class _grib_expression_class_unop = { "unop", /* name */ sizeof(grib_expression_unop),/* size of instance */ 0, /* inited */ - &init_class, /* init_class */ 0, /* constructor */ &destroy, /* destructor */ &print, &add_dependency, &native_type, - 0, + &get_name, &evaluate_long, &evaluate_double, 0, @@ -80,18 +75,13 @@ static grib_expression_class _grib_expression_class_unop = { grib_expression_class* grib_expression_class_unop = &_grib_expression_class_unop; - -static void init_class(grib_expression_class* c) -{ -} /* END_CLASS_IMP */ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) { - int ret; - long v = 0; + long v = 0; grib_expression_unop* e = (grib_expression_unop*)g; - ret = grib_expression_evaluate_long(h, e->exp, &v); + int ret = grib_expression_evaluate_long(h, e->exp, &v); if (ret != GRIB_SUCCESS) return ret; *lres = e->long_func(v); @@ -100,16 +90,21 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) { - int ret; - double v = 0; + double v = 0; grib_expression_unop* e = (grib_expression_unop*)g; - ret = grib_expression_evaluate_double(h, e->exp, &v); + int ret = grib_expression_evaluate_double(h, e->exp, &v); if (ret != GRIB_SUCCESS) return ret; *dres = e->double_func ? e->double_func(v) : e->long_func(v); return GRIB_SUCCESS; } +static const char* get_name(grib_expression* g) +{ + grib_expression_unop* e = (grib_expression_unop*)g; + return grib_expression_get_name(e->exp); +} + static void print(grib_context* c, grib_expression* g, grib_handle* f) { grib_expression_unop* e = (grib_expression_unop*)g; @@ -124,7 +119,6 @@ static void destroy(grib_context* c, grib_expression* g) grib_expression_free(c, e->exp); } - static void add_dependency(grib_expression* g, grib_accessor* observer) { grib_expression_unop* e = (grib_expression_unop*)g; diff --git a/src/grib_expression_factory.h b/src/grib_expression_factory.h index 0f5cd83bb..7cacd3ac1 100644 --- a/src/grib_expression_factory.h +++ b/src/grib_expression_factory.h @@ -1,8 +1,6 @@ /* This file is automatically generated by ./make_class.pl, do not edit */ { "accessor", &grib_expression_class_accessor, }, { "binop", &grib_expression_class_binop, }, -{ "column", &grib_expression_class_column, }, -{ "constant", &grib_expression_class_constant, }, { "double", &grib_expression_class_double, }, { "functor", &grib_expression_class_functor, }, { "is_in_dict", &grib_expression_class_is_in_dict, }, diff --git a/src/grib_filepool.cc b/src/grib_filepool.cc index 8d55f3d3d..28606e8c9 100644 --- a/src/grib_filepool.cc +++ b/src/grib_filepool.cc @@ -132,10 +132,10 @@ void grib_file_pool_clean() // return grib_write_file(fh, file->next); // } -grib_file* grib_file_pool_get_files() -{ - return file_pool.first; -} +// grib_file* grib_file_pool_get_files() +// { +// return file_pool.first; +// } // int grib_file_pool_read(grib_context* c, FILE* fh) // { diff --git a/src/grib_handle.cc b/src/grib_handle.cc index e1c361eba..1bbcef4ae 100644 --- a/src/grib_handle.cc +++ b/src/grib_handle.cc @@ -10,7 +10,6 @@ /*************************************************************************** * Jean Baptiste Filippi - 01.11.2005 * - * Enrico Fucile * ***************************************************************************/ #include "grib_api_internal.h" @@ -55,7 +54,7 @@ static void update_sections(grib_section* s, grib_handle* h, long offset) a->offset += offset; /* update_sections ( grib_get_sub_section ( a ),h,offset ); */ update_sections(a->sub_section, h, offset); - a = a->next; + a = a->next_; } } @@ -75,7 +74,7 @@ void grib_swap_sections(grib_section* the_old, grib_section* the_new) a = the_old->block->first; while (a) { a->parent = the_old; - a = a->next; + a = a->next_; } update_sections(the_old, the_old->h, the_old->owner->offset); @@ -95,12 +94,12 @@ void grib_empty_section(grib_context* c, grib_section* b) current = b->block->first; while (current) { - grib_accessor* next = current->next; + grib_accessor* next = current->next_; if (current->sub_section) { grib_section_delete(c, current->sub_section); current->sub_section = 0; } - grib_accessor_delete(c, current); + current->destroy(c); current = next; } b->block->first = b->block->last = 0; @@ -228,11 +227,11 @@ grib_handle* codes_handle_new_from_samples(grib_context* c, const char* name) fprintf(stderr, "ECCODES DEBUG codes_handle_new_from_samples '%s'\n", name); } - g = codes_external_template(c, PRODUCT_ANY, name); + g = codes_external_sample(c, PRODUCT_ANY, name); if (!g) { grib_context_log(c, GRIB_LOG_ERROR, "Unable to load sample file '%s.tmpl'\n" - " from %s\n" + " samples path='%s'\n" " (ecCodes Version=%s)", name, c->grib_samples_path, ECCODES_VERSION_STR); } @@ -256,7 +255,7 @@ grib_handle* grib_handle_new_from_samples(grib_context* c, const char* name) fprintf(stderr, "ECCODES DEBUG grib_handle_new_from_samples '%s'\n", name); } - g = codes_external_template(c, PRODUCT_GRIB, name); + g = codes_external_sample(c, PRODUCT_GRIB, name); if (!g) grib_context_log(c, GRIB_LOG_ERROR, "Unable to load GRIB sample file '%s.tmpl'\n" @@ -279,7 +278,7 @@ grib_handle* codes_bufr_handle_new_from_samples(grib_context* c, const char* nam fprintf(stderr, "ECCODES DEBUG bufr_handle_new_from_samples '%s'\n", name); } - g = codes_external_template(c, PRODUCT_BUFR, name); + g = codes_external_sample(c, PRODUCT_BUFR, name); if (!g) { grib_context_log(c, GRIB_LOG_ERROR, "Unable to load BUFR sample file '%s.tmpl'\n" diff --git a/src/grib_hash_array.cc b/src/grib_hash_array.cc index 54ba4294f..ec556c904 100644 --- a/src/grib_hash_array.cc +++ b/src/grib_hash_array.cc @@ -30,19 +30,19 @@ grib_hash_array_value* grib_integer_hash_array_value_new(grib_context* c, const // return v; // } -void grib_hash_array_value_delete(grib_context* c, grib_hash_array_value* v) -{ - switch (v->type) { - case GRIB_HASH_ARRAY_TYPE_INTEGER: - grib_iarray_delete(v->iarray); - break; - case GRIB_HASH_ARRAY_TYPE_DOUBLE: - grib_darray_delete(c, v->darray); - break; - default: - grib_context_log(c, GRIB_LOG_ERROR, - "wrong type in grib_hash_array_value_delete"); - } - grib_context_free_persistent(c, v->name); - grib_context_free_persistent(c, v); -} +// void grib_hash_array_value_delete(grib_context* c, grib_hash_array_value* v) +// { +// switch (v->type) { +// case GRIB_HASH_ARRAY_TYPE_INTEGER: +// grib_iarray_delete(v->iarray); +// break; +// case GRIB_HASH_ARRAY_TYPE_DOUBLE: +// grib_darray_delete(c, v->darray); +// break; +// default: +// grib_context_log(c, GRIB_LOG_ERROR, +// "wrong type in grib_hash_array_value_delete"); +// } +// grib_context_free_persistent(c, v->name); +// grib_context_free_persistent(c, v); +// } diff --git a/src/grib_hash_keys.cc b/src/grib_hash_keys.cc index a71738e88..ba26dbe03 100644 --- a/src/grib_hash_keys.cc +++ b/src/grib_hash_keys.cc @@ -31,7 +31,7 @@ #include "grib_api_internal.h" -struct grib_keys_hash { char* name; int id;}; +struct grib_keys_hash { const char* name; int id;}; #include #define TOTAL_KEYWORDS 2535 diff --git a/src/grib_iarray.cc b/src/grib_iarray.cc index 50d16bcaa..f69adfffd 100644 --- a/src/grib_iarray.cc +++ b/src/grib_iarray.cc @@ -46,8 +46,7 @@ grib_iarray* grib_iarray_new(grib_context* c, size_t size, size_t incsize) v = (grib_iarray*)grib_context_malloc(c, sizeof(grib_iarray)); if (!v) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_iarray_new unable to allocate %zu bytes", sizeof(grib_iarray)); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(grib_iarray)); return NULL; } v->context = c; @@ -57,8 +56,7 @@ grib_iarray* grib_iarray_new(grib_context* c, size_t size, size_t incsize) v->v = (long*)grib_context_malloc(c, sizeof(long) * size); v->number_of_pop_front = 0; if (!v->v) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_iarray_new unable to allocate %zu bytes", sizeof(long) * size); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(long) * size); return NULL; } return v; @@ -98,8 +96,7 @@ static grib_iarray* grib_iarray_resize_to(grib_iarray* v, size_t newsize) newv = (long*)grib_context_malloc_clear(c, newsize * sizeof(long)); if (!newv) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_iarray_resize unable to allocate %zu bytes", sizeof(long) * newsize); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(long) * newsize); return NULL; } diff --git a/src/grib_index.cc b/src/grib_index.cc index 225e502eb..211b30cb5 100644 --- a/src/grib_index.cc +++ b/src/grib_index.cc @@ -9,6 +9,8 @@ */ #include "grib_api_internal.h" +#include +#include #define UNDEF_LONG -99999 #define UNDEF_DOUBLE -99999 @@ -63,6 +65,7 @@ static int index_count; static long values_count = 0; static int codes_index_add_file_internal(grib_index* index, const char* filename, int message_type); +static void grib_index_rewind(grib_index* index); static char* get_key(char** keys, int* type) { @@ -242,17 +245,13 @@ static grib_index_key* grib_index_new_key(grib_context* c, grib_index_key* keys, next = (grib_index_key*)grib_context_malloc_clear(c, sizeof(grib_index_key)); if (!next) { - grib_context_log(c, GRIB_LOG_ERROR, - "unable to allocate %ld bytes", - sizeof(grib_index_key)); + grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", sizeof(grib_index_key)); *err = GRIB_OUT_OF_MEMORY; return NULL; } values = (grib_string_list*)grib_context_malloc_clear(c, sizeof(grib_string_list)); if (!values) { - grib_context_log(c, GRIB_LOG_ERROR, - "unable to allocate %ld bytes", - sizeof(grib_string_list)); + grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", sizeof(grib_string_list)); *err = GRIB_OUT_OF_MEMORY; return NULL; } @@ -546,7 +545,7 @@ grib_index* grib_index_new(grib_context* c, const char* key, int* err) index = (grib_index*)grib_context_malloc_clear(c, sizeof(grib_index)); if (!index) { - grib_context_log(c, GRIB_LOG_ERROR, "unable to create index"); + grib_context_log(c, GRIB_LOG_ERROR, "Unable to create index"); *err = GRIB_OUT_OF_MEMORY; return NULL; } @@ -1036,7 +1035,7 @@ int grib_index_search_same(grib_index* index, grib_handle* h) } if (err && err != GRIB_NOT_FOUND) { grib_context_log(c, GRIB_LOG_ERROR, - "unable to create index. \"%s\": %s", + "Unable to create index. \"%s\": %s", keys->name, grib_get_error_message(err)); return err; } @@ -1086,6 +1085,7 @@ static int codes_index_add_file_internal(grib_index* index, const char* filename grib_field_tree* field_tree; grib_file* file = NULL; grib_context* c; + bool warn_about_duplicates = true; if (!index) return GRIB_NULL_INDEX; @@ -1124,6 +1124,7 @@ static int codes_index_add_file_internal(grib_index* index, const char* filename fseeko(file->handle, 0, SEEK_SET); + std::map map_of_offsets; while ((h = new_message_from_file(message_type, c, file->handle, &err)) != NULL) { grib_string_list* v = 0; index_key = index->keys; @@ -1132,18 +1133,25 @@ static int codes_index_add_file_internal(grib_index* index, const char* filename message_count++; { - char* envsetkeys = getenv("ECCODES_INDEX_SET_KEYS"); + const char* set_keys_env_var = "ECCODES_INDEX_SET_KEYS"; + char* envsetkeys = getenv(set_keys_env_var); if (envsetkeys) { grib_values set_values[MAX_NUM_KEYS]; int set_values_count = MAX_NUM_KEYS; + std::string copy_of_env(envsetkeys); //parse_keyval_string changes envsetkeys! int error = parse_keyval_string(NULL, envsetkeys, 1, GRIB_TYPE_UNDEFINED, set_values, &set_values_count); if (!error && set_values_count != 0) { err = grib_set_values(h, set_values, set_values_count); if (err) { - grib_context_log(c, GRIB_LOG_ERROR,"codes_index_add_file: unable to set %s\n", envsetkeys); + grib_context_log(c, GRIB_LOG_ERROR, + "codes_index_add_file: Unable to set %s", copy_of_env.c_str()); return err; } + } else { + grib_context_log(c, GRIB_LOG_ERROR, "codes_index_add_file: Unable to parse %s (%s)", + set_keys_env_var, grib_get_error_message(error)); + return error; } } } @@ -1151,7 +1159,7 @@ static int codes_index_add_file_internal(grib_index* index, const char* filename if (index->product_kind == PRODUCT_BUFR && index->unpack_bufr) { err = grib_set_long(h, "unpack", 1); if (err) { - grib_context_log(c, GRIB_LOG_ERROR, "unable to unpack BUFR to create index. \"%s\": %s", + grib_context_log(c, GRIB_LOG_ERROR, "Unable to unpack BUFR to create index. \"%s\": %s", index_key->name, grib_get_error_message(err)); return err; } @@ -1189,7 +1197,7 @@ static int codes_index_add_file_internal(grib_index* index, const char* filename return err; } if (err && err != GRIB_NOT_FOUND) { - grib_context_log(c, GRIB_LOG_ERROR, "unable to create index. key=\"%s\" (message #%lu): %s", + grib_context_log(c, GRIB_LOG_ERROR, "Unable to create index. key=\"%s\" (message #%lu): %s", index_key->name, message_count, grib_get_error_message(err)); return err; } @@ -1243,6 +1251,18 @@ static int codes_index_add_file_internal(grib_index* index, const char* filename field->file = file; index->count++; field->offset = h->offset; + if (warn_about_duplicates) { + const bool offset_is_unique = map_of_offsets.insert( std::pair(h->offset, h) ).second; + if (!offset_is_unique) { + fprintf(stderr, "ECCODES WARNING : File '%s': field offset %ld is not unique.\n", filename, (long)h->offset); + long edition = 0; + if (grib_get_long(h, "edition", &edition) == GRIB_SUCCESS && edition == 2) { + fprintf(stderr, "ECCODES WARNING : This can happen if the file contains multi-field GRIB messages.\n"); + fprintf(stderr, "ECCODES WARNING : Indexing multi-field messages is not fully supported.\n"); + } + warn_about_duplicates = false; + } + } err = grib_get_long(h, "totalLength", &length); if (err) @@ -1270,6 +1290,11 @@ static int codes_index_add_file_internal(grib_index* index, const char* filename grib_context_log(c, GRIB_LOG_ERROR, "File %s contains no messages", filename); return GRIB_END_OF_FILE; } + + if (c->debug) { + fprintf(stderr, "ECCODES DEBUG %s %s\n", __func__, filename); + grib_index_dump(stderr, index, GRIB_DUMP_FLAG_TYPE); + } return GRIB_SUCCESS; } @@ -1362,7 +1387,7 @@ static int codes_index_add_file_internal(grib_index* index, const char* filename // return err; // } // if (err && err != GRIB_NOT_FOUND) { -// grib_context_log(c,GRIB_LOG_ERROR,"unable to create index. \"%s\": %s",index_key->name,grib_get_error_message(err)); +// grib_context_log(c,GRIB_LOG_ERROR,"Unable to create index. \"%s\": %s",index_key->name,grib_get_error_message(err)); // return err; // } @@ -1498,7 +1523,7 @@ int grib_index_get_long(const grib_index* index, const char* key, long* values, if (!k) return GRIB_NOT_FOUND; if (k->type != GRIB_TYPE_LONG) { - grib_context_log(index->context, GRIB_LOG_ERROR, "unable to get index %s as long", key); + grib_context_log(index->context, GRIB_LOG_ERROR, "Unable to get index %s as long", key); return GRIB_WRONG_TYPE; } if (k->values_count > *size) @@ -1527,7 +1552,7 @@ int grib_index_get_double(const grib_index* index, const char* key, double* valu if (!k) return GRIB_NOT_FOUND; if (k->type != GRIB_TYPE_DOUBLE) { - grib_context_log(index->context, GRIB_LOG_ERROR, "unable to get index %s as double", key); + grib_context_log(index->context, GRIB_LOG_ERROR, "Unable to get index %s as double", key); return GRIB_WRONG_TYPE; } if (k->values_count > *size) @@ -1885,7 +1910,8 @@ grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err) return NULL; c = index->context; if (!index->rewind) { - if (!index->current) { + // ECC-1764 + if (!index->current || !index->current->field) { *err = GRIB_END_OF_INDEX; return NULL; } @@ -1908,7 +1934,7 @@ grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err) sizeof(grib_field_list)); if (!index->fieldset) { grib_context_log(index->context, GRIB_LOG_ERROR, - "unable to allocate %lu bytes", sizeof(grib_field_list)); + "Unable to allocate %zu bytes", sizeof(grib_field_list)); return NULL; } index->current = index->fieldset; @@ -1941,7 +1967,7 @@ grib_handle* codes_new_from_index(grib_index* index, int message_type, int* err) return h; } -void grib_index_rewind(grib_index* index) +static void grib_index_rewind(grib_index* index) { index->rewind = 1; } diff --git a/src/grib_io.cc b/src/grib_io.cc index 64c197a29..64477d39e 100644 --- a/src/grib_io.cc +++ b/src/grib_io.cc @@ -421,7 +421,6 @@ static int read_GRIB(reader* r, int no_alloc) r->seek_from_start(r->read_data, r->offset + 4); grib_buffer_delete(c, buf); return GRIB_UNSUPPORTED_EDITION; - break; } /* Assert(i <= buf->length); */ @@ -820,6 +819,9 @@ static int read_BUFR(reader* r, int no_alloc) GROW_BUF_IF_REQUIRED(sec1len + sec2len + sec3len + 4 + 3); /* Read section 3 */ + if (sec3len < 5) { + return GRIB_INVALID_MESSAGE; // ECC-1778 + } if ((r->read(r->read_data, tmp + i, sec3len - 3, &err) != sec3len - 3) || err) return err; i += sec3len - 3; @@ -949,7 +951,7 @@ static int read_any_gts(reader* r) unsigned long magic = 0; unsigned long start = 0x010d0d0a; /* SOH CR CR LF */ unsigned long theEnd = 0x0d0d0a03; /* CR CR LF ETX */ - unsigned char tmp[1024] = {0,}; /* See ECC-735 */ + unsigned char tmp[16384] = {0,}; /* See ECC-735 */ size_t message_size = 0; size_t already_read = 0; int i = 0; @@ -1229,12 +1231,12 @@ int wmo_read_bufr_from_file_fast(FILE* f, size_t* msg_len, off_t* msg_offset) int wmo_read_gts_from_file_fast(FILE* f, size_t* msg_len, off_t* msg_offset) { //TODO(masn): Needs proper implementation; no malloc - unsigned char buffer[1024] = {0,}; + //unsigned char buffer[1024] = {0,}; void* mesg = NULL; int err = GRIB_SUCCESS; grib_context* c = grib_context_get_default(); - *msg_len = sizeof(buffer); + *msg_len = 1024; // sizeof(buffer) mesg = wmo_read_gts_from_file_malloc(f, 0, msg_len, msg_offset, &err); grib_context_free(c, mesg); return err; @@ -1336,7 +1338,7 @@ static size_t stream_read(void* data, void* buffer, size_t len, int* err) if (len > LONG_MAX) { /* size_t cannot be coded into long */ *err = GRIB_INTERNAL_ERROR; - return -1; + return 0; } n = s->stream_proc(s->stream_data, buffer, len); diff --git a/src/grib_iterator.cc b/src/grib_iterator.cc index 9f4fadd95..0d253bc68 100644 --- a/src/grib_iterator.cc +++ b/src/grib_iterator.cc @@ -9,7 +9,6 @@ */ /*************************************************************************** - * Enrico Fucile * * Jean Baptiste Filippi - 01.11.2005 * ***************************************************************************/ #include "grib_api_internal.h" @@ -71,7 +70,8 @@ int grib_iterator_next(grib_iterator* i, double* lat, double* lon, double* value return c->next(i, lat, lon, value); c = s; } - Assert(0); + + grib_context_log(i->h->context, GRIB_LOG_FATAL, "%s: No next() function in iterator '%s'", __func__, i->cclass->name); return 0; } @@ -84,7 +84,7 @@ int grib_iterator_has_next(grib_iterator* i) return c->has_next(i); c = s; } - Assert(0); + grib_context_log(i->h->context, GRIB_LOG_FATAL, "%s: No has_next() function in iterator '%s'", __func__, i->cclass->name); return 0; } @@ -97,7 +97,7 @@ int grib_iterator_previous(grib_iterator* i, double* lat, double* lon, double* v return c->previous(i, lat, lon, value); c = s; } - Assert(0); + grib_context_log(i->h->context, GRIB_LOG_FATAL, "%s: No previous() function in iterator '%s'", __func__, i->cclass->name); return 0; } @@ -110,7 +110,7 @@ int grib_iterator_reset(grib_iterator* i) return c->reset(i); c = s; } - Assert(0); + grib_context_log(i->h->context, GRIB_LOG_FATAL, "%s: No reset() function in iterator '%s'", __func__, i->cclass->name); return 0; } diff --git a/src/grib_iterator_class_gaussian_reduced.cc b/src/grib_iterator_class_gaussian_reduced.cc index cde71f746..b21f680b1 100644 --- a/src/grib_iterator_class_gaussian_reduced.cc +++ b/src/grib_iterator_class_gaussian_reduced.cc @@ -22,6 +22,11 @@ MEMBERS = double *las MEMBERS = double *los MEMBERS = long Nj + MEMBERS = long isRotated + MEMBERS = double angleOfRotation + MEMBERS = double southPoleLat + MEMBERS = double southPoleLon + MEMBERS = long disableUnrotate END_CLASS_DEF */ @@ -53,6 +58,11 @@ typedef struct grib_iterator_gaussian_reduced{ double *las; double *los; long Nj; + long isRotated; + double angleOfRotation; + double southPoleLat; + double southPoleLon; + long disableUnrotate; } grib_iterator_gaussian_reduced; extern grib_iterator_class* grib_iterator_class_gen; @@ -87,16 +97,29 @@ static void init_class(grib_iterator_class* c) static int next(grib_iterator* iter, double* lat, double* lon, double* val) { grib_iterator_gaussian_reduced* self = (grib_iterator_gaussian_reduced*)iter; + double ret_lat=0, ret_lon=0; if (iter->e >= (long)(iter->nv - 1)) return 0; iter->e++; - *lat = self->las[iter->e]; - *lon = self->los[iter->e]; + ret_lat = self->las[iter->e]; + ret_lon = self->los[iter->e]; if (val && iter->data) { *val = iter->data[iter->e]; } + + if (self->isRotated && !self->disableUnrotate) { + double new_lat = 0, new_lon = 0; + unrotate(ret_lat, ret_lon, + self->angleOfRotation, self->southPoleLat, self->southPoleLon, + &new_lat, &new_lon); + ret_lat = new_lat; + ret_lon = new_lon; + } + *lat = ret_lat; + *lon = ret_lon; + return 1; } @@ -104,7 +127,7 @@ typedef void (*get_reduced_row_proc)(long pl, double lon_first, double lon_last, /* For a reduced Gaussian grid which is GLOBAL, the number of points is the sum of the 'pl' array */ /* i.e. the total number of points on all latitudes */ -static size_t count_global_points(long* pl, size_t plsize) +static size_t count_global_points(const long* pl, size_t plsize) { return sum_of_pl_array(pl, plsize); } @@ -288,9 +311,9 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) long* pl; long max_pl = 0; long nj = 0, order = 0, i; - long row_count = 0; - long angleSubdivisions = 0; - grib_context* c = h->context; + long row_count = 0; + long angleSubdivisions = 0; + const grib_context* c = h->context; grib_iterator_gaussian_reduced* self = (grib_iterator_gaussian_reduced*)iter; const char* slat_first = grib_arguments_get_name(h, args, self->carg++); const char* slon_first = grib_arguments_get_name(h, args, self->carg++); @@ -300,6 +323,22 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) const char* spl = grib_arguments_get_name(h, args, self->carg++); const char* snj = grib_arguments_get_name(h, args, self->carg++); + self->angleOfRotation = 0; + self->isRotated = 0; + self->southPoleLat = 0; + self->southPoleLon = 0; + self->disableUnrotate = 0; /* unrotate enabled by default */ + + ret = grib_get_long(h, "isRotatedGrid", &self->isRotated); + if (ret == GRIB_SUCCESS && self->isRotated) { + if ((ret = grib_get_double_internal(h, "angleOfRotation", &self->angleOfRotation))) + return ret; + if ((ret = grib_get_double_internal(h, "latitudeOfSouthernPoleInDegrees", &self->southPoleLat))) + return ret; + if ((ret = grib_get_double_internal(h, "longitudeOfSouthernPoleInDegrees", &self->southPoleLon))) + return ret; + } + if ((ret = grib_get_double_internal(h, slat_first, &lat_first)) != GRIB_SUCCESS) return ret; if ((ret = grib_get_double_internal(h, slon_first, &lon_first)) != GRIB_SUCCESS) diff --git a/src/grib_iterator_class_gen.cc b/src/grib_iterator_class_gen.cc index 02fe38c28..7124e8cf9 100644 --- a/src/grib_iterator_class_gen.cc +++ b/src/grib_iterator_class_gen.cc @@ -193,12 +193,21 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) if ((err = grib_get_long_internal(h, s_numPoints, &numberOfPoints)) != GRIB_SUCCESS) return err; - if (numberOfPoints != dli) { - grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator: %s != size(%s) (%ld!=%ld)", - s_numPoints, s_rawData, numberOfPoints, dli); - return GRIB_WRONG_GRID; + // See ECC-1792. If we don't want to decode the Data Section, we should not do a check + // to see if it is consistent with the Grid Section + if (iter->flags & GRIB_GEOITERATOR_NO_VALUES) { + // Iterator's number of values taken from the Grid Section + iter->nv = numberOfPoints; + } else { + // Check for consistency between the Grid and Data Sections + if (numberOfPoints != dli) { + grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator: %s != size(%s) (%ld!=%ld)", + s_numPoints, s_rawData, numberOfPoints, dli); + return GRIB_WRONG_GRID; + } + iter->nv = dli; } - iter->nv = dli; + if (iter->nv == 0) { grib_context_log(h->context, GRIB_LOG_ERROR, "Geoiterator: size(%s) is %ld", s_rawData, dli); return GRIB_WRONG_GRID; diff --git a/src/grib_iterator_class_healpix.cc b/src/grib_iterator_class_healpix.cc index f2e9c0766..6a545b6c5 100644 --- a/src/grib_iterator_class_healpix.cc +++ b/src/grib_iterator_class_healpix.cc @@ -9,9 +9,13 @@ */ #include "grib_api_internal.h" -#include -#include + #include +#include +#include +#include +#include +#include /* This is used by make_class.pl @@ -24,6 +28,7 @@ MEMBERS = double *lats MEMBERS = double *lons MEMBERS = long Nsides + MEMBERS = bool nested END_CLASS_DEF */ @@ -54,6 +59,7 @@ typedef struct grib_iterator_healpix{ double *lats; double *lons; long Nsides; + bool nested; } grib_iterator_healpix; extern grib_iterator_class* grib_iterator_class_gen; @@ -84,7 +90,77 @@ static void init_class(grib_iterator_class* c) /* END_CLASS_IMP */ #define ITER "HEALPix Geoiterator" -#define RAD2DEG 57.29577951308232087684 // 180 over pi +constexpr double RAD2DEG = 57.29577951308232087684; // 180 over pi + +namespace +{ + +struct CodecFijNest +{ + static constexpr uint64_t __masks[] = { 0x00000000ffffffff, 0x0000ffff0000ffff, 0x00ff00ff00ff00ff, + 0x0f0f0f0f0f0f0f0f, 0x3333333333333333, 0x5555555555555555 }; + + inline static int nest_encode_bits(int n) + { + auto b = static_cast(n) & __masks[0]; + b = (b ^ (b << 16)) & __masks[1]; + b = (b ^ (b << 8)) & __masks[2]; + b = (b ^ (b << 4)) & __masks[3]; + b = (b ^ (b << 2)) & __masks[4]; + b = (b ^ (b << 1)) & __masks[5]; + return static_cast(b); + } + + // inline static int nest_decode_bits(int n) + // { + // auto b = static_cast(n) & __masks[5]; + // b = (b ^ (b >> 1)) & __masks[4]; + // b = (b ^ (b >> 2)) & __masks[3]; + // b = (b ^ (b >> 4)) & __masks[2]; + // b = (b ^ (b >> 8)) & __masks[1]; + // b = (b ^ (b >> 16)) & __masks[0]; + // return static_cast(b); + // } + + // static std::tuple nest_to_fij(int n, int k) + // { + // Assert(0 <= n); + // auto f = n >> (2 * k); // f = n / (Nside * Nside) + // n &= (1 << (2 * k)) - 1; // n = n % (Nside * Nside) + // auto i = nest_decode_bits(n); + // auto j = nest_decode_bits(n >> 1); + // return { f, i, j }; + // } + + static int fij_to_nest(int f, int i, int j, int k) + { + return (f << (2 * k)) + nest_encode_bits(i) + (nest_encode_bits(j) << 1); + } +}; + +inline int int_sqrt(int n) +{ + return static_cast(std::sqrt(static_cast(n) + 0.5)); +} + +// for division result within [0; 3] +inline int div_03(int a, int b) +{ + int t = (a >= (b << 1)) ? 1 : 0; + a -= t * (b << 1); + return (t << 1) + (a >= b ? 1 : 0); +} + +inline bool is_power_of_2(int n) +{ + return std::bitset(n).count() == 1; +} + +inline int pll(int f) +{ + constexpr int __pll[] = { 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7 }; + return __pll[f]; +} size_t HEALPix_nj(size_t N, size_t i) { @@ -92,7 +168,7 @@ size_t HEALPix_nj(size_t N, size_t i) size_t ni = 4 * N - 1; Assert(i < ni); return i < N ? 4 * (i + 1) : i < 3 * N ? 4 * N - : HEALPix_nj(N, ni - 1 - i); + : HEALPix_nj(N, ni - 1 - i); } // Thanks to Willem Deconinck and Pedro Maciel @@ -137,52 +213,139 @@ static std::vector HEALPix_longitudes(size_t N, size_t i) static int iterate_healpix(grib_iterator_healpix* self, long N) { - size_t ny, nx; - ny = nx = 4*N - 1; - std::vector latitudes(ny); + size_t Ny = 4 * static_cast(N) - 1; + auto Nd = static_cast(N); + + std::vector latitudes(Ny); for (long r = 1; r < N; r++) { - latitudes[r - 1] = 90.0 - RAD2DEG * std::acos(1.0 - r * r / (3.0 * N * N)); + auto rd = static_cast(r); + latitudes[r - 1] = 90.0 - RAD2DEG * std::acos(1.0 - rd * rd / (3.0 * Nd * Nd)); latitudes[4 * N - 1 - r] = -latitudes[r - 1]; } + // Polar caps for (long r = 1; r < N; r++) { - latitudes[r - 1] = 90.0 - RAD2DEG * std::acos(1.0 - r * r / (3.0 * N * N)); + auto rd = static_cast(r); + latitudes[r - 1] = 90.0 - RAD2DEG * std::acos(1.0 - rd * rd / (3.0 * Nd * Nd)); latitudes[4 * N - 1 - r] = -latitudes[r - 1]; } + // Equatorial belt for (long r = N; r < 2 * N; r++) { - latitudes[r - 1] = 90.0 - RAD2DEG * std::acos((4.0 * N - 2.0 * r) / (3.0 * N)); + auto rd = static_cast(r); + latitudes[r - 1] = 90.0 - RAD2DEG * std::acos((4.0 * Nd - 2.0 * rd) / (3.0 * Nd)); latitudes[4 * N - 1 - r] = -latitudes[r - 1]; } // Equator latitudes[2 * N - 1] = 0.0; - size_t k = 0; - for (size_t i = 0; i < ny; i++) { - // Compute the longitudes at a given latitude - std::vector longitudes = HEALPix_longitudes(N, i); - for (size_t j = 0; j < longitudes.size(); j++) { - self->lons[k] = longitudes[j]; - self->lats[k] = latitudes[i]; - ++k; + if (self->nested) { + if (!is_power_of_2(N)) { + grib_context* c = grib_context_get_default(); + grib_context_log(c, GRIB_LOG_ERROR, "%s: For nested ordering, Nside must be a power of 2", ITER); + return GRIB_WRONG_GRID; + } + + const auto Nside = static_cast(N); + const auto k = static_cast(std::log2(Nside)); + const int Npix = 12 * Nside * Nside; + const int Ncap = (Nside * (Nside - 1)) << 1; + + auto to_nest = [&](int f, //!< base pixel index + int ring, //!< 1-based ring number + int Nring, //!< number of pixels in ring + int phi, //!< index in longitude + int shift //!< if ring's first pixel is not at phi=0 + ) -> int { + int r = ((2 + (f >> 2)) << k) - ring - 1; + int p = 2 * phi - pll(f) * Nring - shift - 1; + if (p >= 2 * Nside) { + p -= 8 * Nside; + } + + int i = std::max(0, (r + p)) >> 1; + int j = std::max(0, (r - p)) >> 1; + + Assert(f < 12 && i < Nside && j < Nside); + return CodecFijNest::fij_to_nest(f, i, j, k); + }; + + std::vector ring_to_nest(Npix); + for (int r = 0; r < Npix; ++r) { + if (r < Ncap) { + // North polar cap + int Nring = (1 + int_sqrt(2 * r + 1)) >> 1; + int phi = 1 + r - 2 * Nring * (Nring - 1); + int f = div_03(phi - 1, Nring); + + ring_to_nest[r] = to_nest(f, Nring, Nring, phi, 0); + continue; + } + + if (Npix - Ncap <= r) { + // South polar cap + int Nring = (1 + int_sqrt(2 * Npix - 2 * r - 1)) >> 1; + int phi = 1 + r + 2 * Nring * (Nring - 1) + 4 * Nring - Npix; + int ring = 4 * Nside - Nring; // (from South pole) + int f = div_03(phi - 1, Nring) + 8; + + ring_to_nest[r] = to_nest(f, ring, Nring, phi, 0); + continue; + } + + // Equatorial belt + int ip = r - Ncap; + int tmp = ip >> (k + 2); + + int phi = ip - tmp * 4 * Nside + 1; + int ring = tmp + Nside; + + int ifm = 1 + ((phi - 1 - ((1 + tmp) >> 1)) >> k); + int ifp = 1 + ((phi - 1 - ((1 - tmp + 2 * Nside) >> 1)) >> k); + int f = (ifp == ifm) ? (ifp | 4) : ((ifp < ifm) ? ifp : (ifm + 8)); + + ring_to_nest[r] = to_nest(f, ring, Nside, phi, ring & 1); + } + + for (size_t i = 0, j=0; i < Ny; i++) { + // Compute the longitudes at a given latitude + for (double longitude : HEALPix_longitudes(N, i)) { + Assert( ring_to_nest.at(j) < Npix ); + self->lons[ring_to_nest.at(j)] = longitude; + self->lats[ring_to_nest.at(j)] = latitudes[i]; + ++j; + } + } + } else { + for (size_t i = 0, j = 0; i < Ny; i++) { + // Compute the longitudes at a given latitude + for (double longitude : HEALPix_longitudes(N, i)) { + self->lons[j] = longitude; + self->lats[j] = latitudes[i]; + ++j; + } } } return GRIB_SUCCESS; } +} // anonymous namespace + static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) { - int err = 0; + int err = 0; grib_iterator_healpix* self = (grib_iterator_healpix*)iter; const char* snside = grib_arguments_get_name(h, args, self->carg++); const char* sorder = grib_arguments_get_name(h, args, self->carg++); long N = 0; - if ((err = grib_get_long_internal(h, snside, &N)) != GRIB_SUCCESS) return err; + if ((err = grib_get_long_internal(h, snside, &N)) != GRIB_SUCCESS) { + return err; + } if (N <= 0) { grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Key %s must be greater than zero", ITER, snside); return GRIB_WRONG_GRID; @@ -190,14 +353,20 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) char ordering[32] = {0,}; size_t slen = sizeof(ordering); - if ((err = grib_get_string_internal(h, sorder, ordering, &slen)) != GRIB_SUCCESS) + if ((err = grib_get_string_internal(h, sorder, ordering, &slen)) != GRIB_SUCCESS) { return err; - - if (!STR_EQUAL(ordering, "ring")) { - grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Only ring ordering is supported", ITER); - return GRIB_WRONG_GRID; } + self->nested = STR_EQUAL(ordering, "nested"); + if (!STR_EQUAL(ordering, "ring") && !self->nested) { + grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Only orderingConvention=(ring|nested) are supported", ITER); + return GRIB_GEOCALCULUS_PROBLEM; + } + // if (self->nested && N == 1) { + // grib_context_log(h->context, GRIB_LOG_ERROR, "%s: For orderingConvention=nested, N must be greater than 1", ITER); + // return GRIB_GEOCALCULUS_PROBLEM; + // } + if (grib_is_earth_oblate(h)) { grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Only spherical earth is supported", ITER); return GRIB_WRONG_GRID; @@ -205,14 +374,19 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) if (iter->nv != 12 * N * N) { grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Wrong number of points (%zu!=12x%ldx%ld)", - ITER, iter->nv, N, N); + ITER, iter->nv, N, N); return GRIB_WRONG_GRID; } self->lats = (double*)grib_context_malloc(h->context, iter->nv * sizeof(double)); - if (self->lats == NULL) return GRIB_OUT_OF_MEMORY; + if (self->lats == nullptr) { + return GRIB_OUT_OF_MEMORY; + } + self->lons = (double*)grib_context_malloc(h->context, iter->nv * sizeof(double)); - if (self->lons == NULL) return GRIB_OUT_OF_MEMORY; + if (self->lons == nullptr) { + return GRIB_OUT_OF_MEMORY; + } try { err = iterate_healpix(self, N); @@ -228,24 +402,26 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) static int next(grib_iterator* iter, double* lat, double* lon, double* val) { - grib_iterator_healpix* self = (grib_iterator_healpix*)iter; + auto* self = (grib_iterator_healpix*)iter; - if ((long)iter->e >= (long)(iter->nv - 1)) + if (iter->e >= static_cast(iter->nv - 1)) { return 0; + } + iter->e++; *lat = self->lats[iter->e]; *lon = self->lons[iter->e]; - if (val && iter->data) { + if (val != nullptr && iter->data != nullptr) { *val = iter->data[iter->e]; } return 1; } -static int destroy(grib_iterator* i) +static int destroy(grib_iterator* iter) { - grib_iterator_healpix* self = (grib_iterator_healpix*)i; - const grib_context* c = i->h->context; + auto* self = (grib_iterator_healpix*)iter; + const auto* c = iter->h->context; grib_context_free(c, self->lats); grib_context_free(c, self->lons); diff --git a/src/grib_iterator_class_lambert_azimuthal_equal_area.cc b/src/grib_iterator_class_lambert_azimuthal_equal_area.cc index a945ee1d2..24dba1877 100644 --- a/src/grib_iterator_class_lambert_azimuthal_equal_area.cc +++ b/src/grib_iterator_class_lambert_azimuthal_equal_area.cc @@ -209,7 +209,11 @@ static int init_oblate(grib_handle* h, sinphi_ = sin(standardParallelInRadians); /* (P->phi0); */ Q__sinb1 = pj_qsfn(sinphi_, e, one_es) / Q__qp; Q__cosb1 = sqrt(1.0 - Q__sinb1 * Q__sinb1); - Q__dd = cos(standardParallelInRadians) / (sqrt(1. - es * sinphi_ * sinphi_) * Q__rq * Q__cosb1); + if (Q__cosb1 == 0) { + Q__dd = 1.0; + } else { + Q__dd = cos(standardParallelInRadians) / (sqrt(1. - es * sinphi_ * sinphi_) * Q__rq * Q__cosb1); + } Q__ymf = (Q__xmf = Q__rq) / Q__dd; Q__xmf *= Q__dd; @@ -253,7 +257,12 @@ static int init_oblate(grib_handle* h, xy_y *= Q__dd; rho = hypot(xy_x, xy_y); Assert(rho >= EPS10); /* TODO(masn): check */ - sCe = 2. * asin(.5 * rho / Q__rq); + const double asin_arg = (0.5 * rho / Q__rq); + if (asin_arg < -1.0 || asin_arg > 1.0) { + grib_context_log(h->context, GRIB_LOG_ERROR, "Invalid value: arcsin argument=%g", asin_arg); + return GRIB_GEOCALCULUS_PROBLEM; + } + sCe = 2. * asin(asin_arg); cCe = cos(sCe); sCe = sin(sCe); xy_x *= sCe; diff --git a/src/grib_iterator_class_polar_stereographic.cc b/src/grib_iterator_class_polar_stereographic.cc index b9c0314a3..1f0c59d69 100644 --- a/src/grib_iterator_class_polar_stereographic.cc +++ b/src/grib_iterator_class_polar_stereographic.cc @@ -123,7 +123,8 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) double *lats, *lons; /* arrays for latitudes and longitudes */ double lonFirstInDegrees, latFirstInDegrees, radius; double x, y, Dx, Dy; - long nx, ny, centralLongitudeInDegrees, centralLatitudeInDegrees; + long nx, ny; + double centralLongitudeInDegrees, centralLatitudeInDegrees; long alternativeRowScanning, iScansNegatively, i, j; long jScansPositively, jPointsAreConsecutive, southPoleOnPlane; double centralLongitude, centralLatitude; /* in radians */ @@ -173,9 +174,9 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) return ret; if ((ret = grib_get_long_internal(h, s_southPoleOnPlane, &southPoleOnPlane)) != GRIB_SUCCESS) return ret; - if ((ret = grib_get_long_internal(h, s_centralLongitude, ¢ralLongitudeInDegrees)) != GRIB_SUCCESS) + if ((ret = grib_get_double_internal(h, s_centralLongitude, ¢ralLongitudeInDegrees)) != GRIB_SUCCESS) return ret; - if ((ret = grib_get_long_internal(h, s_centralLatitude, ¢ralLatitudeInDegrees)) != GRIB_SUCCESS) + if ((ret = grib_get_double_internal(h, s_centralLatitude, ¢ralLatitudeInDegrees)) != GRIB_SUCCESS) return ret; if ((ret = grib_get_double_internal(h, s_Dx, &Dx)) != GRIB_SUCCESS) return ret; diff --git a/src/grib_keys_iterator.cc b/src/grib_keys_iterator.cc index 854b4a2c5..06c112c04 100644 --- a/src/grib_keys_iterator.cc +++ b/src/grib_keys_iterator.cc @@ -165,11 +165,11 @@ int grib_keys_iterator_next(grib_keys_iterator* kiter) kiter->at_start = 0; } else { - kiter->current = grib_next_accessor(kiter->current); + kiter->current = kiter->current->next_accessor(); } while (kiter->current && skip(kiter)) - kiter->current = grib_next_accessor(kiter->current); + kiter->current = kiter->current->next_accessor(); return kiter->current != NULL; } @@ -200,29 +200,29 @@ int grib_keys_iterator_delete(grib_keys_iterator* kiter) int grib_keys_iterator_get_long(const grib_keys_iterator* kiter, long* v, size_t* len) { - return grib_unpack_long(kiter->current, v, len); + return kiter->current->unpack_long(v, 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); + return kiter->current->unpack_double(v, len); } int grib_keys_iterator_get_float(const grib_keys_iterator* kiter, float* v, size_t* len) { - return grib_unpack_float(kiter->current, v, len); + return kiter->current->unpack_float(v, 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); + return kiter->current->unpack_string(v, 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); + return kiter->current->unpack_bytes(v, len); } int grib_keys_iterator_get_native_type(const grib_keys_iterator* kiter) { - return grib_accessor_get_native_type(kiter->current); + return kiter->current->get_native_type(); } diff --git a/src/grib_loader_from_handle.cc b/src/grib_loader_from_handle.cc index cd5ae8513..f26c68c21 100644 --- a/src/grib_loader_from_handle.cc +++ b/src/grib_loader_from_handle.cc @@ -10,6 +10,10 @@ #include "grib_api_internal.h" +#if defined DEBUG && ! defined GRIB_PTHREADS + #define MY_DEBUG +#endif + static int copy_values(grib_handle* h, grib_accessor* ga) { int i, j, k; @@ -23,17 +27,14 @@ static int copy_values(grib_handle* h, grib_accessor* ga) /*printf("SET VALUES %s\n",h->values[j][i].name);*/ switch (h->values[j][i].type) { case GRIB_TYPE_LONG: - return grib_pack_long(ga, &h->values[j][i].long_value, &len); - break; + return ga->pack_long(&h->values[j][i].long_value, &len); case GRIB_TYPE_DOUBLE: - return grib_pack_double(ga, &h->values[j][i].double_value, &len); - break; + return ga->pack_double(&h->values[j][i].double_value, &len); case GRIB_TYPE_STRING: len = strlen(h->values[j][i].string_value); - return grib_pack_string(ga, h->values[j][i].string_value, &len); - break; + return ga->pack_string(h->values[j][i].string_value, &len); } } } @@ -49,7 +50,7 @@ int grib_lookup_long_from_handle(grib_context* gc, grib_loader* loader, const ch grib_accessor* b = grib_find_accessor(h, name); size_t len = 1; if (b) - return grib_unpack_long(b, value, &len); + return b->unpack_long(value, &len); /* TODO: fix me. For now, we don't fail on a lookup. */ *value = -1; @@ -65,7 +66,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ unsigned char* uval = NULL; long* lval = NULL; double* dval = NULL; -#ifdef DEBUG +#ifdef MY_DEBUG static int first = 1; static const char* missing = 0; #endif @@ -79,7 +80,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ if (default_value) { grib_context_log(h->context, GRIB_LOG_DEBUG, "Copying: setting %s to default value", ga->name); - grib_pack_expression(ga, grib_arguments_get_expression(h, default_value, 0)); + ga->pack_expression(grib_arguments_get_expression(h, default_value, 0)); } if ((ga->flags & GRIB_ACCESSOR_FLAG_NO_COPY) || @@ -126,7 +127,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ if (ret != GRIB_SUCCESS) { name = ga->name; -#ifdef DEBUG +#ifdef MY_DEBUG if (first) { missing = codes_getenv("ECCODES_PRINT_MISSING"); first = 0; @@ -134,7 +135,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ #endif grib_context_log(h->context, GRIB_LOG_DEBUG, "Copying [%s] failed: %s", name, grib_get_error_message(ret)); -#ifdef DEBUG +#ifdef MY_DEBUG if (missing) { fprintf(stdout, "REPARSE: no value for %s", name); if (default_value) @@ -152,11 +153,11 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ } if ((ga->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) && grib_is_missing(h, name, &e) && e == GRIB_SUCCESS && len == 1) { - grib_pack_missing(ga); + ga->pack_missing(); pack_missing = 1; } - const long ga_type = grib_accessor_get_native_type(ga); + const long ga_type = ga->get_native_type(); if ((ga->flags & GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION) && !loader->changing_edition) { // See ECC-1560 and ECC-1644 @@ -172,7 +173,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ ret = grib_get_string_internal(h, name, sval, &len); if (ret == GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_DEBUG, "Copying string %s to %s", sval, name); - ret = grib_pack_string(ga, sval, &len); + ret = ga->pack_string(sval, &len); } grib_context_free(h->context, sval); @@ -202,7 +203,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ *lval = 0; /* Reset to a reasonable value */ } } - ret = grib_pack_long(ga, lval, &len); + ret = ga->pack_long(lval, &len); } } @@ -223,7 +224,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ ret = GRIB_SUCCESS; } else - ret = grib_pack_double(ga, dval, &len); + ret = ga->pack_double(dval, &len); } grib_context_free(h->context, dval); @@ -232,13 +233,13 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ case GRIB_TYPE_BYTES: ao = grib_find_accessor(h, name); - len = grib_byte_count(ao); + len = ao->byte_count(); uval = (unsigned char*)grib_context_malloc(h->context, len * sizeof(char)); - ret = grib_unpack_bytes(ao, uval, &len); + ret = ao->unpack_bytes(uval, &len); /* ret = grib_get_bytes_internal(h,name,uval,&len); */ if (ret == GRIB_SUCCESS) { grib_context_log(h->context, GRIB_LOG_DEBUG, "Copying %d byte(s) to %s", len, name); - ret = grib_pack_bytes(ga, uval, &len); + ret = ga->pack_bytes(uval, &len); } grib_context_free(h->context, uval); @@ -250,7 +251,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ default: grib_context_log(h->context, GRIB_LOG_ERROR, - "Copying %s, cannot establish type %ld [%s]", name, grib_accessor_get_native_type(ga), ga->creator->cclass->name); + "Copying %s, cannot establish type %ld [%s]", name, ga->get_native_type(), ga->creator->cclass->name); break; } diff --git a/src/grib_nearest_class_latlon_reduced.cc b/src/grib_nearest_class_latlon_reduced.cc index e38978188..e5c503e99 100644 --- a/src/grib_nearest_class_latlon_reduced.cc +++ b/src/grib_nearest_class_latlon_reduced.cc @@ -210,11 +210,11 @@ static int find_global(grib_nearest* nearest, grib_handle* h, iter = grib_iterator_new(h, GRIB_GEOITERATOR_NO_VALUES, &ret); if (ret) { - grib_context_log(h->context, GRIB_LOG_ERROR, "unable to create iterator"); + grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to create iterator"); return ret; } while (grib_iterator_next(iter, &lat, &lon, NULL)) { - if (olat != lat) { + if (ilat < self->lats_count && olat != lat) { self->lats[ilat++] = lat; olat = lat; } diff --git a/src/grib_nearest_class_reduced.cc b/src/grib_nearest_class_reduced.cc index f17d3b4e3..713570264 100644 --- a/src/grib_nearest_class_reduced.cc +++ b/src/grib_nearest_class_reduced.cc @@ -29,6 +29,7 @@ MEMBERS = double lon_first MEMBERS = double lon_last MEMBERS = int legacy + MEMBERS = int rotated END_CLASS_DEF */ @@ -69,6 +70,7 @@ typedef struct grib_nearest_reduced{ double lon_first; double lon_last; int legacy; + int rotated; } grib_nearest_reduced; extern grib_nearest_class* grib_nearest_class_gen; @@ -101,6 +103,7 @@ static int init(grib_nearest* nearest, grib_handle* h, grib_arguments* args) self->pl = grib_arguments_get_name(h, args, self->cargs++); self->j = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); self->legacy = -1; + self->rotated = -1; if (!self->j) return GRIB_OUT_OF_MEMORY; self->k = (size_t*)grib_context_malloc(nearest->context, NUM_NEIGHBOURS * sizeof(size_t)); @@ -138,10 +141,21 @@ static int find_global(grib_nearest* nearest, grib_handle* h, static int is_legacy(grib_handle* h, int* legacy) { int err = 0; - long lLegacy = 0; - err = grib_get_long(h, "legacyGaussSubarea", &lLegacy); + long lVal = 0; + *legacy = 0; // false by default + err = grib_get_long(h, "legacyGaussSubarea", &lVal); if (err) return err; - *legacy = (int)lLegacy; + *legacy = (int)lVal; + return GRIB_SUCCESS; +} +static int is_rotated(grib_handle* h, int* rotated) +{ + int err = 0; + long lVal = 0; + *rotated = 0; // false by default + err = grib_get_long(h, "isRotatedGrid", &lVal); + if (err) return err; + *rotated = (int)lVal; return GRIB_SUCCESS; } @@ -153,7 +167,12 @@ static int find(grib_nearest* nearest, grib_handle* h, int err = 0; grib_nearest_reduced* self = (grib_nearest_reduced*)nearest; - if (self->global) { + if (self->rotated == -1 || (flags & GRIB_NEAREST_SAME_GRID) == 0) { + err = is_rotated(h, &(self->rotated)); + if (err) return err; + } + + if (self->global && self->rotated == 0) { err = find_global(nearest, h, inlat, inlon, flags, outlats, outlons, values, @@ -251,7 +270,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h, return err; } while (grib_iterator_next(iter, &lat, &lon, NULL)) { - if (olat != lat) { + if (ilat < self->lats_count && olat != lat) { self->lats[ilat++] = lat; olat = lat; } @@ -262,6 +281,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h, if (lon > 180 && lon < 360) lon -= 360; } + DEBUG_ASSERT_ACCESS(self->lons, (long)ilon, (long)nearest->values_count); self->lons[ilon++] = lon; } self->lats_count = ilat; diff --git a/src/grib_nearest_class_regular.cc b/src/grib_nearest_class_regular.cc index 7ff90e38f..adb5320a1 100644 --- a/src/grib_nearest_class_regular.cc +++ b/src/grib_nearest_class_regular.cc @@ -214,7 +214,6 @@ static int find(grib_nearest* nearest, grib_handle* h, } while (grib_iterator_next(iter, &lat, &lon, NULL)) { if (ilat < self->lats_count && olat != lat) { - /* Assert(ilat < self->lats_count); */ self->lats[ilat++] = lat; olat = lat; } diff --git a/src/grib_oarray.cc b/src/grib_oarray.cc index 91e7d9f33..6c5e06d45 100644 --- a/src/grib_oarray.cc +++ b/src/grib_oarray.cc @@ -17,8 +17,6 @@ grib_oarray* grib_oarray_new(grib_context* c, size_t size, size_t incsize) c = grib_context_get_default(); v = (grib_oarray*)grib_context_malloc_clear(c, sizeof(grib_oarray)); if (!v) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_oarray_new unable to allocate %zu bytes", sizeof(grib_oarray)); return NULL; } v->size = size; @@ -27,8 +25,7 @@ grib_oarray* grib_oarray_new(grib_context* c, size_t size, size_t incsize) v->v = (void**)grib_context_malloc_clear(c, sizeof(char*) * size); v->context = c; if (!v->v) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_oarray_new unable to allocate %zu bytes", sizeof(char*) * size); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(char*) * size); return NULL; } return v; @@ -44,8 +41,7 @@ static grib_oarray* grib_oarray_resize(grib_oarray* v) v->v = (void**)grib_context_realloc(c, v->v, newsize * sizeof(char*)); v->size = newsize; if (!v->v) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_oarray_resize unable to allocate %zu bytes", sizeof(char*) * newsize); + grib_context_log(c, GRIB_LOG_ERROR, "%s: Unable to allocate %zu bytes", __func__, sizeof(char*) * newsize); return NULL; } return v; diff --git a/src/grib_openjpeg_encoding.cc b/src/grib_openjpeg_encoding.cc index 6b726a97a..f03ba2fcb 100644 --- a/src/grib_openjpeg_encoding.cc +++ b/src/grib_openjpeg_encoding.cc @@ -14,6 +14,13 @@ #include "openjpeg.h" +// The older versions did not have the opj_config.h file +// So we use a more recent macro to detect whether it is there. +// Also see https://github.com/uclouvain/openjpeg/issues/1514 +#if defined(OPJ_IMG_INFO) + #include "opj_config.h" +#endif + static void openjpeg_warning(const char* msg, void* client_data) { grib_context_log((grib_context*)client_data, GRIB_LOG_WARNING, "openjpeg: %s", msg); diff --git a/src/grib_parse_utils.cc b/src/grib_parse_utils.cc index 2fb771cb7..51de29332 100644 --- a/src/grib_parse_utils.cc +++ b/src/grib_parse_utils.cc @@ -117,16 +117,16 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una switch (type) { case GRIB_TYPE_STRING: replen = 1024; - ret = grib_unpack_string(a, val, &replen); + ret = a->unpack_string(val, &replen); break; case GRIB_TYPE_DOUBLE: replen = 1; - ret = grib_unpack_double(a, &dval, &replen); + ret = a->unpack_double(&dval, &replen); snprintf(val, sizeof(val), "%.12g", dval); break; case GRIB_TYPE_LONG: replen = 1; - ret = grib_unpack_long(a, &lval, &replen); + ret = a->unpack_long(&lval, &replen); snprintf(val, sizeof(val), "%d", (int)lval); break; default: @@ -194,11 +194,11 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // grib_handle* h = grib_handle_of_accessor(a); // if (type == -1) -// type = grib_accessor_get_native_type(a); +// type = a->get_native_type(); // switch (type) { // case GRIB_TYPE_STRING: // replen = sizeof(sbuf) / sizeof(*sbuf); -// ret = grib_unpack_string(a, sbuf, &replen); +// ret = a->unpack_string(sbuf, &replen); // fprintf(out, "%s", sbuf); // break; // case GRIB_TYPE_DOUBLE: @@ -206,7 +206,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // myseparator = separator ? (char*)separator : default_separator; // if (name[0] == '/' || name[0] == '#') { // long count; -// ret = grib_value_count(a, &count); +// ret = a->value_count(&count); // size = count; // } // else { @@ -216,7 +216,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // dval = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size); // if (name[0] == '/' || name[0] == '#') { // replen = size; -// ret = grib_unpack_double(a, dval, &replen); +// ret = a->unpack_double(dval, &replen); // } // else { // replen = 0; @@ -247,7 +247,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // myseparator = separator ? (char*)separator : default_separator; // if (name[0] == '/' || name[0] == '#') { // long count; -// ret = grib_value_count(a, &count); +// ret = a->value_count(&count); // size = count; // } // else { @@ -257,7 +257,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // lval = (long*)grib_context_malloc_clear(h->context, sizeof(long) * size); // if (name[0] == '/' || name[0] == '#') { // replen = size; -// ret = grib_unpack_long(a, lval, &replen); +// ret = a->unpack_long(lval, &replen); // } // else { // replen = 0; @@ -286,7 +286,7 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una // case GRIB_TYPE_BYTES: // replen = a->length; // sval = (char*)grib_context_malloc(h->context, replen * sizeof(char)); -// ret = grib_unpack_string(a, sval, &replen); +// ret = a->unpack_string(sval, &replen); // p = sval; // while ((replen--) > 0) // fprintf(out, "%c", *(p++)); @@ -321,15 +321,15 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha maxcols = INT_MAX; if (type == -1) - type = grib_accessor_get_native_type(al->accessor); - grib_accessors_list_value_count(al, &size); + type = al->accessor->get_native_type(); + al->value_count(&size); switch (type) { case GRIB_TYPE_STRING: myseparator = separator ? (char*)separator : default_separator; if (size == 1) { char sbuf[1024] = {0,}; len = sizeof(sbuf); - ret = grib_unpack_string(al->accessor, sbuf, &len); + ret = al->accessor->unpack_string(sbuf, &len); if (grib_is_missing_string(al->accessor, (unsigned char*)sbuf, len)) { fprintf(out, "%s", "MISSING"); } @@ -341,7 +341,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha int cols = 0; j = 0; cvals = (char**)grib_context_malloc_clear(h->context, sizeof(char*) * size); - grib_accessors_list_unpack_string(al, cvals, &size); + al->unpack_string(cvals, &size); for (j = 0; j < size; j++) { *newline = 1; fprintf(out, "%s", cvals[j]); @@ -362,7 +362,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha myformat = format ? (char*)format : double_format; myseparator = separator ? (char*)separator : default_separator; dval = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size); - ret = grib_accessors_list_unpack_double(al, dval, &size); + ret = al->unpack_double(dval, &size); if (size == 1) fprintf(out, myformat, dval[0]); else { @@ -387,7 +387,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha myformat = format ? (char*)format : long_format; myseparator = separator ? (char*)separator : default_separator; lval = (long*)grib_context_malloc_clear(h->context, sizeof(long) * size); - ret = grib_accessors_list_unpack_long(al, lval, &size); + ret = al->unpack_long(lval, &size); if (size == 1) fprintf(out, myformat, lval[0]); else { @@ -411,7 +411,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha case GRIB_TYPE_BYTES: replen = a->length; bval = (unsigned char*)grib_context_malloc(h->context, replen * sizeof(unsigned char)); - ret = grib_unpack_bytes(al->accessor, bval, &replen); + ret = al->accessor->unpack_bytes(bval, &replen); for (j = 0; j < replen; j++) { fprintf(out, "%02x", bval[j]); } @@ -872,19 +872,14 @@ int grib_type_to_int(char id) switch (id) { case 'd': return GRIB_TYPE_DOUBLE; - break; case 'f': return GRIB_TYPE_DOUBLE; - break; case 'l': return GRIB_TYPE_LONG; - break; case 'i': return GRIB_TYPE_LONG; - break; case 's': return GRIB_TYPE_STRING; - break; } return GRIB_TYPE_UNDEFINED; } diff --git a/src/grib_query.cc b/src/grib_query.cc index 253217c0b..a1209efaf 100644 --- a/src/grib_query.cc +++ b/src/grib_query.cc @@ -14,6 +14,7 @@ * * ***************************************************************************/ #include "grib_api_internal.h" +#include "accessor/grib_accessor_class_bufr_data_array.h" /* Note: A fast cut-down version of strcmp which does NOT return -1 */ /* 0 means input strings are equal and 1 means not equal */ @@ -63,7 +64,7 @@ static grib_accessor* search(grib_section* s, const char* name, const char* name if ((b = search(sub, name, name_space)) != NULL) match = b; - a = a->next; + a = a->next_; } return match; @@ -94,7 +95,7 @@ static void rebuild_hash_keys(grib_handle* h, grib_section* s) i++; } rebuild_hash_keys(h, sub); - a = a->next; + a = a->next_; } } @@ -228,7 +229,7 @@ static grib_accessor* _search_by_rank(grib_accessor* a,const char* name,long ran if (r==rank) return al->accessor; r++; } - al=al->next; + al=al->next_; } return NULL; @@ -257,14 +258,14 @@ static int get_single_long_val(grib_accessor* a, long* result) size_t size = 1; if (c->bufr_multi_element_constant_arrays) { long count = 0; - grib_value_count(a, &count); + a->value_count(&count); if (count > 1) { size_t i = 0; long val0 = 0; int is_constant = 1; long* values = (long*)grib_context_malloc_clear(c, sizeof(long) * count); size = count; - err = grib_unpack_long(a, values, &size); + err = a->unpack_long(values, &size); val0 = values[0]; for (i = 0; i < size; i++) { if (val0 != values[i]) { @@ -281,11 +282,11 @@ static int get_single_long_val(grib_accessor* a, long* result) } } else { - err = grib_unpack_long(a, result, &size); + err = a->unpack_long(result, &size); } } else { - err = grib_unpack_long(a, result, &size); + err = a->unpack_long(result, &size); } return err; } @@ -296,14 +297,14 @@ static int get_single_double_val(grib_accessor* a, double* result) size_t size = 1; if (c->bufr_multi_element_constant_arrays) { long count = 0; - grib_value_count(a, &count); + a->value_count(&count); if (count > 1) { size_t i = 0; double val0 = 0; int is_constant = 1; double* values = (double*)grib_context_malloc_clear(c, sizeof(double) * count); size = count; - err = grib_unpack_double(a, values, &size); + err = a->unpack_double(values, &size); val0 = values[0]; for (i = 0; i < size; i++) { if (val0 != values[i]) { @@ -320,11 +321,11 @@ static int get_single_double_val(grib_accessor* a, double* result) } } else { - err = grib_unpack_double(a, result, &size); + err = a->unpack_double(result, &size); } } else { - err = grib_unpack_double(a, result, &size); + err = a->unpack_double(result, &size); } return err; } @@ -377,27 +378,27 @@ static void search_from_accessors_list(grib_accessors_list* al, const grib_acces while (al && al != end && al->accessor) { if (grib_inline_strcmp(al->accessor->name, accessor_name) == 0) { if (attribute_name[0]) { - accessor_result = grib_accessor_get_attribute(al->accessor, attribute_name); + accessor_result = al->accessor->get_attribute(attribute_name); } else { accessor_result = al->accessor; } if (accessor_result) { - grib_accessors_list_push(result, accessor_result, al->rank); + result->push(accessor_result, al->rank()); } } - al = al->next; + al = al->next_; } if (al == end && al->accessor) { if (grib_inline_strcmp(al->accessor->name, accessor_name) == 0) { if (attribute_name[0]) { - accessor_result = grib_accessor_get_attribute(al->accessor, attribute_name); + accessor_result = al->accessor->get_attribute(attribute_name); } else { accessor_result = al->accessor; } if (accessor_result) { - grib_accessors_list_push(result, accessor_result, al->rank); + result->push(accessor_result, al->rank()); } } } @@ -416,7 +417,7 @@ static void search_accessors_list_by_condition(grib_accessors_list* al, const ch if (start && !condition_true(al->accessor, condition)) end = al; } - if (start != NULL && (end != NULL || al->next == NULL)) { + if (start != NULL && (end != NULL || al->next_ == NULL)) { if (end == NULL) end = al; search_from_accessors_list(start, end, name, result); @@ -424,7 +425,7 @@ static void search_accessors_list_by_condition(grib_accessors_list* al, const ch start = NULL; end = NULL; } - al = al->next; + al = al->next_; } } @@ -452,7 +453,7 @@ static void grib_find_same_and_push(grib_accessors_list* al, grib_accessor* a) { if (a) { grib_find_same_and_push(al, a->same); - grib_accessors_list_push(al, a, al->rank); + al->push(a, al->rank()); } } @@ -484,7 +485,7 @@ grib_accessors_list* grib_find_accessors_list(const grib_handle* ch, const char* int r; al = (grib_accessors_list*)grib_context_malloc_clear(h->context, sizeof(grib_accessors_list)); str2 = get_rank(h->context, name, &r); - grib_accessors_list_push(al, a, r); + al->push(a, r); grib_context_free(h->context, str2); } } @@ -585,7 +586,7 @@ grib_accessor* grib_find_accessor(const grib_handle* h, const char* name) aret = a; } else if (a) { - aret = grib_accessor_get_attribute(a, attribute_name); + aret = a->get_attribute(attribute_name); grib_context_free(h->context, accessor_name); } } @@ -600,7 +601,7 @@ grib_accessor* grib_find_accessor(const grib_handle* h, const char* name) // *err = GRIB_NOT_FOUND; // return NULL; // } -// if ((act = grib_accessor_get_attribute(a, attr_name)) == NULL) { +// if ((act = a->get_attribute(attr_name)) == NULL) { // *err = GRIB_ATTRIBUTE_NOT_FOUND; // return NULL; // } diff --git a/src/grib_sarray.cc b/src/grib_sarray.cc index 93e372e94..2159af7b3 100644 --- a/src/grib_sarray.cc +++ b/src/grib_sarray.cc @@ -30,7 +30,7 @@ grib_sarray* grib_sarray_new(grib_context* c, size_t size, size_t incsize) v = (grib_sarray*)grib_context_malloc_clear(c, sizeof(grib_sarray)); if (!v) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_sarray_new unable to allocate %lu bytes\n", sizeof(grib_sarray)); + "%s: Unable to allocate %zu bytes", __func__, sizeof(grib_sarray)); return NULL; } v->size = size; @@ -40,7 +40,7 @@ grib_sarray* grib_sarray_new(grib_context* c, size_t size, size_t incsize) v->v = (char**)grib_context_malloc_clear(c, sizeof(char*) * size); if (!v->v) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_sarray_new unable to allocate %lu bytes\n", sizeof(char*) * size); + "%s: Unable to allocate %zu bytes", __func__, sizeof(char*) * size); return NULL; } return v; @@ -57,7 +57,7 @@ static grib_sarray* grib_sarray_resize(grib_sarray* v) v->size = newsize; if (!v->v) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_sarray_resize unable to allocate %lu bytes\n", sizeof(char*) * newsize); + "%s: Unable to allocate %zu bytes", __func__, sizeof(char*) * newsize); return NULL; } return v; diff --git a/src/grib_scaling.h b/src/grib_scaling.h index c48b3aa2c..3aebfe78f 100644 --- a/src/grib_scaling.h +++ b/src/grib_scaling.h @@ -1,3 +1,13 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + #pragma once /* Return n to the power of s */ diff --git a/src/grib_templates.cc b/src/grib_templates.cc index 3e357382c..ca2076a2a 100644 --- a/src/grib_templates.cc +++ b/src/grib_templates.cc @@ -35,15 +35,15 @@ // return NULL; // } -/* Windows always has a colon in pathnames e.g. C:\temp\file. It uses semi-colons as delimiter */ +// Windows always has a colon in pathnames e.g. C:\temp\file. It uses semi-colons as delimiter #ifdef ECCODES_ON_WINDOWS #define ECC_PATH_DELIMITER_CHAR ';' #else #define ECC_PATH_DELIMITER_CHAR ':' #endif -/* if product_kind is PRODUCT_ANY, the type of sample file is determined at runtime */ -static grib_handle* try_product_template(grib_context* c, ProductKind product_kind, const char* dir, const char* name) +// if product_kind is PRODUCT_ANY, the type of sample file is determined at runtime +static grib_handle* try_product_sample(grib_context* c, ProductKind product_kind, const char* dir, const char* name) { char path[1024]; grib_handle* g = NULL; @@ -55,10 +55,10 @@ static grib_handle* try_product_template(grib_context* c, ProductKind product_ki snprintf(path, sizeof(path), "%s/%s.tmpl", dir, name); if (c->debug) { - fprintf(stderr, "ECCODES DEBUG try_product_template product=%s, path='%s'\n", codes_get_product_name(product_kind), path); + fprintf(stderr, "ECCODES DEBUG try_product_sample product=%s, path='%s'\n", codes_get_product_name(product_kind), path); } - if (codes_access(path, F_OK) == 0) { /* 0 means file exists */ + if (codes_access(path, F_OK) == 0) { // 0 means file exists FILE* f = codes_fopen(path, "r"); if (!f) { grib_context_log(c, GRIB_LOG_PERROR, "cannot open %s", path); @@ -66,7 +66,7 @@ static grib_handle* try_product_template(grib_context* c, ProductKind product_ki } if (product_kind == PRODUCT_ANY) { - /* Determine the product kind from sample file */ + // Determine the product kind from sample file char* mesg = NULL; size_t size = 0; off_t offset = 0; @@ -89,7 +89,7 @@ static grib_handle* try_product_template(grib_context* c, ProductKind product_ki if (product_kind == PRODUCT_BUFR) { g = codes_bufr_handle_new_from_file(c, f, &err); } else { - /* Note: Pseudo GRIBs like DIAG and BUDG also come here */ + // Note: Pseudo GRIBs like DIAG and BUDG also come here DEBUG_ASSERT(product_kind == PRODUCT_GRIB); g = grib_handle_new_from_file(c, f, &err); } @@ -102,22 +102,24 @@ static grib_handle* try_product_template(grib_context* c, ProductKind product_ki return g; } -static char* try_template_path(grib_context* c, const char* dir, const char* name) +static char* try_sample_path(grib_context* c, const char* dir, const char* name) { + // The ".tmpl" extension is historic. It should have been ".sample" char path[2048]; if (string_ends_with(name, ".tmpl")) snprintf(path, sizeof(path), "%s/%s", dir, name); else snprintf(path, sizeof(path), "%s/%s.tmpl", dir, name); - if (codes_access(path, F_OK) == 0) { /* 0 means file exists */ + if (codes_access(path, F_OK) == 0) { // 0 means file exists return grib_context_strdup(c, path); } return NULL; } -grib_handle* codes_external_template(grib_context* c, ProductKind product_kind, const char* name) +// External here means on disk +grib_handle* codes_external_sample(grib_context* c, ProductKind product_kind, const char* name) { const char* base = c->grib_samples_path; char buffer[1024]; @@ -130,21 +132,21 @@ grib_handle* codes_external_template(grib_context* c, ProductKind product_kind, while (*base) { if (*base == ECC_PATH_DELIMITER_CHAR) { *p = 0; - g = try_product_template(c, product_kind, buffer, name); + g = try_product_sample(c, product_kind, buffer, name); if (g) return g; p = buffer; - base++; /*advance past delimiter*/ + base++; //advance past delimiter } *p++ = *base++; } *p = 0; - g = try_product_template(c, product_kind, buffer, name); + g = try_product_sample(c, product_kind, buffer, name); return g; } -char* get_external_template_path(grib_context* c, const char* name) +char* get_external_sample_path(grib_context* c, const char* name) { const char* base = c->grib_samples_path; char buffer[1024]; @@ -157,7 +159,7 @@ char* get_external_template_path(grib_context* c, const char* name) while (*base) { if (*base == ECC_PATH_DELIMITER_CHAR) { *p = 0; - g = try_template_path(c, buffer, name); + g = try_sample_path(c, buffer, name); if (g) return g; p = buffer; @@ -167,5 +169,5 @@ char* get_external_template_path(grib_context* c, const char* name) } *p = 0; - return g = try_template_path(c, buffer, name); + return g = try_sample_path(c, buffer, name); } diff --git a/src/grib_util.cc b/src/grib_util.cc index c559eeacb..9ff8e7270 100644 --- a/src/grib_util.cc +++ b/src/grib_util.cc @@ -10,6 +10,8 @@ #include "grib_api_internal.h" #include +#include +#include typedef enum { @@ -90,18 +92,18 @@ static grib_handle* grib_sections_copy_internal(grib_handle* hfrom, grib_handle* p = buffer; off = 0; for (i = 0; i <= hfrom->sections_count; i++) { - grib_handle* hand = NULL; + const grib_handle* hand = NULL; if (sections[i]) hand = hfrom; else hand = hto; - p = (unsigned char*)memcpy(p, hand->buffer->data + section_offset[i], section_length[i]); + p = (unsigned char*)memcpy(p, hand->buffer->data + section_offset[i], section_length[i]); section_offset[i] = off; off += section_length[i]; p += section_length[i]; } - /* copy section 3 present flag*/ + // copy section 3 present flag if (edition == 1) { const void* buffer_to = NULL; size_t size_to = 0; @@ -113,7 +115,7 @@ static grib_handle* grib_sections_copy_internal(grib_handle* hfrom, grib_handle* h = grib_handle_new_from_message(hfrom->context, buffer, totalLength); - /*to allow free of buffer*/ + // to allow freeing of buffer h->buffer->property = CODES_MY_BUFFER; switch (edition) { @@ -279,7 +281,7 @@ grib_handle* grib_util_sections_copy(grib_handle* hfrom, grib_handle* hto, int w static grib_trie* init_list(const char* name); static grib_trie* param_id_list = NULL; static grib_trie* mars_param_list = NULL; -/* TODO thread safe */ + grib_string_list* grib_util_get_param_id(const char* mars_param) { if (!mars_param_list && (mars_param_list = init_list("mars_param.table")) == NULL) @@ -382,13 +384,13 @@ static const char* get_packing_spec_packing_type_name(long packing_spec_packing_ return NULL; } -/* For debugging purposes */ -static void print_values(grib_context* c, +// For debugging purposes +static void print_values(const grib_context* c, const grib_util_grid_spec* spec, const grib_util_packing_spec* packing_spec, const char* input_packing_type, - const double* data_values, const size_t data_values_count, /* the data pay load */ - const grib_values* keyval_pairs, const size_t count) /* keys and their values */ + const double* data_values, const size_t data_values_count, // the data pay load + const grib_values* keyval_pairs, const size_t count) // keys and their values { size_t i = 0; int isConstant = 1; @@ -464,14 +466,12 @@ static void print_values(grib_context* c, } -/* -static int DBL_EQUAL(double d1, double d2, double tolerance) -{ - return fabs(d1-d2) < tolerance; -} -*/ +// static int DBL_EQUAL(double d1, double d2, double tolerance) +// { +// return fabs(d1-d2) < tolerance; +// } -// /* Returns a boolean: 1 if angle can be encoded, 0 otherwise */ +// Returns a boolean: 1 if angle can be encoded, 0 otherwise // static int grib1_angle_can_be_encoded(const double angle) // { // const double angle_milliDegrees = angle * 1000; @@ -480,10 +480,10 @@ static int DBL_EQUAL(double d1, double d2, double tolerance) // rounded = (int)(angle_milliDegrees-0.5)/1000.0; // } // if (angle == rounded) return 1; -// return 0; /* sub millidegree. Cannot be encoded in grib1 */ +// return 0; // sub millidegree. Cannot be encoded in grib1 // } -// /* Returns a boolean: 1 if angle can be encoded, 0 otherwise */ +// Returns a boolean: 1 if angle can be encoded, 0 otherwise // static int angle_can_be_encoded(const double angle, const double angular_precision) // { // const double angle_expanded = angle * angular_precision; @@ -493,18 +493,18 @@ static int DBL_EQUAL(double d1, double d2, double tolerance) // rounded = (long)(angle_expanded-0.5)/angular_precision; // } // if (angle == rounded) return 1; -// /*printf(" ......... angle cannot be encoded: %.10e\n", angle);*/ -// return 0; /* Cannot be encoded */ +// //printf(" ......... angle cannot be encoded: %.10e\n", angle); +// return 0; // Cannot be encoded // } -/* Returns a boolean: 1 if angle can be encoded, 0 otherwise */ -static int angle_can_be_encoded(grib_handle* h, const double angle) +// Returns a boolean: 1 if angle can be encoded, 0 otherwise +static int angle_can_be_encoded(const grib_handle* h, const double angle) { int ret = 0; int retval = 1; grib_handle* h2 = NULL; char sample_name[16] = {0,}; - long angle_subdivisions = 0; /* e.g. 1e3 for grib1 and 1e6 for grib2 */ + long angle_subdivisions = 0; // e.g. 1e3 for grib1 and 1e6 for grib2 long edition = 0, coded = 0; double expanded, diff; @@ -545,20 +545,19 @@ static double adjust_angle(const double angle, const RoundingPolicy policy, cons return result; } -/* Search key=value array for: - * latitudeOfFirstGridPointInDegrees - * longitudeOfFirstGridPointInDegrees - * latitudeOfLastGridPointInDegrees - * longitudeOfLastGridPointInDegrees - * and change their values to expand the bounding box - */ -static int expand_bounding_box(grib_handle* h, grib_values* values, const size_t count) +// Search key=value array for: +// * latitudeOfFirstGridPointInDegrees +// * longitudeOfFirstGridPointInDegrees +// * latitudeOfLastGridPointInDegrees +// * longitudeOfLastGridPointInDegrees +// and change their values to expand the bounding box +static int expand_bounding_box(const grib_handle* h, grib_values* values, const size_t count) { int ret = GRIB_SUCCESS; size_t i = 0; double new_angle = 0; RoundingPolicy roundingPolicy = eROUND_ANGLE_UP; - long angle_subdivisions = 0; /* e.g. 1e3 for grib1 and 1e6 for grib2 */ + long angle_subdivisions = 0; // e.g. 1e3 for grib1 and 1e6 for grib2 if ((ret = grib_get_long(h, "angleSubdivisions", &angle_subdivisions)) != 0) return ret; @@ -625,7 +624,7 @@ static int check_values(const double* data_values, size_t data_values_count) }*/ static int check_geometry(grib_handle* handle, const grib_util_grid_spec* spec, - size_t data_values_count, int specified_as_global) + size_t data_values_count, bool specified_as_global) { int err = 0; @@ -646,11 +645,10 @@ static int check_geometry(grib_handle* handle, const grib_util_grid_spec* spec, return err; } - #if defined(CHECK_HANDLE_AGAINST_SPEC) /* Check what is coded in the handle is what is requested by the spec. */ /* Return GRIB_SUCCESS if the geometry matches, otherwise the error code */ -static int check_handle_against_spec(grib_handle* handle, const long edition, +static int check_handle_against_spec(const grib_handle* handle, const long edition, const grib_util_grid_spec* spec, int global_grid) { int err = 0; @@ -833,10 +831,10 @@ static const char* get_grid_type_name(const int spec_grid_type) return NULL; } -static int is_constant_field(const double missingValue, const double* data_values, size_t data_values_count) +static bool is_constant_field(const double missingValue, const double* data_values, size_t data_values_count) { size_t ii = 0; - int constant = 1; + bool constant = true; double value = missingValue; for (ii = 0; ii < data_values_count; ii++) { @@ -846,7 +844,7 @@ static int is_constant_field(const double missingValue, const double* data_value } else { if (value != data_values[ii]) { - constant = 0; + constant = false; break; } } @@ -884,10 +882,10 @@ static int get_grib_sample_name(grib_handle* h, long editionNumber, switch (spec->grid_type) { case GRIB_UTIL_GRID_SPEC_REDUCED_GG: case GRIB_UTIL_GRID_SPEC_REDUCED_ROTATED_GG: - /* Choose a sample with the right Gaussian number and edition */ + // Choose a sample with the right Gaussian number and edition snprintf(sample_name, sample_name_len, "%s_pl_%ld_grib%ld", grid_type, spec->N, editionNumber); if (spec->pl && spec->pl_size) { - /* GRIB-834: pl is given so can use any of the reduced_gg_pl samples */ + // GRIB-834: pl is given so can use any of the reduced_gg_pl samples snprintf(sample_name, sample_name_len, "%s_pl_grib%ld", grid_type, editionNumber); } break; @@ -905,7 +903,7 @@ static int get_grib_sample_name(grib_handle* h, long editionNumber, } if (spec->pl && spec->grid_name) { - /* Cannot have BOTH pl and grid name specified */ + // Cannot have BOTH pl and grid name specified fprintf(stderr, "%s: Cannot set BOTH spec.pl and spec.grid_name!\n", __func__); return GRIB_INTERNAL_ERROR; } @@ -967,25 +965,25 @@ grib_handle* grib_util_set_spec(grib_handle* h, } while (0) grib_values values[1024] = {{0,},}; - grib_context* c = grib_context_get_default(); + const grib_context* c = grib_context_get_default(); grib_handle* h_out = NULL; grib_handle* h_sample = NULL; const char* grid_type = NULL; - char sample_name[1024]; /* name of the GRIB sample file */ + char sample_name[1024]; // name of the GRIB sample file char input_grid_type[100]; char input_packing_type[100]; long editionNumber = 0; size_t count = 0, len = 100, slen = 20, input_grid_type_len = 100; double laplacianOperator; int i = 0, packingTypeIsSet = 0, setSecondOrder = 0, setJpegPacking = 0, setCcsdsPacking = 0; - int convertEditionEarlier = 0; /* For cases when we cannot set some keys without converting */ - int grib1_high_resolution_fix = 0; /* boolean: See GRIB-863 */ - int global_grid = 0; /* boolean */ + bool convertEditionEarlier = false; // For cases when we cannot set some keys without converting + bool grib1_high_resolution_fix = false; // See GRIB-863 + bool global_grid = false; int expandBoundingBox = 0; Assert(h); - /* Get edition number from input handle */ + // Get edition number from input handle if ((*err = grib_get_long(h, "edition", &editionNumber)) != 0) { if (c->write_on_fail) grib_write_message(h, "error.grib", "w"); return NULL; @@ -997,7 +995,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, grib_get_string(h, "packingType", input_packing_type, &len); - /* ECC-1201, ECC-1529, ECC-1530: Make sure input packing type is preserved */ + // ECC-1201, ECC-1529, ECC-1530: Make sure input packing type is preserved if (packing_spec->packing == GRIB_UTIL_PACKING_SAME_AS_INPUT && packing_spec->packing_type == GRIB_UTIL_PACKING_TYPE_SAME_AS_INPUT) { @@ -1031,7 +1029,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, } SET_STRING_VALUE("gridType", grid_type); - /* The "pl" is given from the template, but "section_copy" will take care of setting the right headers */ + // The "pl" is given from the template, but "section_copy" will take care of setting the right headers if (get_grib_sample_name(h, editionNumber, spec, grid_type, sample_name) != GRIB_SUCCESS) { goto cleanup; } @@ -1040,7 +1038,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, fprintf(stderr, "ECCODES WARNING %s: '%s' specified " "but input is GRIB edition %ld. Output must be a higher edition!\n", __func__, grid_type, editionNumber); - convertEditionEarlier = 1; + convertEditionEarlier = true; } h_sample = grib_handle_new_from_samples(NULL, sample_name); @@ -1049,7 +1047,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, return NULL; } - /* Set grid */ + // Set grid switch (spec->grid_type) { case GRIB_UTIL_GRID_SPEC_REGULAR_LL: case GRIB_UTIL_GRID_SPEC_ROTATED_LL: @@ -1060,16 +1058,16 @@ grib_handle* grib_util_set_spec(grib_handle* h, SET_LONG_VALUE("ijDirectionIncrementGiven", 1); if (editionNumber == 1) { - /* GRIB-863: GRIB1 cannot represent increments less than a millidegree */ + // GRIB-863: GRIB1 cannot represent increments less than a millidegree if (!angle_can_be_encoded(h, spec->iDirectionIncrementInDegrees) || !angle_can_be_encoded(h, spec->jDirectionIncrementInDegrees)) { - grib1_high_resolution_fix = 1; - /* Set flag to compute the increments */ + grib1_high_resolution_fix = true; + // Set flag to compute the increments SET_LONG_VALUE("ijDirectionIncrementGiven", 0); } } - /* default iScansNegatively=0 jScansPositively=0 is ok */ + // default iScansNegatively=0 jScansPositively=0 is ok COPY_SPEC_LONG(iScansNegatively); COPY_SPEC_LONG(jScansPositively); @@ -1094,7 +1092,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, if (spec->missingValue) COPY_SPEC_DOUBLE(missingValue); SET_LONG_VALUE("ijDirectionIncrementGiven", 1); - /* TODO: add Assert */ + // TODO(masn): add Assert COPY_SPEC_LONG(Ni); COPY_SPEC_DOUBLE(iDirectionIncrementInDegrees); COPY_SPEC_LONG(Nj); @@ -1129,7 +1127,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, COPY_SPEC_LONG(Ni); COPY_SPEC_LONG(Nj); - /* default iScansNegatively=0 jScansPositively=0 is ok */ + // default iScansNegatively=0 jScansPositively=0 is ok COPY_SPEC_LONG(iScansNegatively); COPY_SPEC_LONG(jScansPositively); COPY_SPEC_DOUBLE(orientationOfTheGridInDegrees); @@ -1143,8 +1141,8 @@ grib_handle* grib_util_set_spec(grib_handle* h, COPY_SPEC_DOUBLE(longitudeOfFirstGridPointInDegrees); COPY_SPEC_DOUBLE(latitudeOfFirstGridPointInDegrees); - COPY_SPEC_LONG(Ni); /* same as Nx */ - COPY_SPEC_LONG(Nj); /* same as Ny */ + COPY_SPEC_LONG(Ni); // same as Nx + COPY_SPEC_LONG(Nj); // same as Ny COPY_SPEC_LONG(iScansNegatively); COPY_SPEC_LONG(jScansPositively); @@ -1160,15 +1158,15 @@ grib_handle* grib_util_set_spec(grib_handle* h, case GRIB_UTIL_GRID_SPEC_UNSTRUCTURED: COPY_SPEC_LONG(bitmapPresent); if (spec->missingValue) COPY_SPEC_DOUBLE(missingValue); - /* TODO(masn): Other keys */ + // TODO(masn): Other keys break; case GRIB_UTIL_GRID_SPEC_LAMBERT_CONFORMAL: COPY_SPEC_LONG(bitmapPresent); if (spec->missingValue) COPY_SPEC_DOUBLE(missingValue); COPY_SPEC_DOUBLE(longitudeOfFirstGridPointInDegrees); COPY_SPEC_DOUBLE(latitudeOfFirstGridPointInDegrees); - COPY_SPEC_LONG(Ni); /* same as Nx */ - COPY_SPEC_LONG(Nj); /* same as Ny */ + COPY_SPEC_LONG(Ni); // same as Nx + COPY_SPEC_LONG(Nj); // same as Ny COPY_SPEC_LONG(iScansNegatively); COPY_SPEC_LONG(jScansPositively); @@ -1239,7 +1237,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, break; } - /* Set rotation */ + // Set rotation switch (spec->grid_type) { case GRIB_UTIL_GRID_SPEC_ROTATED_LL: case GRIB_UTIL_GRID_SPEC_ROTATED_GG: @@ -1251,7 +1249,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, break; } - /* process packing options */ + // process packing options if (!packingTypeIsSet && packing_spec->packing == GRIB_UTIL_PACKING_USE_PROVIDED && strcmp(input_packing_type, "grid_simple_matrix")) { @@ -1271,7 +1269,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, case GRIB_UTIL_PACKING_TYPE_GRID_COMPLEX: if (!STR_EQUAL(input_packing_type, "grid_complex")) { SET_STRING_VALUE("packingType", "grid_complex"); - convertEditionEarlier=1; + convertEditionEarlier = true; } break; case GRIB_UTIL_PACKING_TYPE_JPEG: @@ -1303,14 +1301,13 @@ grib_handle* grib_util_set_spec(grib_handle* h, fprintf(stderr, "%s: invalid packing_spec.packing_type (%ld)\n", __func__, packing_spec->packing_type); *err = GRIB_INTERNAL_ERROR; goto cleanup; - break; } } if (strcmp(input_packing_type, "grid_simple_matrix") == 0) { long numberOfDirections, numberOfFrequencies; int keep_matrix = h->context->keep_matrix; if (packing_spec->packing_type == GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE) { - keep_matrix = 0; /* ECC-911 */ + keep_matrix = 0; // ECC-911 } if (keep_matrix) { SET_STRING_VALUE("packingType", "grid_simple_matrix"); @@ -1365,7 +1362,6 @@ grib_handle* grib_util_set_spec(grib_handle* h, grib_handle_delete(h_sample); *err = GRIB_INTERNAL_ERROR; goto cleanup; - break; } if (packing_spec->extra_settings_count) { @@ -1384,14 +1380,14 @@ grib_handle* grib_util_set_spec(grib_handle* h, packing_spec->extra_settings[i].long_value == 1) { /* GRIB-922: Request is for a global grid. Setting this key will * calculate the lat/lon values. So the spec's lat/lon can be ignored */ - global_grid = 1; + global_grid = true; } } } } - /* grib_write_message(h,"input.grib","w"); */ - /* grib_write_message(h_sample,"geo.grib","w"); */ - /* copy product and local sections from h to h_sample handle and store in h_out */ + // grib_write_message(h,"input.grib","w"); + // grib_write_message(h_sample,"geo.grib","w"); + // copy product and local sections from h to h_sample handle and store in h_out if ((h_out = grib_util_sections_copy(h, h_sample, GRIB_SECTION_PRODUCT | GRIB_SECTION_LOCAL, err)) == NULL) { goto cleanup; } @@ -1399,7 +1395,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, grib_handle_delete(h_sample); Assert(*err == 0); - /* GRIB-857: Set "pl" array if provided (For reduced Gaussian grids) */ + // GRIB-857: Set "pl" array if provided (For reduced Gaussian grids) Assert(spec->pl_size >= 0); if (spec->pl && spec->pl_size == 0) { fprintf(stderr, "%s: pl array not NULL but pl_size == 0!\n", __func__); @@ -1434,7 +1430,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, print_values(h->context, spec, packing_spec, input_packing_type, data_values, data_values_count, values, count); } - /* Apply adjustments to bounding box if needed */ + // Apply adjustments to bounding box if needed if (expandBoundingBox) { if ((*err = expand_bounding_box(h_out, values, count)) != 0) { fprintf(stderr, "%s: Cannot expand bounding box: %s\n", __func__, grib_get_error_message(*err)); @@ -1445,6 +1441,14 @@ grib_handle* grib_util_set_spec(grib_handle* h, } if (convertEditionEarlier && packing_spec->editionNumber > 1) { + // Note: + // If the input is GRIB1 and the requested grid type is HealPix or ORCA etc, + // we deliberately fail unless the user specifies edition conversion. + // i.e., we do not automatically convert edition + // If we later change our mind, we need to change editionNumber to 2 here: + // long new_edition = packing_spec->editionNumber; + // if (new_edition == 0) new_edition = 2; + // *err = grib_set_long(h_out, "edition", packing_spec->editionNumber); if (*err) { fprintf(stderr, "%s: Cannot convert to edition %ld.\n", __func__, packing_spec->editionNumber); @@ -1477,8 +1481,8 @@ grib_handle* grib_util_set_spec(grib_handle* h, } */ if (grib1_high_resolution_fix) { - /* GRIB-863: must set increments to MISSING */ - /* increments are not coded in message but computed */ + // GRIB-863: must set increments to MISSING + // increments are not coded in message but computed if ((*err = grib_set_missing(h_out, "iDirectionIncrement")) != 0) { fprintf(stderr, "%s: Cannot set Di to missing: %s\n", __func__, grib_get_error_message(*err)); goto cleanup; @@ -1489,13 +1493,12 @@ grib_handle* grib_util_set_spec(grib_handle* h, } } - /*grib_dump_content(h_out, stdout,"debug", ~0, NULL);*/ - /* convert to second_order if not constant field. (Also see ECC-326) */ + //grib_dump_content(h_out, stdout,"debug", ~0, NULL); + // convert to second_order if not constant field. (Also see ECC-326) if (setSecondOrder) { - int constant = 0; double missingValue = 0; grib_get_double(h_out, "missingValue", &missingValue); - constant = is_constant_field(missingValue, data_values, data_values_count); + bool constant = is_constant_field(missingValue, data_values, data_values_count); if (!constant) { if (editionNumber == 1) { @@ -1505,7 +1508,7 @@ grib_handle* grib_util_set_spec(grib_handle* h, slen = 17; grib_set_string(htmp, "packingType", "grid_second_order", &slen); grib_get_long(htmp, "numberOfGroups", &numberOfGroups); - /* GRIBEX is not able to decode overflown numberOfGroups with SPD */ + // GRIBEX is not able to decode overflown numberOfGroups with SPD if (numberOfGroups > 65534 && h_out->context->no_spd) { slen = 24; grib_set_string(h_out, "packingType", "grid_second_order_no_SPD", &slen); @@ -1546,8 +1549,8 @@ grib_handle* grib_util_set_spec(grib_handle* h, } } - if (editionNumber > 1 || packing_spec->editionNumber > 1) { /* ECC-353 */ - /* Some packing types are not available in GRIB1 and have to be done AFTER we set data values */ + if (editionNumber > 1 || packing_spec->editionNumber > 1) { // ECC-353 + // Some packing types are not available in GRIB1 and have to be done AFTER we set data values if (setJpegPacking == 1) { *err = grib_set_string(h_out, "packingType", "grid_jpeg", &slen); if (*err != GRIB_SUCCESS) { @@ -1570,9 +1573,9 @@ grib_handle* grib_util_set_spec(grib_handle* h, grib_set_long(h_out, "deleteLocalDefinition", 1); } - /* ECC-445 */ + // ECC-445 if (expandBoundingBox) { - Assert(!global_grid); /* ECC-576: "global" should not be set */ + Assert(!global_grid); // ECC-576: "global" should not be set } if ((*err = check_geometry(h_out, spec, data_values_count, global_grid)) != GRIB_SUCCESS) { @@ -1632,9 +1635,7 @@ cleanup: // } // } // grib_iterator_delete(iter); - // ret = grib_get_double(h, "missingValue", &missingValue); - // centroidX = 0; // centroidY = 0; // mass = 0; @@ -1650,10 +1651,8 @@ cleanup: // centroidX /= mass; // centroidY /= mass; // mass /= *count; - // for (j = 0; j < order * order; j++) // moments[j] = 0; - // for (i = 0; i < numberOfPoints; i++) { // if (values[i] != missingValue) { // dx = (lon[i] - centroidX); @@ -1693,7 +1692,7 @@ static void set_value(grib_values* value, char* str, int equal) { char *p = 0, *q = 0, *s = 0; char buf[1000] = {0,}; - grib_context* c = grib_context_get_default(); + const grib_context* c = grib_context_get_default(); value->equal = equal; q = str; @@ -1724,6 +1723,7 @@ static void set_value(grib_values* value, char* str, int equal) } break; case GRIB_TYPE_LONG: + errno = 0; // must clear errno before calling strtol value->long_value = strtol(buf, &p, 10); if (*p != 0) value->has_value = 1; @@ -1747,8 +1747,15 @@ static void set_value(grib_values* value, char* str, int equal) } break; case GRIB_TYPE_UNDEFINED: + errno = 0; // must clear errno before calling strtol value->long_value = strtol(buf, &p, 10); if (*p == 0) { + // check the conversion from string to long + if (errno == ERANGE && (value->long_value == LONG_MAX || value->long_value == LONG_MIN)) { + fprintf(stderr, "ECCODES WARNING : Setting %s=%s causes overflow/underflow\n", value->name, buf); + fprintf(stderr, "ECCODES WARNING : Value adjusted to %ld\n", value->long_value); + //perror("strtol"); + } value->type = GRIB_TYPE_LONG; value->has_value = 1; } @@ -1814,7 +1821,7 @@ int parse_keyval_string(const char* grib_tool, int equal = 1; char* value = NULL; if (values_required) { - /* Can be either k=v or k!=v */ + // Can be either k=v or k!=v p = (char*)values[i].name; while (*p != '=' && *p != '!' && *p != '\0') p++; @@ -2046,7 +2053,7 @@ size_t sum_of_pl_array(const long* pl, size_t plsize) return count; } -int grib_is_earth_oblate(grib_handle* h) +int grib_is_earth_oblate(const grib_handle* h) { long oblate = 0; int err = grib_get_long(h, "earthIsOblate", &oblate); @@ -2058,8 +2065,8 @@ int grib_is_earth_oblate(grib_handle* h) int grib_check_data_values_minmax(grib_handle* h, const double min_val, const double max_val) { - int result = GRIB_SUCCESS; - grib_context* ctx = h->context; + int result = GRIB_SUCCESS; + const grib_context* ctx = h->context; if (!(min_val < DBL_MAX && min_val > -DBL_MAX)) { grib_context_log(ctx, GRIB_LOG_ERROR, "Minimum value out of range: %g", min_val); @@ -2079,10 +2086,10 @@ int grib_check_data_values_minmax(grib_handle* h, const double min_val, const do } // Return true(1) if large constant fields are to be created, otherwise false(0) -int grib_producing_large_constant_fields(grib_handle* h, int edition) +int grib_producing_large_constant_fields(const grib_handle* h, int edition) { // First check if the transient key is set - grib_context* c = h->context; + const grib_context* c = h->context; long produceLargeConstantFields = 0; if (grib_get_long(h, "produceLargeConstantFields", &produceLargeConstantFields) == GRIB_SUCCESS && produceLargeConstantFields != 0) { @@ -2097,16 +2104,38 @@ int grib_producing_large_constant_fields(grib_handle* h, int edition) return c->large_constant_fields; } +static std::string grib_data_quality_check_extra_info(const grib_handle* h) +{ + char step[32] = "unknown"; + char marsClass[32] = {0,}; + char marsStream[32] = {0,}; + char marsType[32] = {0,}; + std::string result; + std::stringstream ss; + size_t len = 32; + int err1 = grib_get_string(h, "step", step, &len); + len = 32; + int err2 = grib_get_string(h, "class", marsClass, &len); + len = 32; + int err3 = grib_get_string(h, "stream", marsStream, &len); + len = 32; + int err4 = grib_get_string(h, "type", marsType, &len); + if (!err1 && !err2 && !err3 && !err4) { + ss << "step=" << step << ", class=" << marsClass << ", stream=" << marsStream << ", type=" << marsType; + result = ss.str(); + } + + return result; +} int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max_val) { - int err = 0; + int err = 0; double min_field_value_allowed = 0, max_field_value_allowed = 0; long paramId = 0; - grib_context* ctx = h->context; + const grib_context* ctx = h->context; bool is_error = true; char description[1024] = {0,}; - char step[32] = "unknown"; char shortName[64] = {0,}; char name[526] = {0,}; size_t len = 0; @@ -2122,8 +2151,9 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max len = sizeof(shortName); err = grib_get_string(h, "shortName", shortName, &len); if (err || STR_EQUAL(shortName, invalid_shortName)) { - fprintf(stderr, "ECCODES %s : Invalid metadata: shortName='%s'\n", - (is_error ? "ERROR" : "WARNING"), invalid_shortName); + std::string info( grib_data_quality_check_extra_info(h) ); + fprintf(stderr, "ECCODES %s : (%s) Invalid metadata: shortName='%s'\n", + (is_error ? "ERROR" : "WARNING"), info.c_str(), invalid_shortName); if (is_error) return GRIB_INVALID_MESSAGE; } @@ -2151,21 +2181,20 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max if (get_concept_condition_string(h, "param_value_max", NULL, description) == GRIB_SUCCESS) { printf("ECCODES DEBUG grib_data_quality_check: Checking condition '%s' (allowed=%g, %g) (actual=%g, %g)\n", description, min_field_value_allowed, max_field_value_allowed, - min_val, max_val - ); + min_val, max_val); } } if (min_val < min_field_value_allowed) { - grib_get_string(h, "step", step, &len); + std::string info( grib_data_quality_check_extra_info(h) ); if (get_concept_condition_string(h, "param_value_min", NULL, description) == GRIB_SUCCESS) { - fprintf(stderr, "ECCODES %s : (%s, step=%s): minimum (%g) is less than the allowable limit (%g)\n", - (is_error ? "ERROR" : "WARNING"), description, step, min_val, min_field_value_allowed); + fprintf(stderr, "ECCODES %s : (%s, %s): minimum (%g) is less than the allowable limit (%g)\n", + (is_error ? "ERROR" : "WARNING"), description, info.c_str(), min_val, min_field_value_allowed); } else { if (grib_get_long(h, "paramId", ¶mId) == GRIB_SUCCESS) { - fprintf(stderr, "ECCODES %s : (paramId=%ld, step=%s): minimum (%g) is less than the default allowable limit (%g)\n", - (is_error ? "ERROR" : "WARNING"), paramId, step, min_val, min_field_value_allowed); + fprintf(stderr, "ECCODES %s : (paramId=%ld, %s): minimum (%g) is less than the default allowable limit (%g)\n", + (is_error ? "ERROR" : "WARNING"), paramId, info.c_str(), min_val, min_field_value_allowed); } } if (is_error) { @@ -2173,15 +2202,15 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max } } if (max_val > max_field_value_allowed) { - grib_get_string(h, "step", step, &len); + std::string info( grib_data_quality_check_extra_info(h) ); if (get_concept_condition_string(h, "param_value_max", NULL, description) == GRIB_SUCCESS) { - fprintf(stderr, "ECCODES %s : (%s, step=%s): maximum (%g) is more than the allowable limit (%g)\n", - (is_error ? "ERROR" : "WARNING"), description, step, max_val, max_field_value_allowed); + fprintf(stderr, "ECCODES %s : (%s, %s): maximum (%g) is more than the allowable limit (%g)\n", + (is_error ? "ERROR" : "WARNING"), description, info.c_str(), max_val, max_field_value_allowed); } else { if (grib_get_long(h, "paramId", ¶mId) == GRIB_SUCCESS) { - fprintf(stderr, "ECCODES %s : (paramId=%ld, step=%s): maximum (%g) is more than the default allowable limit (%g)\n", - (is_error ? "ERROR" : "WARNING"), paramId, step, max_val, max_field_value_allowed); + fprintf(stderr, "ECCODES %s : (paramId=%ld, %s): maximum (%g) is more than the default allowable limit (%g)\n", + (is_error ? "ERROR" : "WARNING"), paramId, info.c_str(), max_val, max_field_value_allowed); } } if (is_error) { diff --git a/src/grib_value.cc b/src/grib_value.cc index 1320bc9b7..1142fa6a6 100644 --- a/src/grib_value.cc +++ b/src/grib_value.cc @@ -13,9 +13,10 @@ #include "grib_api_internal.h" #include "grib_value.h" -#include "grib_accessor.h" +//#include "grib_accessor.h" #include #include +#include /* Note: A fast cut-down version of strcmp which does NOT return -1 */ /* 0 means input strings are equal and 1 means not equal */ @@ -46,7 +47,7 @@ static void print_debug_info__set_array(grib_handle* h, const char* func, const if (length <= N) N = length; - fprintf(stderr, "ECCODES DEBUG %s key=%s, %zu entries (", func, name, length); + fprintf(stderr, "ECCODES DEBUG %s h=%p key=%s, %zu entries (", func, (void*)h, name, length); for (i = 0; i < N; ++i) { if (i != 0) fprintf(stderr,", "); fprintf(stderr, "%.10g", val[i]); @@ -70,7 +71,7 @@ int grib_set_expression(grib_handle* h, const char* name, grib_expression* e) if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_expression(a, e); + ret = a->pack_expression(e); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -89,10 +90,10 @@ int grib_set_long_internal(grib_handle* h, const char* name, long val) a = grib_find_accessor(h, name); if (h->context->debug) - fprintf(stderr, "ECCODES DEBUG grib_set_long_internal %s=%ld\n", name, val); + fprintf(stderr, "ECCODES DEBUG grib_set_long_internal h=%p %s=%ld\n", (void*)h, name, val); if (a) { - ret = grib_pack_long(a, &val, &l); + ret = a->pack_long(&val, &l); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -117,15 +118,15 @@ int grib_set_long(grib_handle* h, const char* name, long val) if (a) { if (h->context->debug) { if (strcmp(name, a->name)!=0) - fprintf(stderr, "ECCODES DEBUG grib_set_long %s=%ld (a->name=%s)\n", name, val, a->name); + fprintf(stderr, "ECCODES DEBUG grib_set_long h=%p %s=%ld (a->name=%s)\n", (void*)h, name, val, a->name); else - fprintf(stderr, "ECCODES DEBUG grib_set_long %s=%ld\n", name, val); + fprintf(stderr, "ECCODES DEBUG grib_set_long h=%p %s=%ld\n", (void*)h, name, val); } if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_long(a, &val, &l); + ret = a->pack_long(&val, &l); if (ret == GRIB_SUCCESS) return grib_dependency_notify_change(a); @@ -133,7 +134,7 @@ int grib_set_long(grib_handle* h, const char* name, long val) } if (h->context->debug) { - fprintf(stderr, "ECCODES DEBUG grib_set_long %s=%ld (Key not found)\n", name, val); + fprintf(stderr, "ECCODES DEBUG grib_set_long h=%p %s=%ld (Key not found)\n", (void*)h, name, val); } return GRIB_NOT_FOUND; @@ -148,10 +149,10 @@ int grib_set_double_internal(grib_handle* h, const char* name, double val) a = grib_find_accessor(h, name); if (h->context->debug) - fprintf(stderr, "ECCODES DEBUG grib_set_double_internal %s=%.10g\n", name, val); + fprintf(stderr, "ECCODES DEBUG grib_set_double_internal h=%p %s=%.10g\n", (void*)h, name, val); if (a) { - ret = grib_pack_double(a, &val, &l); + ret = a->pack_double(&val, &l); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -349,15 +350,15 @@ int grib_set_double(grib_handle* h, const char* name, double val) if (a) { if (h->context->debug) { if (strcmp(name, a->name)!=0) - fprintf(stderr, "ECCODES DEBUG grib_set_double %s=%.10g (a->name=%s)\n", name, val, a->name); + fprintf(stderr, "ECCODES DEBUG grib_set_double h=%p %s=%.10g (a->name=%s)\n", (void*)h, name, val, a->name); else - fprintf(stderr, "ECCODES DEBUG grib_set_double %s=%.10g\n", name, val); + fprintf(stderr, "ECCODES DEBUG grib_set_double h=%p %s=%.10g\n", (void*)h, name, val); } if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_double(a, &val, &l); + ret = a->pack_double(&val, &l); if (ret == GRIB_SUCCESS) return grib_dependency_notify_change(a); @@ -375,10 +376,10 @@ int grib_set_string_internal(grib_handle* h, const char* name, a = grib_find_accessor(h, name); if (h->context->debug) - fprintf(stderr, "ECCODES DEBUG grib_set_string_internal %s=%s\n", name, val); + fprintf(stderr, "ECCODES DEBUG grib_set_string_internal h=%p %s=%s\n", (void*)h, name, val); if (a) { - ret = grib_pack_string(a, val, length); + ret = a->pack_string(val, length); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -467,15 +468,15 @@ int grib_set_string(grib_handle* h, const char* name, const char* val, size_t* l if (a) { if (h->context->debug) { if (strcmp(name, a->name)!=0) - fprintf(stderr, "ECCODES DEBUG grib_set_string %s=|%s| (a->name=%s)\n", name, val, a->name); + fprintf(stderr, "ECCODES DEBUG grib_set_string h=%p %s=|%s| (a->name=%s)\n", (void*)h, name, val, a->name); else - fprintf(stderr, "ECCODES DEBUG grib_set_string %s=|%s|\n", name, val); + fprintf(stderr, "ECCODES DEBUG grib_set_string h=%p %s=|%s|\n", (void*)h, name, val); } if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_string(a, val, length); + ret = a->pack_string(val, length); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -497,14 +498,14 @@ int grib_set_string_array(grib_handle* h, const char* name, const char** val, si a = grib_find_accessor(h, name); if (h->context->debug) { - fprintf(stderr, "ECCODES DEBUG grib_set_string_array key=%s %zu values\n", name, length); + fprintf(stderr, "ECCODES DEBUG grib_set_string_array h=%p key=%s %zu values\n", (void*)h, name, length); } if (a) { if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) return GRIB_READ_ONLY; - ret = grib_pack_string_array(a, val, &length); + ret = a->pack_string_array(val, &length); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -519,7 +520,7 @@ int grib_set_string_array(grib_handle* h, const char* name, const char** val, si // grib_accessor* a = NULL; // a = grib_find_accessor(h, name); // if (a) { -// ret = grib_pack_bytes(a, val, length); +// ret = a->pack_bytes(val, length); // if (ret == GRIB_SUCCESS) { // return grib_dependency_notify_change(a); // } @@ -540,7 +541,7 @@ int grib_set_bytes(grib_handle* h, const char* name, const unsigned char* val, s /* if(a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) */ /* return GRIB_READ_ONLY; */ - ret = grib_pack_bytes(a, val, length); + ret = a->pack_bytes(val, length); if (ret == GRIB_SUCCESS) { return grib_dependency_notify_change(a); } @@ -557,7 +558,7 @@ int grib_set_bytes(grib_handle* h, const char* name, const unsigned char* val, s // if (a) { // if (a->length == 0) // return 0; -// if ((ret = grib_pack_zero(a)) != GRIB_SUCCESS) +// if ((ret = a->grib_pack_zero()) != GRIB_SUCCESS) // grib_context_log(h->context, GRIB_LOG_ERROR, "Unable to clear %s (%s)", // name, grib_get_error_message(ret)); // return ret; @@ -579,9 +580,9 @@ int grib_set_missing(grib_handle* h, const char* name) if (grib_accessor_can_be_missing(a, &ret)) { if (h->context->debug) - fprintf(stderr, "ECCODES DEBUG grib_set_missing %s\n", name); + fprintf(stderr, "ECCODES DEBUG grib_set_missing h=%p %s\n", (void*)h, name); - ret = grib_pack_missing(a); + ret = a->pack_missing(); if (ret == GRIB_SUCCESS) return grib_dependency_notify_change(a); } @@ -637,7 +638,7 @@ int grib_accessor_is_missing(grib_accessor* a, int* err) *err = GRIB_SUCCESS; if (a) { if (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) - return grib_is_missing_internal(a); + return a->is_missing_internal(); else return 0; } @@ -697,7 +698,7 @@ static int _grib_set_double_array_internal(grib_handle* h, grib_accessor* a, if (err == GRIB_SUCCESS) { size_t len = buffer_len - *encoded_length; if (len) { - err = grib_pack_double(a, val + *encoded_length, &len); + err = a->pack_double(val + *encoded_length, &len); *encoded_length += len; if (err == GRIB_SUCCESS) { /* See ECC-778 */ @@ -729,7 +730,7 @@ static int _grib_set_double_array(grib_handle* h, const char* name, if (name[0] == '/' || name[0] == '#') { if (check && (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return GRIB_READ_ONLY; - err = grib_pack_double(a, val, &length); + err = a->pack_double(val, &length); encoded = length; } else @@ -754,7 +755,7 @@ int grib_set_double_array_internal(grib_handle* h, const char* name, const doubl if (length == 0) { grib_accessor* a = grib_find_accessor(h, name); - ret = grib_pack_double(a, val, &length); + ret = a->pack_double(val, &length); } else { ret = _grib_set_double_array(h, name, val, length, 0); @@ -783,7 +784,7 @@ static int __grib_set_double_array(grib_handle* h, const char* name, const doubl if (length == 0) { grib_accessor* a = grib_find_accessor(h, name); - return grib_pack_double(a, val, &length); + return a->pack_double(val, &length); } /*second order doesn't have a proper representation for constant fields @@ -873,7 +874,7 @@ static int _grib_set_long_array_internal(grib_handle* h, grib_accessor* a, const if (err == GRIB_SUCCESS) { size_t len = buffer_len - *encoded_length; if (len) { - err = grib_pack_long(a, val + *encoded_length, &len); + err = a->pack_long(val + *encoded_length, &len); *encoded_length += len; } else { @@ -903,7 +904,7 @@ static int _grib_set_long_array(grib_handle* h, const char* name, const long* va size_t N = 5; if (length <= N) N = length; - fprintf(stderr, "ECCODES DEBUG _grib_set_long_array key=%s %zu values (", name, length); + fprintf(stderr, "ECCODES DEBUG _grib_set_long_array h=%p key=%s %zu values (", (void*)h, name, length); for (i = 0; i < N; ++i) fprintf(stderr, " %ld,", val[i]); if (N >= length) @@ -915,7 +916,7 @@ static int _grib_set_long_array(grib_handle* h, const char* name, const long* va if (name[0] == '/' || name[0] == '#') { if (check && (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)) return GRIB_READ_ONLY; - err = grib_pack_long(a, val, &length); + err = a->pack_long(val, &length); encoded = length; } else @@ -989,14 +990,14 @@ int grib_get_long(const grib_handle* h, const char* name, long* val) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_unpack_long(al->accessor, val, &length); + ret = al->accessor->unpack_long(val, &length); grib_context_free(h->context, al); } else { a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - ret = grib_unpack_long(a, val, &length); + ret = a->unpack_long(val, &length); } return ret; } @@ -1024,14 +1025,14 @@ int grib_get_double(const grib_handle* h, const char* name, double* val) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_unpack_double(al->accessor, val, &length); + ret = al->accessor->unpack_double(val, &length); grib_context_free(h->context, al); } else { a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - ret = grib_unpack_double(a, val, &length); + ret = a->unpack_double(val, &length); } return ret; } @@ -1047,14 +1048,14 @@ int grib_get_float(const grib_handle* h, const char* name, float* val) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_unpack_float(al->accessor, val, &length); + ret = al->accessor->unpack_float(val, &length); grib_context_free(h->context, al); } else { a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - ret = grib_unpack_float(a, val, &length); + ret = a->unpack_float(val, &length); } return ret; } @@ -1076,7 +1077,7 @@ int grib_get_double_element(const grib_handle* h, const char* name, int i, doubl grib_accessor* act = grib_find_accessor(h, name); if (act) { - return grib_unpack_double_element(act, i, val); + return act->unpack_double_element(i, val); } return GRIB_NOT_FOUND; } @@ -1085,7 +1086,7 @@ int grib_get_float_element(const grib_handle* h, const char* name, int i, float* grib_accessor* act = grib_find_accessor(h, name); if (act) { - return grib_unpack_float_element(act, i, val); + return act->unpack_float_element(i, val); } return GRIB_NOT_FOUND; } @@ -1118,7 +1119,7 @@ int grib_get_double_element_set(const grib_handle* h, const char* name, const si grib_accessor* acc = grib_find_accessor(h, name); if (acc) { - return grib_unpack_double_element_set(acc, index_array, len, val_array); + return acc->unpack_double_element_set(index_array, len, val_array); } return GRIB_NOT_FOUND; } @@ -1127,7 +1128,7 @@ int grib_get_float_element_set(const grib_handle* h, const char* name, const siz grib_accessor* acc = grib_find_accessor(h, name); if (acc) { - return grib_unpack_float_element_set(acc, index_array, len, val_array); + return acc->unpack_float_element_set(index_array, len, val_array); } return GRIB_NOT_FOUND; } @@ -1168,7 +1169,7 @@ int grib_get_double_elements(const grib_handle* h, const char* name, const int* return GRIB_OUT_OF_MEMORY; } - err = grib_unpack_double(act, values, &size); + err = act->unpack_double(values, &size); if (!err) { for (j = 0; j < len; j++) { val_array[j] = values[index_array[j]]; @@ -1206,7 +1207,7 @@ int grib_get_string(const grib_handle* h, const char* name, char* val, size_t* l al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_unpack_string(al->accessor, val, length); + ret = al->accessor->unpack_string(val, length); grib_context_free(h->context, al); return ret; } @@ -1214,7 +1215,7 @@ int grib_get_string(const grib_handle* h, const char* name, char* val, size_t* l a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - return grib_unpack_string(a, val, length); + return a->unpack_string(val, length); } } @@ -1232,7 +1233,7 @@ int grib_get_bytes(const grib_handle* h, const char* name, unsigned char* val, s { int err = 0; grib_accessor* act = grib_find_accessor(h, name); - err = act ? grib_unpack_bytes(act, val, length) : GRIB_NOT_FOUND; + err = act ? act->unpack_bytes(val, length) : GRIB_NOT_FOUND; if (err) grib_context_log(h->context, GRIB_LOG_ERROR, "grib_get_bytes %s failed %s", name, grib_get_error_message(err)); @@ -1251,14 +1252,14 @@ int grib_get_native_type(const grib_handle* h, const char* name, int* type) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - *type = grib_accessor_get_native_type(al->accessor); + *type = al->accessor->get_native_type(); grib_context_free(h->context, al); } else { a = grib_find_accessor(h, name); if (!a) return GRIB_NOT_FOUND; - *type = grib_accessor_get_native_type(a); + *type = a->get_native_type(); } return GRIB_SUCCESS; @@ -1279,7 +1280,12 @@ static int _grib_get_array_internal(const grib_handle* h, grib_accessor* a, T* v if (err == GRIB_SUCCESS) { size_t len = buffer_len - *decoded_length; - err = grib_unpack(a, val + *decoded_length, &len); + if constexpr (std::is_same::value) { + err = a->unpack_double(val + *decoded_length, &len); + } + else if constexpr (std::is_same::value) { + err = a->unpack_float(val + *decoded_length, &len); + } *decoded_length += len; } @@ -1311,7 +1317,7 @@ int grib_get_double_array(const grib_handle* h, const char* name, double* val, s al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_accessors_list_unpack_double(al, val, length); + ret = al->unpack_double(val, length); grib_accessors_list_delete(h->context, al); return ret; } @@ -1320,7 +1326,7 @@ int grib_get_double_array(const grib_handle* h, const char* name, double* val, s if (!a) return GRIB_NOT_FOUND; if (name[0] == '#') { - return grib_unpack(a, val, length); + return a->unpack_double(val, length); } else { *length = 0; @@ -1364,7 +1370,7 @@ int grib_get_string_length_acc(grib_accessor* a, size_t* size) *size = 0; while (a) { - s = grib_string_length(a); + s = a->string_length(); if (s > *size) *size = s; a = a->same; @@ -1407,7 +1413,7 @@ int grib_get_size_acc(const grib_handle* h, grib_accessor* a, size_t* size) *size = 0; while (a) { if (err == 0) { - err = grib_value_count(a, &count); + err = a->value_count(&count); if (err) return err; *size += count; @@ -1429,7 +1435,7 @@ int grib_get_size(const grib_handle* ch, const char* name, size_t* size) al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_accessors_list_value_count(al, size); + ret = al->value_count(size); grib_accessors_list_delete(h->context, al); return ret; } @@ -1439,7 +1445,7 @@ int grib_get_size(const grib_handle* ch, const char* name, size_t* size) return GRIB_NOT_FOUND; if (name[0] == '#') { long count = *size; - ret = grib_value_count(a, &count); + ret = a->value_count(&count); *size = count; return ret; } @@ -1471,7 +1477,7 @@ int grib_get_offset(const grib_handle* ch, const char* key, size_t* val) const grib_handle* h = (grib_handle*)ch; grib_accessor* act = grib_find_accessor(h, key); if (act) { - *val = (size_t)grib_byte_offset(act); + *val = (size_t) act->byte_offset(); return GRIB_SUCCESS; } return GRIB_NOT_FOUND; @@ -1484,7 +1490,7 @@ static int grib_get_string_array_internal_(const grib_handle* h, grib_accessor* if (err == GRIB_SUCCESS) { size_t len = buffer_len - *decoded_length; - err = grib_unpack_string_array(a, val + *decoded_length, &len); + err = a->unpack_string_array(val + *decoded_length, &len); *decoded_length += len; } @@ -1506,7 +1512,7 @@ int grib_get_string_array(const grib_handle* h, const char* name, char** val, si al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_accessors_list_unpack_string(al, val, length); + ret = al->unpack_string(val, length); grib_context_free(h->context, al); return ret; } @@ -1515,7 +1521,7 @@ int grib_get_string_array(const grib_handle* h, const char* name, char** val, si if (!a) return GRIB_NOT_FOUND; if (name[0] == '#') { - return grib_unpack_string_array(a, val, length); + return a->unpack_string_array(val, length); } else { *length = 0; @@ -1531,7 +1537,7 @@ static int _grib_get_long_array_internal(const grib_handle* h, grib_accessor* a, if (err == GRIB_SUCCESS) { size_t len = buffer_len - *decoded_length; - err = grib_unpack_long(a, val + *decoded_length, &len); + err = a->unpack_long(val + *decoded_length, &len); *decoded_length += len; } @@ -1565,7 +1571,7 @@ int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_ al = grib_find_accessors_list(h, name); if (!al) return GRIB_NOT_FOUND; - ret = grib_accessors_list_unpack_long(al, val, length); + ret = al->unpack_long(val, length); grib_context_free(h->context, al); } else { @@ -1573,7 +1579,7 @@ int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_ if (!a) return GRIB_NOT_FOUND; if (name[0] == '#') { - return grib_unpack_long(a, val, length); + return a->unpack_long(val, length); } else { *length = 0; @@ -1838,7 +1844,7 @@ int grib_get_nearest_smaller_value(grib_handle* h, const char* name, { grib_accessor* act = grib_find_accessor(h, name); Assert(act); - return grib_nearest_smaller_value(act, val, nearest); + return act->nearest_smaller_value(val, nearest); } void grib_print_values(const char* title, grib_values* values, FILE* out) @@ -2028,5 +2034,5 @@ int codes_compare_key(grib_handle* h1, grib_handle* h2, const char* key, int com return GRIB_NOT_FOUND; } - return grib_compare_accessors(a1, a2, GRIB_COMPARE_TYPES); + return a1->compare_accessors(a2, GRIB_COMPARE_TYPES); } diff --git a/src/make_accessor_class_hash.sh b/src/make_accessor_class_hash.sh index 8a3f26f79..72955ae4a 100755 --- a/src/make_accessor_class_hash.sh +++ b/src/make_accessor_class_hash.sh @@ -6,7 +6,7 @@ cat > accessor_class_list.gperf <> 3); + o <<= 7 - ((*bitp) % 8); + *p |= o; + (*bitp) += 1; +} + +long convert_to_minutes(long step, long stepUnits) +{ + double result = 0; + if (stepUnits == 0) + return step; /* unit=minutes so no change */ + if (stepUnits == 1) + return step * 60; /* unit=hours */ + if (stepUnits == 13) + return step / 60; /* unit=seconds */ + /* Assert( stepUnits < sizeof(u2m)/sizeof(u2m[0]) ); */ + + result = step * u2m[stepUnits]; + return (long)result; +} + diff --git a/src/shared_functions.h b/src/shared_functions.h new file mode 100644 index 000000000..04ae2f90f --- /dev/null +++ b/src/shared_functions.h @@ -0,0 +1,9 @@ +#ifndef eccodes_shared_functions_h +#define eccodes_shared_functions_h + +#include "grib_api_internal.h" + +void grib_set_bit_on(unsigned char*, long*); +long convert_to_minutes(long step, long stepUnits); + +#endif // eccodes_shared_functions_h diff --git a/src/step_unit.cc b/src/step_unit.cc index bd192a6e7..a842430f2 100644 --- a/src/step_unit.cc +++ b/src/step_unit.cc @@ -12,8 +12,6 @@ namespace eccodes { -Unit::Map Unit::map_{}; - std::vector Unit::grib_selected_units = { Unit::Value::SECOND, Unit::Value::MINUTE, @@ -39,7 +37,7 @@ std::vector Unit::complete_unit_order_ = { }; template <> long Unit::value() const { - return map_.unit_to_long(internal_value_); + return get_converter().unit_to_long(internal_value_); } template <> Unit::Value Unit::value() const { @@ -47,7 +45,7 @@ template <> Unit::Value Unit::value() const { } template <> std::string Unit::value() const { - return map_.unit_to_name(internal_value_); + return get_converter().unit_to_name(internal_value_); } } // namespace eccodes diff --git a/src/step_unit.h b/src/step_unit.h index bd078f403..0d6bc4e4e 100644 --- a/src/step_unit.h +++ b/src/step_unit.h @@ -68,7 +68,7 @@ public: explicit Unit(const std::string& unit_value) { try { - internal_value_ = map_.name_to_unit(unit_value); + internal_value_ = get_converter().name_to_unit(unit_value); } catch (std::exception& e) { throw std::runtime_error(std::string{"Unit not found "} + e.what()); } @@ -76,15 +76,15 @@ public: explicit Unit(long unit_value) { try { - internal_value_ = map_.long_to_unit(unit_value); + internal_value_ = get_converter().long_to_unit(unit_value); } catch (std::exception& e) { throw std::runtime_error(std::string{"Unit not found "} + e.what()); } } - bool operator>(const Unit& other) const {return map_.unit_to_duration(internal_value_) > map_.unit_to_duration(other.internal_value_);} - bool operator==(const Value value) const {return map_.unit_to_duration(internal_value_) == map_.unit_to_duration(value);} - bool operator==(const Unit& unit) const {return map_.unit_to_duration(internal_value_) == map_.unit_to_duration(unit.internal_value_);} + bool operator>(const Unit& other) const {return get_converter().unit_to_duration(internal_value_) > get_converter().unit_to_duration(other.internal_value_);} + bool operator==(const Value value) const {return get_converter().unit_to_duration(internal_value_) == get_converter().unit_to_duration(value);} + bool operator==(const Unit& unit) const {return get_converter().unit_to_duration(internal_value_) == get_converter().unit_to_duration(unit.internal_value_);} bool operator!=(const Unit& unit) const {return !(*this == unit);} bool operator!=(const Value value) const {return !(*this == value);} @@ -177,13 +177,14 @@ private: Value internal_value_; - static Map map_; public: - static Map& get_converter() {return map_;} + static Map& get_converter() { + static Map map_; + return map_; + } }; - template Seconds to_seconds(long value, const Unit& unit) { Seconds seconds; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 21640b8bb..ac0f133de 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,6 +18,7 @@ list(APPEND test_c_bins grib_double_cmp read_any julian + grib_update_sections_lengths grib_indexing grib_fieldset grib_multi_from_message @@ -45,6 +46,7 @@ list(APPEND test_c_bins grib_ecc-1467 grib_ecc-1431 grib_ecc-1433 + grib_ecc-1764 bufr_ecc-517 bufr_ecc-1288 bufr_get_element @@ -102,6 +104,8 @@ if( HAVE_BUILD_TOOLS ) grib_ifsParam grib_packing_order filter_substr + filter_size + filter_is_one_of filter_is_in_list filter_transient_darray grib_uerra @@ -142,6 +146,8 @@ if( HAVE_BUILD_TOOLS ) grib_ecc-1671 grib_ecc-1708 grib_ecc-1691 + grib_ecc-1766 + grib_ecc-1806 bufr_ecc-1028 bufr_ecc-1195 bufr_ecc-1259 @@ -168,6 +174,8 @@ if( HAVE_BUILD_TOOLS ) # and/or take much longer list(APPEND tests_extra grib_data_quality_checks + grib_update_sections_lengths + grib_units_bias_factor grib_set_large_message_fail grib_g1monthlydate grib_g1fcperiod @@ -218,6 +226,13 @@ if( HAVE_BUILD_TOOLS ) grib_keys_iter grib_keys_iter_skip grib_geo_iter + grib_to_json + grib_to_ppm + grib_merge + big2gribex + grib_sub_area_check + grib_list_keys + grib_histogram bufr_get_element bufr_wmo_tables bufr_extract_headers @@ -244,6 +259,7 @@ if( HAVE_BUILD_TOOLS ) bufr_ecc-1305 bufr_ecc-1476 bufr_ecc-1623 + bufr_ecc-1785 grib_ecc-490 grib_ecc-756 grib_ecc-806 @@ -259,6 +275,8 @@ if( HAVE_BUILD_TOOLS ) grib_ecc-1397 grib_ecc-1425 grib_ecc-1467 + grib_ecc-1764 + grib_ecc-1792 grib_sub_hourly grib_set_bytes grib_set_force @@ -299,6 +317,7 @@ if( HAVE_BUILD_TOOLS ) grib_ls grib_ls_json grib_filter + grib_filter_fail grib_multi grib_nearest_test pseudo_budg @@ -382,7 +401,8 @@ if( HAVE_BUILD_TOOLS ) ecbuild_add_test( TARGET eccodes_t_grib_repair TYPE SCRIPT CONDITION ECCODES_INSTALL_EXTRA_TOOLS AND ENABLE_EXTRA_TESTS - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_repair.sh ) + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_repair.sh + TEST_DEPENDS eccodes_download_gribs ) # Note: making the test dependent on the grib files (with DEPENDS) diff --git a/tests/big2gribex.sh b/tests/big2gribex.sh new file mode 100755 index 000000000..acc78cdf2 --- /dev/null +++ b/tests/big2gribex.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="big2gribex_test" +tempGrib=temp.$label.grib + +if [ ! -x ${tools_dir}/big2gribex ]; then + exit 0 +fi + +set +e +${tools_dir}/big2gribex +status=$? +set -e +[ $status -ne 0 ] + +${tools_dir}/big2gribex $data_dir/test.grib1 $tempGrib + +# Clean up +rm -f $tempGrib diff --git a/tests/bufr_ecc-1785.sh b/tests/bufr_ecc-1785.sh new file mode 100755 index 000000000..1a4ae4a2c --- /dev/null +++ b/tests/bufr_ecc-1785.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +# --------------------------------------------------------- +# This is the test for the JIRA issue ECC-1785 +# BUFR: Allow encoding satelliteID when rdbType=30 +# --------------------------------------------------------- + +label="bufr_ecc-1785_test" + +tempBufr=temp.$label.bufr +tempFilt=temp.$label.filt +tempLog=temp.$label.log + +sample_bufr4=$ECCODES_SAMPLES_PATH/BUFR3_local_satellite.tmpl + +echo 'set numberOfSubsets=1; set rdbType=30; set satelliteID=78; write;' > $tempFilt + +${tools_dir}/codes_bufr_filter -o $tempBufr $tempFilt $sample_bufr4 + +result=$(${tools_dir}/bufr_get -p isSatelliteType,isSatellite,satelliteID $tempBufr) +[ "$result" = "1 1 78" ] + +# Clean up +rm -f $tempBufr $tempFilt $tempLog diff --git a/tests/bufr_ecc-517.cc b/tests/bufr_ecc-517.cc index e4dc5d563..2ad8d7ab4 100644 --- a/tests/bufr_ecc-517.cc +++ b/tests/bufr_ecc-517.cc @@ -20,10 +20,9 @@ int main(int argc, char** argv) codes_handle* h = NULL; long* ivalues = NULL; const char* sampleName = "BUFR3_local"; - char* outfilename = NULL; assert(argc == 2); - outfilename = argv[1]; + char* outfilename = argv[1]; // Test non-existent sample file. Should fail h = codes_bufr_handle_new_from_samples(NULL, "some rubbish"); @@ -33,10 +32,8 @@ int main(int argc, char** argv) assert(h); ivalues = (long*)malloc(1 * sizeof(long)); - if (!ivalues) { - fprintf(stderr, "Failed to allocate memory (ivalues).\n"); - return 1; - } + assert(ivalues); + size = 1; ivalues[0] = 1; CODES_CHECK(codes_set_long_array(h, "inputDelayedDescriptorReplicationFactor", ivalues, size), 0); @@ -89,10 +86,8 @@ int main(int argc, char** argv) free(ivalues); ivalues = (long*)malloc(9 * sizeof(long)); - if (!ivalues) { - fprintf(stderr, "Failed to allocate memory (ivalues).\n"); - return 1; - } + assert(ivalues); + size = 4; ivalues[0] = 309052; ivalues[1] = 5001; @@ -104,11 +99,8 @@ int main(int argc, char** argv) CODES_CHECK(codes_set_long(h, "pack", 1), 0); fout = fopen(outfilename, "wb"); - if (!fout) { - fprintf(stderr, "Failed to open (create) output file.\n"); - free(ivalues); - return 1; - } + assert(fout); + CODES_CHECK(codes_get_message(h, &buffer, &size), 0); CODES_CHECK(codes_check_message_header(buffer, size, PRODUCT_BUFR), 0); CODES_CHECK(codes_check_message_footer(buffer, size, PRODUCT_BUFR), 0); @@ -120,8 +112,17 @@ int main(int argc, char** argv) } fclose(fout); + + // expandedOriginalCodes + long orig[100]; + size = 100; + CODES_CHECK(codes_get_long_array(h, "expandedOriginalCodes", orig, &size), 0); + printf("Size of expandedOriginalCodes = %zu\n", size); + codes_handle_delete(h); free(ivalues); + codes_context_delete(0); + return 0; } diff --git a/tests/bufr_extract_headers.sh b/tests/bufr_extract_headers.sh index 6b6f0a907..4b2b92b08 100755 --- a/tests/bufr_extract_headers.sh +++ b/tests/bufr_extract_headers.sh @@ -14,6 +14,8 @@ label="bufr_extract_headers_test" temp1="temp.${label}.1" temp2="temp.${label}.2" +tempBufr=temp.$label.bufr +tempFilt=temp.$label.filt # Multi-message BUFR # -------------------- @@ -62,7 +64,7 @@ r=`${test_dir}/bufr_extract_headers centre ${data_dir}/bufr/israel_observations_ # Check all centres with an abbreviation centre_table=${ECCODES_DEFINITION_PATH}/common/c-11.table -centres=`awk 'NR > 1 {print $2}' < $centre_table` +centres=`awk 'NR > 1 && $1 !~ /#/ {print $2}' < $centre_table` for c in $centres; do ${tools_dir}/bufr_set -s centre=$c $ECCODES_SAMPLES_PATH/BUFR4.tmpl $temp1 r=`${test_dir}/bufr_extract_headers centre $temp1` @@ -115,26 +117,16 @@ amsu_55.bufr amv2_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_89.bufr -cmwi_87.bufr cmwn_87.bufr cori_156.bufr -crit_202.bufr -csrh_189.bufr emsg_189.bufr euwv_87.bufr fy3a_154.bufr @@ -150,20 +142,14 @@ 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 -mloz_206.bufr -modi_87.bufr -modw_87.bufr -monw_87.bufr nomi_206.bufr nos1_208.bufr pgps_110.bufr @@ -172,8 +158,6 @@ s4kn_165.bufr sb19_206.bufr sbu8_206.bufr smin_49.bufr -smiu_49.bufr -smos_203.bufr sn4k_165.bufr ssbt_127.bufr tmr7_129.bufr @@ -208,6 +192,14 @@ ${tools_dir}/bufr_set -s restricted=1 $input $temp1 r=`$EXEC ${test_dir}/bufr_extract_headers restricted $temp1` [ "$r" = "1" ] +# ECC-1785 Allow encoding satelliteID when rdbType=30 +# ---------------------------------------------------- +sample_bufr4=$ECCODES_SAMPLES_PATH/BUFR3_local_satellite.tmpl +echo 'set numberOfSubsets=1; set rdbType=30; set satelliteID=78; write;' > $tempFilt +${tools_dir}/codes_bufr_filter -o $tempBufr $tempFilt $sample_bufr4 +r=$(${test_dir}/bufr_extract_headers isSatellite,satelliteID $tempBufr) +[ "$r" = "1 78" ] + echo "Test with invalid inputs..." # --------------------------------- @@ -217,4 +209,39 @@ status=$? set -e [ $status -ne 0 ] + +echo "Test with nonexistent file..." +# --------------------------------- +set +e +$EXEC ${test_dir}/bufr_extract_headers centre nosuchfile > $temp1 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Unable to read file" $temp1 + + +echo "Test with bad BUFR file..." +# --------------------------------- +echo BUFR > $temp1 +set +e +$EXEC ${test_dir}/bufr_extract_headers centre $temp1 > $temp2 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Unable to count BUFR messages" $temp2 + + +echo "Test with GRIB file..." +# --------------------------------- +input=${data_dir}/sample.grib2 +set +e +$EXEC ${test_dir}/bufr_extract_headers centre $input > $temp2 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "No BUFR messages in file" $temp2 + + +# Clean up rm -f $temp1 $temp2 +rm -f $tempBufr $tempFilt diff --git a/tests/bufr_filter_misc.sh b/tests/bufr_filter_misc.sh index f1edf0368..f2021a3f5 100755 --- a/tests/bufr_filter_misc.sh +++ b/tests/bufr_filter_misc.sh @@ -1290,6 +1290,15 @@ cat > $fRules < $fLog +# smart table unpack_string +tempBufr=temp.$label.bufr +f="$ECCODES_SAMPLES_PATH/BUFR4.tmpl" +cat > $fRules < $fLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Input file seems to be GRIB" $fLog + +f=$ECCODES_SAMPLES_PATH/budg.tmpl +set +e +${tools_dir}/bufr_get -p edition $f > $fLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Input file seems to be GRIB" $fLog + # ---------------------------------------- # Unreadable message diff --git a/tests/bufr_indexing.sh b/tests/bufr_indexing.sh index 297f71bba..cc1c4cb39 100755 --- a/tests/bufr_indexing.sh +++ b/tests/bufr_indexing.sh @@ -45,6 +45,15 @@ ${tools_dir}/bufr_index_build -k mars.ident -o $tempIndex $infile |\ # ------------------ # Error conditions # ------------------ +infile=${data_dir}/bufr/vos308014_v3_26.bufr +set +e +${tools_dir}/bufr_index_build -o $tempIndex $infile > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Unable to unpack BUFR to create index" $tempOut + + echo BUFR > $tempBufr set +e ${tools_dir}/bufr_index_build $tempBufr > $tempOut 2>&1 diff --git a/tests/bufr_keys_iter.cc b/tests/bufr_keys_iter.cc index f2ab295b7..9938fcdd5 100644 --- a/tests/bufr_keys_iter.cc +++ b/tests/bufr_keys_iter.cc @@ -12,12 +12,6 @@ #undef NDEBUG #include -static void usage(const char* prog) -{ - printf("usage: %s [-a|-d] infile\n", prog); - exit(1); -} - #define ITER_ALL_KEYS 1 #define ITER_DATA_KEYS 2 @@ -28,12 +22,11 @@ int main(int argc, char* argv[]) codes_handle* h = NULL; codes_bufr_keys_iterator* kiter = NULL; char* input_filename = NULL; - const char* prog = argv[0]; FILE* f = NULL; int iterator_mode = ITER_ALL_KEYS; if (argc == 1 || argc > 3) - usage(prog); + return 1; // usage: prog [-a|-d] infile for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-a") == 0) { diff --git a/tests/codes_compare_keys.cc b/tests/codes_compare_keys.cc index 116998de7..2b930ea11 100644 --- a/tests/codes_compare_keys.cc +++ b/tests/codes_compare_keys.cc @@ -54,6 +54,8 @@ int main(int argc, char* argv[]) codes_compare_key(h1, h2, "computeStatistics", 0); // statistics codes_compare_key(h1, h2, "paramId", 0); // concept codes_compare_key(h1, h2, "identifier", 0); // ascii + err = codes_compare_key(h1, h2, "abcdefghij", 0); // no such key + Assert(err == GRIB_NOT_FOUND); if (list_provided_keys) { for (i = 0; list_provided_keys[i] != NULL; ++i) { diff --git a/tests/codes_compare_keys.sh b/tests/codes_compare_keys.sh index 9a2a39aef..b07e6edc0 100755 --- a/tests/codes_compare_keys.sh +++ b/tests/codes_compare_keys.sh @@ -37,6 +37,7 @@ key: hoursAfterDataCutoff (Long values are different) key: minutesAfterDataCutoff (Long values are different) key: numberOfValues (Long values are different) key: referenceValue (Double values are different) +ECCODES ERROR : Key abcdefghij not found in first message Comparison failed: 13 differences EOF @@ -57,6 +58,7 @@ cat $tempLog cat > $tempRef < $tempText +$EXEC ${test_dir}/codes_get_string GRIB $tempGrib dayOfTheYearDate # 2> $tempText input=$data_dir/reduced_latlon_surface.grib2 -keys="identifier projString bitmap class year gridDefinitionDescription +keys="hundred identifier projString bitmap class year gridDefinitionDescription time validityTime packingType md5Headers parameterUnits" for k in $keys; do - $EXEC ${test_dir}/codes_get_string $input $k 2> $tempText + $EXEC ${test_dir}/codes_get_string GRIB $input $k 2> $tempText grep -q "Buffer too small" $tempText done input=$ECCODES_SAMPLES_PATH/reduced_gg_ml_grib2.tmpl -$EXEC ${test_dir}/codes_get_string "$input" gridName 2> $tempText +$EXEC ${test_dir}/codes_get_string GRIB "$input" gridName 2> $tempText grep -q "Buffer too small" $tempText # shortName = swh input=$data_dir/reduced_latlon_surface.grib1 -$EXEC ${test_dir}/codes_get_string "$input" shortName 2> $tempText +$EXEC ${test_dir}/codes_get_string GRIB "$input" shortName 2> $tempText grep -q "Buffer too small" $tempText +input=$data_dir/gts/EGRR20150317121020_00493212.DAT +$EXEC ${test_dir}/codes_get_string GTS "$input" theMessage 2> $tempText +grep -q "Buffer too small" $tempText -rm -f $tempText +# Clean up +rm -f $tempText $tempGrib diff --git a/tests/create_test.sh b/tests/create_test.sh index 3be842e8e..a63abcb5f 100755 --- a/tests/create_test.sh +++ b/tests/create_test.sh @@ -43,6 +43,7 @@ tempGrib=temp.\$label.grib tempBufr=temp.\$label.bufr tempFilt=temp.\$label.filt tempLog=temp.\$label.log +tempOut=temp.\$label.txt tempRef=temp.\$label.ref sample_grib2=\$ECCODES_SAMPLES_PATH/GRIB2.tmpl @@ -61,7 +62,8 @@ sample_bufr4=\$ECCODES_SAMPLES_PATH/BUFR4.tmpl #\${tools_dir}/bufr_set #... -rm -f \$tempGrib \$tempBufr \$tempFilt \$tempLog \$tempRef +# Clean up +rm -f \$tempGrib \$tempBufr \$tempFilt \$tempLog \$tempOut \$tempRef EOF echo >&2 diff --git a/tests/definitions.sh b/tests/definitions.sh index b841e2834..ecd5d5f4a 100755 --- a/tests/definitions.sh +++ b/tests/definitions.sh @@ -16,7 +16,7 @@ tempOut=temp.$label.txt [ -z "$ECCODES_DEFINITION_PATH" ] || ECCODES_DEFINITION_PATH=`${tools_dir}/codes_info -d` -for file in `find ${ECCODES_DEFINITION_PATH}/ -name '*.def' -print | grep -v grib3/` +for file in `find ${ECCODES_DEFINITION_PATH}/ -name '*.def' -print | grep -v grib3/ | grep -v metar/ | grep -v taf/` do ${tools_dir}/codes_parser $file > $REDIRECT done diff --git a/tests/filter_is_one_of.sh b/tests/filter_is_one_of.sh new file mode 100755 index 000000000..96099d60e --- /dev/null +++ b/tests/filter_is_one_of.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="filter_is_one_of_test" +tempFilt=temp.$label.filt +tempOut=temp.$label.txt + +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +grib_check_key_equals $input "shortName,paramId,typeOfLevel" "t 130 surface" + +cat > $tempFilt < $tempFilt < $tempOut +grep "size of pl is 64" $tempOut + +${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/reduced_gg_pl_64_grib2.tmpl > $tempOut +grep "size of pl is 128" $tempOut + +# Clean up +rm -f $tempFilt $tempOut diff --git a/tests/gauss_sub.cc b/tests/gauss_sub.cc index b1114e964..b743b5d3c 100644 --- a/tests/gauss_sub.cc +++ b/tests/gauss_sub.cc @@ -10,12 +10,6 @@ #include "grib_api.h" -static void usage(char* prog) -{ - printf("usage: %s file1.grib file2.grib\n", prog); - exit(1); -} - int main(int argc, char* argv[]) { grib_handle *h1, *h2; @@ -34,7 +28,7 @@ int main(int argc, char* argv[]) c = grib_context_get_default(); - if (argc < 3) usage(argv[0]); + if (argc < 3) return 1;//usage: %s file1.grib file2.grib infile1 = argv[1]; infile2 = argv[2]; diff --git a/tests/grib2_templates.sh b/tests/grib2_templates.sh index 437eb36b1..64b43e4ad 100755 --- a/tests/grib2_templates.sh +++ b/tests/grib2_templates.sh @@ -180,6 +180,61 @@ test_PDTN_conversions 57 67 test_PDTN_conversions 58 68 test_PDTN_conversions 71 73 +# ECC-1779: Deprecated and experimental templates +# ------------------------------------------------ +grib_check_key_equals $sample2 isTemplateDeprecated,isTemplateExperimental '0 0' + +$tools_dir/grib_set -s productDefinitionTemplateNumber=44 $sample2 $temp +grib_check_key_equals $temp isTemplateDeprecated,isTemplateExperimental '1 0' + +$tools_dir/grib_set -s productDefinitionTemplateNumber=10 $sample2 $temp +grib_check_key_equals $temp isTemplateDeprecated,isTemplateExperimental '0 1' + +$tools_dir/grib_set -s gridType=cross_section $sample2 $temp +grib_check_key_equals $temp isTemplateDeprecated,isTemplateExperimental '0 1' +$tools_dir/grib_set -s gridType=time_section $sample2 $temp +grib_check_key_equals $temp isTemplateDeprecated,isTemplateExperimental '0 1' + +# Use of eps key (for local section) +# ----------------------------------- +input=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl +$tools_dir/grib_set -s stepType=accum,eps=1 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber '11' + +#17 Ensemble mean +#18 Ensemble standard deviation +$tools_dir/grib_set -s type=17,stepType=accum,eps=1 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber,derivedForecast '12 0' + +$tools_dir/grib_set -s type=18,stepType=accum,eps=1 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber,derivedForecast '12 4' + +# Chemicals +$tools_dir/grib_set -s paramId=217019,stepType=instant,eps=0 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber '40' + +$tools_dir/grib_set -s paramId=217019,stepType=instant,eps=1 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber '41' + +$tools_dir/grib_set -s paramId=217019,stepType=accum,eps=0 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber '42' + +$tools_dir/grib_set -s paramId=217019,stepType=accum,eps=1 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber '43' + +# Aerosol 210072 +$tools_dir/grib_set -s paramId=210072,stepType=instant,eps=0 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber '48' + +$tools_dir/grib_set -s paramId=210072,stepType=instant,eps=1 $input $temp +grib_check_key_equals $temp productDefinitionTemplateNumber '45' + +#$tools_dir/grib_set -s paramId=210072,stepType=accum,eps=0 $input $temp +#grib_check_key_equals $temp productDefinitionTemplateNumber '42' + +#$tools_dir/grib_set -s paramId=210072,stepType=accum,eps=1 $input $temp +#grib_check_key_equals $temp productDefinitionTemplateNumber '43' + # Clean up rm -f $temp $temp1 $temp2 $tempFilt $tempText diff --git a/tests/grib2_version.sh b/tests/grib2_version.sh index 6e6daef42..8b3119767 100755 --- a/tests/grib2_version.sh +++ b/tests/grib2_version.sh @@ -62,7 +62,6 @@ ${tools_dir}/grib_filter $tempFilt $sample2 > $tempText 2>&1 status=$? set -e [ $status -ne 0 ] -cat $tempText grep -q "Definition files version .* is greater than engine version" $tempText rm -f $tempFilt $temp $tempText diff --git a/tests/grib_bpv_limit.cc b/tests/grib_bpv_limit.cc index b5a3af0f6..896e0cff7 100644 --- a/tests/grib_bpv_limit.cc +++ b/tests/grib_bpv_limit.cc @@ -25,12 +25,6 @@ static double compare_double_absolute(double a, double b, double tolerance) return ret; } -static void usage(const char* prog) -{ - fprintf(stderr, "usage: %s input\n", prog); - exit(1); -} - static int check_error_code(int err) { if (err == GRIB_INVALID_BPV || err == GRIB_DECODING_ERROR) @@ -40,28 +34,24 @@ static int check_error_code(int err) int main(int argc, char** argv) { - int err = 0, i; + int err = 0, i; size_t values_len = 0; - double* values = NULL; - char error_msg[100]; const double tolerance = 1e-5; - size_t slong = sizeof(long) * 8; - grib_handle* h; - char* filename; + size_t slong = sizeof(long) * 8; - if (argc < 2) usage(argv[0]); - filename = argv[1]; + Assert(argc == 2); + char* filename = argv[1]; for (i = 0; i < 255; i++) { FILE* in = fopen(filename, "rb"); Assert(in); - h = grib_handle_new_from_file(0, in, &err); + grib_handle* h = grib_handle_new_from_file(0, in, &err); Assert(h); /* get the size of the values array*/ GRIB_CHECK(grib_get_size(h, "values", &values_len), 0); - values = (double*)malloc(values_len * sizeof(double)); + double* values = (double*)malloc(values_len * sizeof(double)); err = grib_get_double_array(h, "values", values, &values_len); if (compare_double_absolute(values[0], 2.7900000000e+02, tolerance) != 0) @@ -88,9 +78,8 @@ int main(int argc, char** argv) /* do nothing */ } else { - snprintf(error_msg, sizeof(error_msg), "Error decoding when bpv=%d. Error message:%s", i, grib_get_error_message(err)); - perror(error_msg); - exit(1); + fprintf(stderr, "Error decoding when bpv=%d. Error message:%s\n", i, grib_get_error_message(err)); + return 1; } values = (double*)malloc(values_len * sizeof(double)); @@ -108,9 +97,8 @@ int main(int argc, char** argv) /* do nothing */ } else { - snprintf(error_msg, sizeof(error_msg), "Error decoding when bpv=%d. Error message:%s", i, grib_get_error_message(err)); - perror(error_msg); - exit(1); + fprintf(stderr, "Error decoding when bpv=%d. Error message:%s\n", i, grib_get_error_message(err)); + return 1; } free(values); diff --git a/tests/grib_ccsds.sh b/tests/grib_ccsds.sh index bb37f060c..13533ab90 100755 --- a/tests/grib_ccsds.sh +++ b/tests/grib_ccsds.sh @@ -22,6 +22,11 @@ logfile=temp.$label.log rm -f $outfile1 $outfile2 +# Debug info +ECCODES_DEBUG=-1 ${tools_dir}/grib_copy -r $infile $outfile1 > $logfile 2>&1 +grep -q "ECCODES DEBUG CCSDS .* aec_stream.flags" $logfile + + # Convert a non-constant grib2 file (Note: not using -r) grib2_sample=$ECCODES_SAMPLES_PATH/gg_sfc_grib2.tmpl ${tools_dir}/grib_set -s packingType=grid_ccsds $grib2_sample $outfile1 diff --git a/tests/grib_cfNames.sh b/tests/grib_cfNames.sh index 369395a00..882d38139 100755 --- a/tests/grib_cfNames.sh +++ b/tests/grib_cfNames.sh @@ -49,9 +49,9 @@ ${tools_dir}/grib_set -s indicatorOfParameter=163,table2Version=151 $sample1 $te grib_check_key_equals $temp cfName depth_of_isosurface_of_sea_water_potential_temperature -${tools_dir}/grib_set -s paramId=151154 $sample1 $temp +${tools_dir}/grib_set -s paramId=181 $sample1 $temp grib_check_key_equals $temp cfName surface_downward_northward_stress -${tools_dir}/grib_set -s paramId=151154 $sample2 $temp +${tools_dir}/grib_set -s stepType=accum,paramId=181 $sample2 $temp grib_check_key_equals $temp cfName surface_downward_northward_stress ${tools_dir}/grib_set -s discipline=192,parameterCategory=151,parameterNumber=153 $sample2 $temp grib_check_key_equals $temp cfName surface_downward_eastward_stress diff --git a/tests/grib_change_scanning.sh b/tests/grib_change_scanning.sh index 25c5e005b..5f1d46596 100755 --- a/tests/grib_change_scanning.sh +++ b/tests/grib_change_scanning.sh @@ -11,6 +11,12 @@ . ./include.ctest.sh label="grib_change_scanning_test" +tempFilt=temp.$label.filt +tempGribA=temp.$label.A.grib +tempGribB=temp.$label.B.grib +tempText=temp.$label.txt +tempRef=temp.$label.ref + editions="1 2" gridTypes="regular_ll rotated_ll" @@ -77,12 +83,6 @@ done # alternativeRowScanning # ----------------------- -tempFilt=temp.$label.filt -tempGribA=temp.$label.A.grib -tempGribB=temp.$label.B.grib -tempText=temp.$label.txt -tempRef=temp.$label.ref - cat > $tempFilt </dev/null cmp $tempGribA $tempGribB + +# Check constraint keys follow (observe) their expressions +# -------------------------------------------------------- +cat > $tempFilt <$tempText + status=$? + set -e + [ $status -ne 0 ] + grep -q "Value is read only" $tempText + rm $tempText + done +done + # Clean up rm -f $tempFilt $tempGribA $tempGribB $tempRef $tempText rm -f ${data_dir}/scan1.grib ${data_dir}/scan.grib diff --git a/tests/grib_check_gaussian_grids.sh b/tests/grib_check_gaussian_grids.sh index 474eaf726..4f16966e4 100755 --- a/tests/grib_check_gaussian_grids.sh +++ b/tests/grib_check_gaussian_grids.sh @@ -28,6 +28,17 @@ for gg in ${samples_dir}/reduced_gg_*tmpl; do done +# Set wrong Nj. Should fail +input=$samples_dir/reduced_gg_pl_32_grib2.tmpl +${tools_dir}/grib_set -s Nj=1 $input $tempGrib +set +e +${tools_dir}/grib_check_gaussian_grid -v $tempGrib 2> $tempText +status=$? +set -e +[ $status -ne 0 ] +grep -q "Nj is 1 but should be 2\*N" $tempText + + # Set wrong N. Should fail input=$samples_dir/reduced_gg_pl_32_grib2.tmpl ${tools_dir}/grib_set -s N=0 $input $tempGrib @@ -38,6 +49,7 @@ set -e [ $status -eq 1 ] grep -q "Error: N should be > 0" $tempText + # Set wrong angle. Should fail input=$samples_dir/reduced_gg_pl_1280_grib2.tmpl ${tools_dir}/grib_set -s longitudeOfLastGridPoint=359929680 $input $tempGrib @@ -49,6 +61,17 @@ set -e grep -q "Error: longitudeOfLastGridPointInDegrees.*but should be" $tempText +# Set wrong lat2. Should fail +input=$samples_dir/reduced_gg_pl_1280_grib2.tmpl +${tools_dir}/grib_set -s latitudeOfLastGridPointInDegrees=9 $input $tempGrib +set +e +${tools_dir}/grib_check_gaussian_grid -v $tempGrib 2> $tempText +status=$? +set -e +[ $status -ne 0 ] +grep -q "First latitude must be = last latitude but opposite in sign" $tempText + + # Set wrong numberOfDataPoints. Should fail input=$samples_dir/reduced_gg_pl_96_grib2.tmpl ${tools_dir}/grib_set -s numberOfDataPoints=44 $input $tempGrib @@ -68,9 +91,17 @@ ${tools_dir}/grib_check_gaussian_grid -f -v $tempGrib 2> $tempText status=$? set -e [ $status -eq 1 ] -cat $tempText grep -q "Error: Sum of pl array 50662 does not match numberOfValues 44" $tempText +# Octahedral +# set +e +# ${tools_dir}/grib_check_gaussian_grid -v $data_dir/msl.octa.glob.grib1 > $tempText 2>&1 +# status=$? +# set -e +# [ $status -ne 0 ] +# grep -q "This is an Octahedral Gaussian grid" $tempText +# grep -q "Error: longitudeOfLastGridPointInDegrees.*should be" $tempText + # Other errors/warnings # ---------------------- diff --git a/tests/grib_check_param_concepts.cc b/tests/grib_check_param_concepts.cc index 077d61e14..99307fe85 100644 --- a/tests/grib_check_param_concepts.cc +++ b/tests/grib_check_param_concepts.cc @@ -52,6 +52,8 @@ static int scale_factor_missing(const char* value) return 0; } +#define STAT_PROC_MAX_VAL 103 // increase this with new Code Table 4.10 entries + /* * key = paramId or shortName * filename = paramId.def or shortName.def @@ -59,6 +61,7 @@ static int scale_factor_missing(const char* value) static int grib_check_param_concepts(const char* key, const char* filename) { int isLocal = 0; + int count = 0; grib_concept_value* concept_value = grib_parse_concept_file(NULL, filename); if (!concept_value) return GRIB_IO_PROBLEM; @@ -67,6 +70,11 @@ static int grib_check_param_concepts(const char* key, const char* filename) isLocal = 1; } while (concept_value) { + count++; + if (strlen(concept_value->name) == 0) { + fprintf(stderr, "%s %s: Empty concept value (count=%d)\n", key, concept_value->name, count); + Assert(0); + } grib_concept_condition* concept_condition = concept_value->conditions; /* Convention: * -1 key not present @@ -106,6 +114,14 @@ static int grib_check_param_concepts(const char* key, const char* filename) key, concept_value->name, filename); return GRIB_INVALID_KEY_VALUE; } + if (strcmp(condition_name, "typeOfStatisticalProcessing") == 0) { + long lValue = atol(condition_value); + if (lValue > STAT_PROC_MAX_VAL || lValue < 0) { + fprintf(stderr, "Bad value for %s in %s=%s in file %s\n", + condition_name, key, concept_value->name, filename); + return GRIB_INVALID_KEY_VALUE; + } + } if (strcmp(condition_name, "typeOfFirstFixedSurface") == 0) { type1Missing = type_of_surface_missing(condition_name, condition_value); } diff --git a/tests/grib_check_param_concepts.sh b/tests/grib_check_param_concepts.sh index 24b2a3e5f..004ca49b8 100755 --- a/tests/grib_check_param_concepts.sh +++ b/tests/grib_check_param_concepts.sh @@ -26,23 +26,21 @@ fi # First check the GRIB2 paramId.def and shortName.def # ---------------------------------------------------- $EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/paramId.def -$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf/paramId.def -$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/uerra/paramId.def -$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/hydro/paramId.def -$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/tigge/paramId.def -$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/s2s/paramId.def -$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/era6/paramId.def -$EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/destine/paramId.def - +datasets="ecmf uerra cerise hydro s2s tigge era6 destine era" +for a_dataset in $datasets; do + $EXEC ${test_dir}/grib_check_param_concepts paramId $ECCODES_DEFINITION_PATH/grib2/localConcepts/$a_dataset/paramId.def +done $EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/shortName.def -$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf/shortName.def -$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/uerra/shortName.def -$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/hydro/shortName.def -$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/tigge/shortName.def -$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/s2s/shortName.def -$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/era6/shortName.def -$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/destine/shortName.def +for a_dataset in $datasets; do + $EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/$a_dataset/shortName.def +done + +# Check WMO name.def etc +$EXEC ${test_dir}/grib_check_param_concepts name $ECCODES_DEFINITION_PATH/grib2/name.def +$EXEC ${test_dir}/grib_check_param_concepts units $ECCODES_DEFINITION_PATH/grib2/units.def +$EXEC ${test_dir}/grib_check_param_concepts units $ECCODES_DEFINITION_PATH/grib2/cfVarName.def + # Check the group: name.def paramId.def shortName.def units.def cfVarName.def # ---------------------------------------------------------------------------- @@ -64,19 +62,20 @@ defs_dirs=" $ECCODES_DEFINITION_PATH/grib1/localConcepts/ecmf $ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf - $ECCODES_DEFINITION_PATH/grib1/localConcepts/ammc - $ECCODES_DEFINITION_PATH/grib1/localConcepts/eidb $ECCODES_DEFINITION_PATH/grib1/localConcepts/ekmi $ECCODES_DEFINITION_PATH/grib1/localConcepts/enmi - $ECCODES_DEFINITION_PATH/grib1/localConcepts/eswi $ECCODES_DEFINITION_PATH/grib1/localConcepts/lfpw $ECCODES_DEFINITION_PATH/grib1/localConcepts/lowm $ECCODES_DEFINITION_PATH/grib1/localConcepts/rjtd $ECCODES_DEFINITION_PATH/grib2/localConcepts/uerra $ECCODES_DEFINITION_PATH/grib2/localConcepts/hydro + $ECCODES_DEFINITION_PATH/grib2/localConcepts/cerise $ECCODES_DEFINITION_PATH/grib2/localConcepts/tigge $ECCODES_DEFINITION_PATH/grib2/localConcepts/s2s + $ECCODES_DEFINITION_PATH/grib2/localConcepts/era6 + $ECCODES_DEFINITION_PATH/grib2/localConcepts/era + $ECCODES_DEFINITION_PATH/grib2/localConcepts/destine $ECCODES_DEFINITION_PATH/grib2/localConcepts/egrr $ECCODES_DEFINITION_PATH/grib2/localConcepts/ekmi diff --git a/tests/grib_clone_headers_only.cc b/tests/grib_clone_headers_only.cc index f59b204ed..f96048a15 100644 --- a/tests/grib_clone_headers_only.cc +++ b/tests/grib_clone_headers_only.cc @@ -12,11 +12,6 @@ #undef NDEBUG #include -static void usage(const char* app) -{ - fprintf(stderr, "Usage is: %s input_file ouput_file\n", app); -} - int main(int argc, char* argv[]) { FILE* in = NULL; @@ -26,13 +21,13 @@ int main(int argc, char* argv[]) int err = 0; long totalLength_src = 0, totalLength_dst = 0; - long edition = 0, isGridded = 0, bitmapPresent = 0; + long edition = 0, isGridded_src = 0, bitmapPresent = 0; long isConstant_src = 0, isConstant_dst = 0; long dataSectionLength_src = 0, dataSectionLength_dst = 0; size_t messageLength_src = 0, messageLength_dst = 0; if (argc != 3) { - usage(argv[0]); + // Usage: prog input_file ouput_file return 1; } @@ -46,8 +41,8 @@ int main(int argc, char* argv[]) assert(clone_handle); codes_get_long(source_handle, "isConstant", &isConstant_src); - codes_get_long(source_handle, "isGridded", &isGridded); - if (isGridded && !isConstant_src) { + codes_get_long(source_handle, "isGridded", &isGridded_src); + if (isGridded_src && !isConstant_src) { CODES_CHECK(codes_get_message(source_handle, &buffer, &messageLength_src), 0); CODES_CHECK(codes_get_message(clone_handle, &buffer, &messageLength_dst), 0); @@ -73,7 +68,7 @@ int main(int argc, char* argv[]) assert(isConstant_dst == 1); } - /* write out the cloned buffer */ + // write out the cloned buffer if (fwrite(buffer, 1, messageLength_dst, out) != messageLength_dst) { perror(argv[1]); return 1; diff --git a/tests/grib_data_quality_checks.sh b/tests/grib_data_quality_checks.sh index 2b8ed80f2..6462a8662 100755 --- a/tests/grib_data_quality_checks.sh +++ b/tests/grib_data_quality_checks.sh @@ -28,6 +28,13 @@ sample_ccsds=$ECCODES_SAMPLES_PATH/ccsds_grib2.tmpl unset ECCODES_GRIB_DATA_QUALITY_CHECKS unset ECCODES_EXTRA_DEFINITION_PATH +echo "Data quality checks enabled. Packing samples should work" +# ------------------------------------------------------------- +export ECCODES_GRIB_DATA_QUALITY_CHECKS=1 +${tools_dir}/grib_copy -r $sample_g1 /dev/null +${tools_dir}/grib_copy -r $sample_g2 /dev/null +unset ECCODES_GRIB_DATA_QUALITY_CHECKS + # These input files are 2m temperature with min=221.76 and max=311.619 input1=${data_dir}/reduced_gaussian_surface.grib1 input2=${data_dir}/reduced_gaussian_surface.grib2 @@ -51,6 +58,7 @@ set -e grep -q 'more than the allowable limit' $tempErr unset ECCODES_DEBUG + echo "Data quality checks enabled but only as a warning. Repacking should pass..." # -------------------------------------------------------------------------------- export ECCODES_GRIB_DATA_QUALITY_CHECKS=2 @@ -80,15 +88,10 @@ grep -q 'allowable limit' $tempErr echo "Test limits which are doubles..." # ------------------------------------- -pid=151131 # has limits -3.5 and +3.5 -${tools_dir}/grib_set -s paramId=$pid $input1 $tempGrib1 +pid=262140 # has limits -3.5 and +3.5 ${tools_dir}/grib_set -s paramId=$pid $input2 $tempGrib2 -minval1=`${tools_dir}/grib_get -p param_value_min:d $tempGrib1` -maxval1=`${tools_dir}/grib_get -p param_value_max:d $tempGrib1` minval2=`${tools_dir}/grib_get -p param_value_min:d $tempGrib2` maxval2=`${tools_dir}/grib_get -p param_value_max:d $tempGrib2` -[ "$minval1" = "-3.5" ] -[ "$maxval1" = "3.5" ] [ "$minval2" = "-3.5" ] [ "$maxval2" = "3.5" ] @@ -96,34 +99,24 @@ maxval2=`${tools_dir}/grib_get -p param_value_max:d $tempGrib2` grib_check_key_equals $tempGrib2 'param_value_min:s,param_value_max:s' '-3.5 3.5' set +e -${tools_dir}/grib_set -s scaleValuesBy=1.1 $tempGrib1 $tempOut 2>$tempErr -stat1=$? ${tools_dir}/grib_set -s scaleValuesBy=1.1 $tempGrib2 $tempOut 2>$tempErr stat2=$? set -e -[ $stat1 -ne 0 ] [ $stat2 -ne 0 ] # Should succeed. Change paramId first and then scale all values down -${tools_dir}/grib_set -s paramId=$pid,scaleValuesBy=0.01 $input1 $tempOut ${tools_dir}/grib_set -s paramId=$pid,scaleValuesBy=0.01 $input2 $tempOut echo "Test close to the limit..." # --------------------------------- -${tools_dir}/grib_set -s paramId=$pid $sample_g2 $tempGrib2 +# The GRIB2 sample has max values of 273. We need to use 1 for this test +${tools_dir}/grib_set -s paramId=$pid,values=1 $sample_g2 $tempGrib2 ${tools_dir}/grib_set -s scaleValuesBy=3 $tempGrib2 $tempOut # OK set +e ${tools_dir}/grib_set -s scaleValuesBy=3.6 $tempGrib2 $tempOut set -e [ $status -ne 0 ] -${tools_dir}/grib_set -s edition=1 $tempGrib2 $tempGrib1 -${tools_dir}/grib_set -s scaleValuesBy=-3 $tempGrib1 $tempOut # OK -set +e -${tools_dir}/grib_set -s scaleValuesBy=-3.55 $tempGrib1 $tempOut -set -e -[ $status -ne 0 ] - echo "Test limits with steps..." # ----------------------------- @@ -189,11 +182,13 @@ cat > $tempDir/param_limits.def < 4 -${tools_dir}/grib_set -s paramId=260509,step=12,scaleValuesBy=1000 $sample_g2 $tempGrib2 +# The GRIB2 sample has max values of 273. We need to use 1 for this test +${tools_dir}/grib_set -s paramId=260509,step=12,values=1,scaleValuesBy=1000 $sample_g2 $tempGrib2 # Step of 0 doesn't satisfy the condition so will use 400 +# The GRIB2 sample has max values of 273. We need to use 1 for this test set +e -${tools_dir}/grib_set -s paramId=260509,scaleValuesBy=1000 $sample_g2 $tempGrib2 +${tools_dir}/grib_set -s paramId=260509,values=1,scaleValuesBy=1000 $sample_g2 $tempGrib2 status=$? set -e [ $status -ne 0 ] diff --git a/tests/grib_decimalPrecision.sh b/tests/grib_decimalPrecision.sh index 66a4c6253..afe13ad74 100755 --- a/tests/grib_decimalPrecision.sh +++ b/tests/grib_decimalPrecision.sh @@ -10,6 +10,9 @@ . ./include.ctest.sh +label="grib_decimalPrecision_test" + +temp=temp.$label.grib REDIRECT=/dev/null files="regular_latlon_surface.grib2 \ @@ -29,7 +32,6 @@ for file in $files; do done # ECC-458: spectral_complex packing -temp=temp.grib_decimalPrecision.grib infile=${data_dir}/spectral_complex.grib1 # Catch errors re negative values export ECCODES_FAIL_IF_LOG_MESSAGE=1 @@ -42,7 +44,7 @@ sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl ${tools_dir}/grib_set -s decimalScaleFactor=3 $sample1 $temp grib_check_key_equals $temp min,max,const,decimalScaleFactor,referenceValue '47485.4 47485.4 1 3 47485.4' ${tools_dir}/grib_set -s decimalScaleFactor=3 $sample2 $temp -grib_check_key_equals $temp min,max,const,decimalScaleFactor,referenceValue '1 1 1 3 1' - +grib_check_key_equals $temp min,max,const,decimalScaleFactor,referenceValue '273 273 1 3 273' +# Clean up rm -f $temp diff --git a/tests/grib_dump.sh b/tests/grib_dump.sh index c2844ec0d..c413f93f1 100755 --- a/tests/grib_dump.sh +++ b/tests/grib_dump.sh @@ -111,6 +111,16 @@ file=$data_dir/sample.grib2 ECCODES_DEBUG=1 ${tools_dir}/grib_dump $file > $temp 2>&1 +# Repeated key numberOfSection +file=$data_dir/sample.grib2 +${tools_dir}/grib_dump -O $file > $temp +grep -q "numberOfSection = 1" $temp +grep -q "numberOfSection = 3" $temp +grep -q "numberOfSection = 4" $temp +grep -q "numberOfSection = 5" $temp +grep -q "numberOfSection = 7" $temp + + # Dump long array # ---------------- input=$data_dir/lfpw.grib1 diff --git a/tests/grib_ecc-1212.sh b/tests/grib_ecc-1212.sh index e1f32e596..7ff7c2ead 100755 --- a/tests/grib_ecc-1212.sh +++ b/tests/grib_ecc-1212.sh @@ -112,6 +112,8 @@ ${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample_grib2 grib_check_key_equals $tempGrib selectedFcIndex,step '1 4' grib_check_key_equals $tempGrib mars.date,mars.time '20220607 300' +${tools_dir}/grib_dump -Dat $tempGrib > $tempOut + for pdtn in 88 92 93 94 95 96 97 98; do ${tools_dir}/grib_set -s \ tablesVersion=30,productDefinitionTemplateNumber=$pdtn,numberOfForecastsUsedInLocalTime=1 \ diff --git a/tests/grib_ecc-1271.sh b/tests/grib_ecc-1271.sh index 04a25d828..8e9f7ed13 100755 --- a/tests/grib_ecc-1271.sh +++ b/tests/grib_ecc-1271.sh @@ -23,6 +23,6 @@ $sample_grib2 $temp grib_check_key_equals $temp Ni,Nj "16 31" grib_check_key_equals $temp centreLatitudeInDegrees,centreLongitudeInDegrees "0 30" -grib_check_key_equals $temp minimum,maximum "1 1" +grib_check_key_equals $temp minimum,maximum "273 273" rm -f $temp diff --git a/tests/grib_ecc-1467.cc b/tests/grib_ecc-1467.cc index 20a2b7268..5c5e8e53b 100644 --- a/tests/grib_ecc-1467.cc +++ b/tests/grib_ecc-1467.cc @@ -8,6 +8,9 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +// +// ECC-1467: Support data values array decoded as "floats" (single-precision) +// #include #include "eccodes.h" #include "grib_api_internal.h" @@ -26,21 +29,14 @@ int main(int argc, char** argv) double dmin, dmax, dval; float fval; - FILE* in = NULL; - const char* filename = 0; - codes_handle* h = NULL; - - if (argc != 2) { - fprintf(stderr, "usage: %s file\n", argv[0]); - return 1; - } - filename = argv[1]; + Assert(argc == 2); + const char* filename = argv[1]; printf("Opening %s\n", filename); - in = fopen(filename, "rb"); + FILE* in = fopen(filename, "rb"); Assert(in); - h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); + codes_handle* h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); Assert(h); CODES_CHECK(codes_get_float(h, "referenceValue", &fval), 0); @@ -67,8 +63,7 @@ int main(int argc, char** argv) fval = fvalues[i]; if (!((dmin <= fval) && (fval <= dmax))) { - fprintf(stderr, "Error:\n"); - fprintf(stderr, "dvalue: %f, fvalue: %f\n", dvalues[i], fvalues[i]); + fprintf(stderr, "Error: dvalue: %f, fvalue: %f\n", dvalues[i], fvalues[i]); fprintf(stderr, "\tmin < fvalue < max = %.20e < %.20e < %.20e FAILED\n", dmin, fvalues[i], dmax); fprintf(stderr, "\tfvalue - min = %.20e (%s)\n", diff --git a/tests/grib_ecc-1467.sh b/tests/grib_ecc-1467.sh index fb5d0bd1c..abb9aa5f3 100755 --- a/tests/grib_ecc-1467.sh +++ b/tests/grib_ecc-1467.sh @@ -8,6 +8,8 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # +# ECC-1467: Support data values array decoded as "floats" (single-precision) + . ./include.ctest.sh # Constant fields diff --git a/tests/grib_ecc-1691.sh b/tests/grib_ecc-1691.sh index 97c38108d..d64bae087 100755 --- a/tests/grib_ecc-1691.sh +++ b/tests/grib_ecc-1691.sh @@ -64,11 +64,12 @@ ${tools_dir}/grib_set -s numberOfDataPoints=12582912,gridDefinitionTemplateNumbe grib_check_key_equals $temp_grib_a "gridSpecification" "H1024" -# Now check streams. +# Now check streams for use in climate-dt. # Setting stream clte and type fc should set mars.date and mars.time to dataDate and dataTime, # and mars.step should be unaliased +# We must also set dataset=climate-dt, since in other datasets mars.step is set to stepRange -${tools_dir}/grib_set -s stream=clte,type=fc $destine_sample $temp_grib_a +${tools_dir}/grib_set -s dataset=climate-dt,stream=clte,type=fc $destine_sample $temp_grib_a result1=$( ${tools_dir}/grib_get -p mars.date,mars.time $temp_grib_a ) result2=$( ${tools_dir}/grib_get -p dataDate,dataTime $temp_grib_a ) @@ -79,8 +80,9 @@ ${tools_dir}/grib_ls -jm $temp_grib_a # Setting stream clmn and type fc should set mars.year and mars.month to year and month, # and mars.date, mars.time, mars.step should be unaliased +# We must also set dataset=climate-dt, since in other datasets mars.step is set to stepRange -${tools_dir}/grib_set -s stream=clmn,type=fc $destine_sample $temp_grib_a +${tools_dir}/grib_set -s dataset=climate-dt,stream=clmn,type=fc $destine_sample $temp_grib_a result1=$( ${tools_dir}/grib_get -p mars.year,mars.month $temp_grib_a ) result2=$( ${tools_dir}/grib_get -p year,month $temp_grib_a ) @@ -91,5 +93,9 @@ ${tools_dir}/grib_ls -jm $temp_grib_a [ $( ${tools_dir}/grib_get -f -p mars.time $temp_grib_a ) = "not_found" ] [ $( ${tools_dir}/grib_get -f -p mars.step $temp_grib_a ) = "not_found" ] +# ECC-1801 +${tools_dir}/grib_set -s productionStatusOfProcessedData=12 $sample_grib2 $temp_grib_a +${tools_dir}/grib_compare -b productionStatusOfProcessedData $sample_grib2 $temp_grib_a + # Clean up rm -f $temp_grib_a $temp_grib_b $destine_sample diff --git a/tests/grib_ecc-1764.cc b/tests/grib_ecc-1764.cc new file mode 100644 index 000000000..a2d884a18 --- /dev/null +++ b/tests/grib_ecc-1764.cc @@ -0,0 +1,44 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ +#include "grib_api.h" +#undef NDEBUG +#include "assert.h" + +int main(int argc, char* argv[]) +{ + int ret = GRIB_SUCCESS; + + if (argc != 2) return 1; + + const char* infile = argv[1]; + grib_index* index = grib_index_new(0, "shortName,level", &ret); + assert(ret == GRIB_SUCCESS); + + ret = grib_index_add_file(index, infile); + assert(ret == GRIB_SUCCESS); + + printf("Select nonexistent entries...\n"); + grib_index_select_string(index, "shortName", "frost"); + grib_index_select_long(index, "level", 666); + + grib_handle* h = grib_handle_new_from_index(index, &ret); + assert(!h); + assert(ret == GRIB_END_OF_INDEX); + + // Call it again. Should not crash + h = grib_handle_new_from_index(index, &ret); + assert(!h); + assert(ret == GRIB_END_OF_INDEX); + + grib_index_delete(index); + grib_context_delete(grib_context_get_default()); + + return 0; +} diff --git a/tests/grib_ecc-1764.sh b/tests/grib_ecc-1764.sh new file mode 100755 index 000000000..81891ec74 --- /dev/null +++ b/tests/grib_ecc-1764.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_ecc-1764_test" +temp=temp.$label.txt + +infile=${data_dir}/tigge_cf_ecmwf.grib2 +$EXEC ${test_dir}/grib_ecc-1764 $infile # > $temp + +# Clean up +rm -f $temp diff --git a/tests/grib_ecc-1766.sh b/tests/grib_ecc-1766.sh new file mode 100755 index 000000000..79e273b1d --- /dev/null +++ b/tests/grib_ecc-1766.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +REDIRECT=/dev/null + +# ECC-1766: EERIE project metadata support + +label="grib_ecc-1766_test" +temp_grib=temp.$label.grib +eerie_sample=temp.$label.eerie.grib +sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +tablesVersionLatest=$( ${tools_dir}/grib_get -p tablesVersionLatest $sample_grib2 ) + +# Setup GRIB message with MARS keys +# Set latest tables version and add local section with MARS labeling +${tools_dir}/grib_set -s tablesVersion=$tablesVersionLatest,setLocalDefinition=1 $sample_grib2 $temp_grib + +# Then change to EERIE project GRIB message --> grib2LocalSectionNumber=43 +${tools_dir}/grib_set -s grib2LocalSectionNumber=43,class=ed $temp_grib $eerie_sample + +# Check EERIE related keys are present and correct +grib_check_key_exists $eerie_sample activity,experiment,realization +grib_check_key_equals $eerie_sample "activity,experiment,realization" "0 0 255" + +# Check domain key is unaliased +[ $( ${tools_dir}/grib_get -f -p mars.domain $eerie_sample ) = "not_found" ] + +# Check an example where a few additional things are set +${tools_dir}/grib_set -s activity=1,experiment=1,realization=1 $eerie_sample $temp_grib + +grib_check_key_equals $temp_grib "activity,experiment,realization" "1 1 1" +grib_check_key_equals $temp_grib "activity:s,experiment:s" "CMIP6 hist" + +# Clean up +rm -f $temp_grib $eerie_sample diff --git a/tests/grib_ecc-1792.sh b/tests/grib_ecc-1792.sh new file mode 100755 index 000000000..960da284d --- /dev/null +++ b/tests/grib_ecc-1792.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +REDIRECT=/dev/null + +label="grib_ecc-1792_test" +tempGrib=temp.$label.grib +tempFilt=temp.$label.filt +tempLog=temp.$label.log +tempRef=temp.$label.ref + +sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +# Create a message with its Data Section out-of-sync with its Grid +${tools_dir}/grib_set -s numberOfValues=2 $sample_grib2 $tempGrib +grib_check_key_equals $tempGrib numberOfDataPoints 496 + +# grib_get_data should fail +set +e +${tools_dir}/grib_get_data $tempGrib > $tempLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep "Grid description is wrong" $tempLog + +# Just getting lats and lons; no need for Data Section to be in-sync +cat >$tempFilt<$tempFilt< $tempLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep "Grid description is wrong" $tempLog + + +# Clean up +rm -f $tempGrib $tempFilt $tempLog $tempRef diff --git a/tests/grib_ecc-1806.sh b/tests/grib_ecc-1806.sh new file mode 100755 index 000000000..e08f667a6 --- /dev/null +++ b/tests/grib_ecc-1806.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +REDIRECT=/dev/null + +label="grib_ecc-1806_test" +tempGrib1=temp.$label.1.grib +tempGrib2=temp.$label.2.grib +tempLog=temp.$label.log + +sampleGrib1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +sampleGrib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +test_conversion() +{ + param1=$1 # old paramId in GRIB1 + param2=$2 # new paramId in GRIB2 + short=$3 # new shortName + + ${tools_dir}/grib_set -s paramId=$param1 $sampleGrib1 $tempGrib1 + ${tools_dir}/grib_set -s edition=2 $tempGrib1 $tempGrib2 + grib_check_key_equals $tempGrib2 paramId,shortName "$param2 $short" + + # Check the old paramId has been removed from GRIB2 + set +e + ${tools_dir}/grib_set -s paramId=$param1 $sampleGrib2 $tempGrib2 >$tempLog 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "no match for paramId" $tempLog +} + +test_conversion 174098 262000 sithick +test_conversion 151163 262104 t20d +test_conversion 151145 262124 zos +test_conversion 130232 235135 avg_w +test_conversion 172146 235033 msshf +test_conversion 172147 235034 mslhf +test_conversion 55 228004 mean2t +test_conversion 56 235168 avg_2d +test_conversion 172169 235035 msdwswrf +test_conversion 172175 235036 msdwlwrf +test_conversion 172176 235037 msnswrf +test_conversion 172177 235038 msnlwrf +test_conversion 172178 235039 mtnswrf +test_conversion 172179 235040 mtnlwrf +test_conversion 151175 262118 sc300m + +# Clean up +rm -f $tempGrib1 $tempGrib2 $tempLog diff --git a/tests/grib_ecc-386.cc b/tests/grib_ecc-386.cc index d4e238c4f..10f2adcdb 100644 --- a/tests/grib_ecc-386.cc +++ b/tests/grib_ecc-386.cc @@ -9,18 +9,11 @@ */ /* - * Description: Reads a GRIB message from file, measures read time. - * + * Description: Reads a GRIB message from file, measures time taken */ #include #include "grib_api_internal.h" -static void usage(const char* prog) -{ - printf("usage: %s filename\n", prog); - exit(1); -} - int main(int argc, char** argv) { grib_timer* tes = grib_get_timer(0, "decoding", 0, 0); @@ -33,21 +26,15 @@ int main(int argc, char** argv) const double duration_max = 3.6; /* seconds */ const int num_repetitions = 100; - if (argc < 2) usage(argv[0]); + if (argc < 2) return 1; in = fopen(argv[1], "rb"); - if (!in) { - printf("ERROR: unable to open file %s\n", argv[1]); - return 1; - } + Assert(in); /* create new handle */ err = 0; h = grib_handle_new_from_file(0, in, &err); - if (h == NULL) { - printf("Error: unable to create handle from file.\n"); - return 1; - } + Assert(h); /* get the size of the values array*/ GRIB_CHECK(grib_get_size(h, "values", &values_len), 0); @@ -72,9 +59,3 @@ int main(int argc, char** argv) fclose(in); return 0; } - -// int main(int argc, char** argv) -// { -// return 0; -// } -// #endif diff --git a/tests/grib_fieldset.cc b/tests/grib_fieldset.cc index a6eb38ce7..d1431b021 100644 --- a/tests/grib_fieldset.cc +++ b/tests/grib_fieldset.cc @@ -13,12 +13,6 @@ #include "grib_api.h" -static void usage(const char* prog) -{ - fprintf(stderr, "Usage: %s order_by grib_file grib_file ...\n", prog); - exit(1); -} - int main(int argc, char** argv) { int err = 0; @@ -34,7 +28,7 @@ int main(int argc, char** argv) size_t lenDate = 10, lenParam = 20, lenLevel = 50; char* order_by = NULL; - if (argc != 3) usage(argv[0]); + if (argc != 3) return 1; //Usage: prog order_by grib_file grib_file ... nkeys = sizeof(keys) / sizeof(*keys); order_by = argv[1]; diff --git a/tests/grib_filter.sh b/tests/grib_filter.sh index c932cf026..42e4eccdf 100755 --- a/tests/grib_filter.sh +++ b/tests/grib_filter.sh @@ -36,24 +36,6 @@ rm -f ${data_dir}/split/* rmdir ${data_dir}/split rm -f ${data_dir}/f.rules -echo "Test with nonexistent keys. Note spelling of centre!" -# --------------------------------------------------------- -cat >${data_dir}/nonexkey.rules < $REDIRECT > $REDIRECT -if [ $? -eq 0 ]; then - echo "grib_filter should have failed if key not found" >&2 - exit 1 -fi -set -e -# Now repeat with -f option (do not exit on error) -${tools_dir}/grib_filter -f ${data_dir}/nonexkey.rules ${data_dir}/tigge_pf_ecmwf.grib2 2> $REDIRECT > $REDIRECT - -rm -f ${data_dir}/nonexkey.rules - echo "Test GRIB-308: format specifier for integer keys" # ---------------------------------------------------- cat > ${data_dir}/formatint.rules <$tempFilt < $tempOut grep -q "defined and equal to -42" $tempOut -echo "Test IEEE float overflow" -# ----------------------------------------- -input="${samp_dir}/GRIB2.tmpl" -cat >$tempFilt < $tempOut -status=$? -set -e -[ $status -ne 0 ] -grep -q "ECCODES ERROR.*Number is too large" $tempOut - - echo "Padded count for filenames" # ----------------------------------------- input=${data_dir}/tigge_af_ecmwf.grib2 @@ -353,6 +324,20 @@ EOF ${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut grep -q "No args: false" $tempOut +# Bit on off +cat >$tempFilt < $tempOut +cat $tempOut +grep -q "xx1=1" $tempOut +grep -q "xx2=0" $tempOut +grep -q "yy1=0" $tempOut +grep -q "yy2=1" $tempOut + # Use of dummy expression (=true) cat >$tempFilt < $tempOut -cat >$tempFilt < $tempOut -status=$? -set -e -[ $status -ne 0 ] -grep "Assertion failure" $tempOut - # Use of the "length" expression cat >$tempFilt <$tempFilt < $tempOut + +# Logical OR with doubles +cat >$tempFilt < 45.01 || referenceValue < 1.1) { print "yes"; } +EOF +${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl #> $tempOut + + # Decode an integer key as string cat >$tempFilt < $tempOut 2>&1 -status=$? -set -e -[ $status -ne 0 ] -grep -q "Invalid argument" $tempOut - # GTS header # --------------- @@ -459,27 +435,6 @@ set -e [ $status -ne 0 ] -# Bad write -set +e -echo 'write "/";' | ${tools_dir}/grib_filter - $input > $tempOut 2>&1 -status=$? -set -e -[ $status -ne 0 ] -grep -q "Unable to open file" $tempOut - -# Signed bits -# ----------- -cat >$tempFilt < $tempOut 2>&1 -status=$? -set -e -[ $status -ne 0 ] - - # Setting step # ------------- input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl @@ -491,15 +446,14 @@ echo 'set endStep = 12; write;' | ${tools_dir}/grib_filter -o $tempGrib - $input grib_check_key_equals $tempGrib step 12 grib_check_key_equals $tempGrib forecastTime 12 - -# Bad filter -# ---------------- -set +e -${tools_dir}/grib_filter a_non_existent_filter_file $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut 2>&1 -status=$? -set -e -[ $status -ne 0 ] -grep -q "Cannot include file" $tempOut +# Functions: grib_op_ne_d +# ------------------------ +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +cat >$tempFilt <${data_dir}/nonexkey.rules < $REDIRECT > $REDIRECT +if [ $? -eq 0 ]; then + echo "grib_filter should have failed if key not found" >&2 + exit 1 +fi +set -e + +# Now repeat with -f option (do not exit on error) +${tools_dir}/grib_filter -f ${data_dir}/nonexkey.rules ${data_dir}/tigge_pf_ecmwf.grib2 2> $REDIRECT > $REDIRECT + +rm -f ${data_dir}/nonexkey.rules + +echo "Test IEEE float overflow" +# ----------------------------------------- +input="${samp_dir}/GRIB2.tmpl" +cat >$tempFilt < $tempOut +status=$? +set -e +[ $status -ne 0 ] +grep -q "ECCODES ERROR.*Number is too large" $tempOut + +# Assert statement +# ----------------- +cat >$tempFilt < $tempOut +status=$? +set -e +[ $status -ne 0 ] +grep "Assertion failure" $tempOut + + +# Bad write +# --------- +set +e +echo 'write(-10);' | ${tools_dir}/grib_filter -o $tempGrib - $sample_grib2 > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid argument" $tempOut + +# Bad write +# ---------- +set +e +echo 'write "/";' | ${tools_dir}/grib_filter - $input > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Unable to open file" $tempOut + +# Signed bits +# ----------- +cat >$tempFilt < $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] + + +# Non existent filter +# -------------------- +set +e +${tools_dir}/grib_filter a_non_existent_filter_file $sample_grib2 > $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Cannot include file" $tempOut + +# Functor not implemented +# ------------------------- +cat >$tempFilt < $tempOut 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "ECCODES ERROR.*failed for 'unicorn'" $tempOut +grep -q "Function not yet implemented" $tempOut + + +# Clean up +rm -f $tempGrib $tempFilt $tempOut $tempRef diff --git a/tests/grib_get_fail.sh b/tests/grib_get_fail.sh index d7d0d5b1b..7f1c967e4 100755 --- a/tests/grib_get_fail.sh +++ b/tests/grib_get_fail.sh @@ -35,6 +35,13 @@ grep -q "Nh (Key/value not found)" $tempText # Nearest # --------- +set +e +${tools_dir}/grib_get -l abc $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Wrong latitude value" $tempText + set +e ${tools_dir}/grib_get -s Nj=MISSING -l 0,0,1 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1 status=$? @@ -51,7 +58,7 @@ grep -q "Key Nj cannot be 0" $tempText set +e -${tools_dir}/grib_get -l 0,0,5 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1 +${tools_dir}/grib_get -l 0,0,5 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib2.tmpl > $tempText 2>&1 status=$? set -e [ $status -ne 0 ] @@ -81,5 +88,16 @@ grep -q "unreadable message" $tempText rm -f $outfile +# ---------------------- +# Wrong message type +# ---------------------- +set +e +${tools_dir}/grib_get -p edition $ECCODES_SAMPLES_PATH/BUFR3.tmpl > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Input file seems to be BUFR" $tempText + + # Clean up rm -f $tempText diff --git a/tests/grib_grid_healpix.sh b/tests/grib_grid_healpix.sh index 9b3560693..7ff56382c 100755 --- a/tests/grib_grid_healpix.sh +++ b/tests/grib_grid_healpix.sh @@ -19,7 +19,8 @@ input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl latest=`${tools_dir}/grib_get -p tablesVersionLatest $input` -# Create a filter +# Check basic keys and grid template +# ----------------------------------- cat > $tempFilt < $tempLog +grep -q "orderingConvention.*ring" $tempLog -# Geoiterator -# ------------- +# Geoiterator ring-ordering +# -------------------------- rm -f $tempGrib cat > $tempFilt < $tempFilt < $tempLog + +# Nested: N must be a power of 2 +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +${tools_dir}/grib_set -s gridType=healpix,Nside=3,orderingConvention=nested,numberOfDataPoints=108,numberOfValues=108 $input $tempGrib +set +e +${tools_dir}/grib_get_data $tempGrib > $tempLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Nside must be a power of 2" $tempLog + + +# Nested N=1 +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +${tools_dir}/grib_set -s gridType=healpix,Nside=1,orderingConvention=nested,numberOfDataPoints=12,numberOfValues=12 $input $tempGrib +${tools_dir}/grib_get_data $tempGrib > $tempLog + # Invalid cases -# -------------- +# ------------------ +# Bad ordering +${tools_dir}/grib_set -s gridType=healpix,Nside=1,ordering=6 $input $tempGrib +set +e +${tools_dir}/grib_get_data $tempGrib > $tempLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Only orderingConvention.*are supported" $tempLog + +# N = 0 set +e ${tools_dir}/grib_get_data -sN=0 $tempGrib > $tempLog 2>&1 status=$? @@ -80,13 +130,6 @@ set -e [ $status -ne 0 ] grep -q "Nside must be greater than zero" $tempLog -set +e -${tools_dir}/grib_get_data -s orderingConvention=nested $tempGrib > $tempLog 2>&1 -status=$? -set -e -[ $status -ne 0 ] -grep -q "Only ring ordering is supported" $tempLog - # Clean up rm -f $tempFilt $tempGrib $tempLog diff --git a/tests/grib_grid_lamb_az_eq_area.sh b/tests/grib_grid_lamb_az_eq_area.sh index f3ed52588..a580d0498 100755 --- a/tests/grib_grid_lamb_az_eq_area.sh +++ b/tests/grib_grid_lamb_az_eq_area.sh @@ -11,21 +11,21 @@ label="grib_grid_lamb_az_eq_area_test" -GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2 -REF_FILE=grib_lamb_az_eq_area.ref +input=${data_dir}/regular_gaussian_pressure_level_constant.grib2 +tempRef=grib_lamb_az_eq_area.ref # Temporary files created for this test -FILTER_FILE=temp.$label.filter -GRIB_OUTFILE=temp.$label.grib2 -DATA_OUTFILE=temp.$label.txt -rm -f $FILTER_FILE $GRIB_OUTFILE $DATA_OUTFILE +tempFilt=temp.$label.filter +tempGrib=temp.$label.grib2 +tempOut=temp.$label.txt +rm -f $tempFilt $tempGrib $tempOut # -------------------- # Spherical Earth # -------------------- # Create a filter -cat > $FILTER_FILE< $tempFilt< $DATA_OUTFILE +${tools_dir}/grib_get_data $tempGrib > $tempOut # Compare output with reference. If the diff fails, script will immediately exit with status 1 -diff $REF_FILE $DATA_OUTFILE +diff $tempRef $tempOut -grib_check_key_equals $GRIB_OUTFILE standardParallelInDegrees,centralLongitudeInDegrees '48 9' -grib_check_key_equals $GRIB_OUTFILE xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000' +grib_check_key_equals $tempGrib standardParallelInDegrees,centralLongitudeInDegrees '48 9' +grib_check_key_equals $tempGrib xDirectionGridLengthInMetres,yDirectionGridLengthInMetres '5000 5000' # Nearest -${tools_dir}/grib_ls -l 67,-33,1 $GRIB_OUTFILE +${tools_dir}/grib_ls -l 67,-33,1 $tempGrib # jPointsAreConsecutive tempOutA=temp.$label.A.txt tempOutB=temp.$label.B.txt -${tools_dir}/grib_get_data -s jPointsAreConsecutive=0 $GRIB_OUTFILE > $tempOutA -${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $GRIB_OUTFILE > $tempOutB +${tools_dir}/grib_get_data -s jPointsAreConsecutive=0 $tempGrib > $tempOutA +${tools_dir}/grib_get_data -s jPointsAreConsecutive=1 $tempGrib > $tempOutB # Results should be different. set +e diff $tempOutA $tempOutB > /dev/null @@ -80,7 +80,7 @@ rm -f $tempOutA $tempOutB # Oblate spheroid # -------------------- -cat > $FILTER_FILE< $tempFilt< $DATA_OUTFILE +${tools_dir}/grib_get_data $tempGrib > $tempOut + +# ECC-1818 +# --------- +cat > $tempFilt< $tempOut # Clean up -rm -f $FILTER_FILE $DATA_OUTFILE -rm -f $GRIB_OUTFILE +rm -f $tempFilt $tempOut $tempGrib diff --git a/tests/grib_histogram.sh b/tests/grib_histogram.sh new file mode 100755 index 000000000..9653a9500 --- /dev/null +++ b/tests/grib_histogram.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_histogram_test" +REDIRECT=/dev/null +tempOut=temp.$label.txt + +${tools_dir}/grib_histogram $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut +${tools_dir}/grib_histogram $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut + +${tools_dir}/grib_histogram -p step,shortName $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut + +# Something with a bitmap +input=$data_dir/reduced_latlon_surface.grib2 +grib_check_key_equals $input numberOfMissing 98701 +${tools_dir}/grib_histogram $input > $tempOut + +# Skip +input=$data_dir/tigge_cf_ecmwf.grib2 +${tools_dir}/grib_histogram -w level=925,shortName=gh $input > $tempOut + + +# Clean up +rm -f $tempOut diff --git a/tests/grib_indexing.sh b/tests/grib_indexing.sh index 79026c9a3..1e3001f16 100755 --- a/tests/grib_indexing.sh +++ b/tests/grib_indexing.sh @@ -147,8 +147,8 @@ mkdir $temp_dir_B cp ${data_dir}/tigge/tigge_rjtd_pl_*grib $temp_dir_A cp ${data_dir}/tigge/tigge_rjtd_sfc_*grib $temp_dir_B -${tools_dir}/grib_index_build -o $tempIndex1 $temp_dir_A -${tools_dir}/grib_dump $tempIndex1 +${tools_dir}/grib_index_build -o $tempIndex1 $temp_dir_A > /dev/null +${tools_dir}/grib_dump $tempIndex1 > /dev/null rm -rf $temp_dir_A @@ -158,6 +158,42 @@ rm -rf $temp_dir_A ${tools_dir}/grib_index_build -N -o $tempIndex1 $sample1 > /dev/null ${tools_dir}/grib_dump $tempIndex1 >/dev/null +# With DEBUG enabled +# -------------------- +ECCODES_DEBUG=-1 ${tools_dir}/grib_index_build -N -o $tempIndex1 $sample1 > /dev/null + +# ECC-1773: GRIB2 multi-field messages +# ------------------------------------- +infile=$data_dir/multi.grib2 +${tools_dir}/grib_index_build -o $tempIndex1 $infile > $temp 2>&1 +grep -q "Indexing multi-field messages is not fully supported" $temp + +# Change keys before indexing +# ---------------------------- +infile=$data_dir/tigge_pf_ecmwf.grib2 + +${tools_dir}/grib_index_build -N -o $tempIndex1 $infile > $temp +grep -q "mars.stream = { enfo }" $temp +grep -q "mars.type = { pf }" $temp + +ECCODES_INDEX_SET_KEYS='typeOfProcessedData=af' ${tools_dir}/grib_index_build -N -o $tempIndex1 $infile > $temp +grep -q "mars.stream = { oper }" $temp +grep -q "mars.type = { fc }" $temp + +set +e +ECCODES_INDEX_SET_KEYS='nosuchkey=1,typeOfProcessedData=af' ${tools_dir}/grib_index_build -N -o $tempIndex1 $infile > $temp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Unable to set nosuchkey=1,typeOfProcessedData=af" $temp + +set +e +ECCODES_INDEX_SET_KEYS='rubbish' ${tools_dir}/grib_index_build -N -o $tempIndex1 $infile > $temp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Unable to parse" $temp + # ------------------ # Error conditions @@ -172,5 +208,5 @@ grep -q "End of resource reached" $tempOut # Clean up -rm -f $tempOut $tempRef +rm -f $temp $tempOut $tempRef rm -f $tempIndex $tempIndex1 $tempIndex2 $tempGribFile1 $tempGribFile2 diff --git a/tests/grib_iterator.sh b/tests/grib_iterator.sh index 152e95c0c..c1f549a53 100755 --- a/tests/grib_iterator.sh +++ b/tests/grib_iterator.sh @@ -45,6 +45,14 @@ grep -q "Latitude Longitude Value shortName level" $tempText ${tools_dir}/grib_get_data "$samp_dir/sh_ml_grib2.tmpl" > $tempText +# ECC-1781: Reduced Gaussian grid with rotation +# --------------------------------------------- +${tools_dir}/grib_get_data $samp_dir/reduced_rotated_gg_pl_320_grib1.tmpl > $tempText +${tools_dir}/grib_get_data $samp_dir/reduced_rotated_gg_pl_320_grib2.tmpl > $tempText +ECCODES_DEBUG=-1 ${tools_dir}/grib_get_data ${data_dir}/reduced_gaussian_sub_area.grib2 > $tempText 2>&1 +grep -q "sub-area num points=53564" $tempText + + # ECC-1642: badly encoded regular grids # ------------------------------------- ${tools_dir}/grib_set -s Ni=33 $samp_dir/GRIB2.tmpl $tempGrib diff --git a/tests/grib_list_keys.sh b/tests/grib_list_keys.sh new file mode 100755 index 000000000..c58bddc96 --- /dev/null +++ b/tests/grib_list_keys.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_list_keys_test" +tempOut=temp.$label.txt + +if [ -d "$ECCODES_DEFINITION_PATH" ]; then + if [ -x "${tools_dir}/grib_list_keys" ]; then + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/boot.def > $tempOut + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.4.2000.def > $tempOut + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.3.0.def > $tempOut + ${tools_dir}/grib_list_keys $ECCODES_DEFINITION_PATH/grib2/template.3.120.def > $tempOut + fi +fi + +# Clean up +rm -f $tempOut diff --git a/tests/grib_ls.sh b/tests/grib_ls.sh index bdbdba4d4..be4f7a38b 100755 --- a/tests/grib_ls.sh +++ b/tests/grib_ls.sh @@ -32,6 +32,24 @@ set -e grep -q "Full documentation and examples at" $tempLog grep -q "https://confluence.ecmwf.int/display/ECC/grib_ls" $tempLog +set +e +${tools_dir}/grib_ls -? > $tempLog +status=$? +set -e +[ $status -ne 0 ] + +set +e +${tools_dir}/grib_ls -h > $tempLog +status=$? +set -e +[ $status -ne 0 ] + +set +e +DOXYGEN_USAGE=1 ${tools_dir}/grib_ls > $tempLog +status=$? +set -e +[ $status -ne 0 ] + ${tools_dir}/grib_ls -P count $infile > $tempLog ${tools_dir}/grib_ls -p count,step $infile >> $tempLog @@ -172,6 +190,14 @@ grep -q "0 of 38 messages" $tempText ${tools_dir}/grib_ls -w units!=K $file > $tempText grep -q "30 of 38 messages" $tempText +${tools_dir}/grib_ls -w scaleFactorOfSecondFixedSurface=missing $file > $tempText +grep -q "36 of 38 messages" $tempText +${tools_dir}/grib_ls -w scaleFactorOfSecondFixedSurface!=missing $file > $tempText +grep -q "2 of 38 messages" $tempText + +${tools_dir}/grib_ls -w referenceValue:d=0 $file > $tempText +grep -q "5 of 38 messages" $tempText + file=mixed.grib # Has 14 messages ${tools_dir}/grib_ls -w packingType=grid_simple,gridType=regular_ll/regular_gg $file > $tempText grep -q "12 of 14 messages" $tempText diff --git a/tests/grib_merge.sh b/tests/grib_merge.sh new file mode 100755 index 000000000..acf59e7a6 --- /dev/null +++ b/tests/grib_merge.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_merge_test" + +tempGrib=temp.$label.grib + +f1=$ECCODES_SAMPLES_PATH/regular_ll_pl_grib1.tmpl +f2=$ECCODES_SAMPLES_PATH/regular_ll_sfc_grib1.tmpl +${tools_dir}/grib_merge $f1 $f2 $tempGrib + +# Clean up +rm -f $tempGrib diff --git a/tests/grib_multi.sh b/tests/grib_multi.sh index f8e2d94d8..028591264 100755 --- a/tests/grib_multi.sh +++ b/tests/grib_multi.sh @@ -11,7 +11,7 @@ . ./include.ctest.sh label="grib_multi_test" -tmpdata=temp.$label.$$.grib +tmpdata=temp.$label.grib rm -f $tmpdata parameterNumber=`${tools_dir}/grib_get -p parameterNumber -w parameterCategory=2,parameterNumber=3 ${data_dir}/multi.grib2` @@ -35,4 +35,16 @@ if [ -z "$parameterNumber" ]; then exit 1 fi +# Convert to single-field +# ----------------------- +infile=${data_dir}/multi.grib2 +${tools_dir}/grib_copy $infile $tmpdata +c1=$(${tools_dir}/grib_count $infile) +c2=$(${tools_dir}/grib_count $tmpdata) +[ $c1 -eq 30 ] +[ $c2 -eq 56 ] + + +# Clean up +rm -f $tmpdata rm -f $tmpdata.1 $tmpdata.rules diff --git a/tests/grib_multi_from_message.cc b/tests/grib_multi_from_message.cc index 798230db5..1728e371c 100644 --- a/tests/grib_multi_from_message.cc +++ b/tests/grib_multi_from_message.cc @@ -8,25 +8,14 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/* - * test: reading GRIB2 multi fields messages from memory - */ +/* Test: reading GRIB2 multi fields messages from memory */ #include "grib_api_internal.h" - -static void usage(const char* prog) -{ - fprintf(stderr, "usage: %s [-m] file.grib\n", prog); - exit(1); -} - int main(int argc, char* argv[]) { struct stat finfo; - char shortName[20] = { - 0, - }; + char shortName[20] = {0,}; size_t len; grib_handle* h = NULL; size_t fsize; @@ -49,25 +38,18 @@ int main(int argc, char* argv[]) else if (argc == 2) filename = argv[1]; else - usage(argv[0]); + return 1; Assert(filename); f = fopen(filename, "rb"); - if (!f) { - perror(filename); - exit(1); - } + Assert(f); stat(filename, &finfo); fsize = finfo.st_size; data = (unsigned char*)malloc(fsize); p = data; - - if (!data) { - fprintf(stderr, "unable to allocate %ld bytes\n", (long)fsize); - exit(1); - } + Assert(data); if (fread(data, 1, fsize, f) != fsize) { perror(filename); diff --git a/tests/grib_set_fail.sh b/tests/grib_set_fail.sh index 1d850141e..e3fd7acd9 100755 --- a/tests/grib_set_fail.sh +++ b/tests/grib_set_fail.sh @@ -19,7 +19,7 @@ temp=${data_dir}/temp.$label.out infile=${data_dir}/regular_gaussian_surface.grib2 -# Set without -s. Expected to fail +# Set without -s # ---------------------------------------------------- set +e ${tools_dir}/grib_set -p levtype $infile $outfile > $temp 2>&1 @@ -28,7 +28,7 @@ set -e [ $status -ne 0 ] grep -q "provide some keys to set" $temp -# Set with empty -s. Expected to fail +# Set with empty -s # ---------------------------------------------------- set +e ${tools_dir}/grib_set -s '' $infile $outfile > $temp 2>&1 @@ -37,7 +37,7 @@ set -e [ $status -ne 0 ] grep -q "provide some keys to set" $temp -# Out-of-bounds value. Expected to fail +# Out-of-bounds value # ---------------------------------------------------- input=${data_dir}/reduced_gaussian_sub_area.grib2 set +e @@ -47,7 +47,7 @@ set -e [ $status -ne 0 ] grep -q "Trying to encode value of 1000 but the maximum allowable value is 255 (number of bits=8)" $temp -# Negative value for an unsigned key. Expected to fail +# Negative value for an unsigned key # ---------------------------------------------------- input=${data_dir}/reduced_gaussian_sub_area.grib2 set +e @@ -95,6 +95,31 @@ status=$? set -e [ $status -ne 0 ] +# ECC-1777: Bad date/time +# ------------------------- +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +${tools_dir}/grib_set -s dataDate=20180229 $input $outfile > $temp 2>&1 +grep -q "Date is not valid" $temp + +${tools_dir}/grib_set -s dataTime=4261 $input $outfile > $temp 2>&1 +grep -q "Time is not valid" $temp + +${tools_dir}/grib_set -s dataTime=2501 $input $outfile > $temp 2>&1 +grep -q "Time is not valid" $temp + +# Note for GRIB1 we DO fail on a bad date! This need to be consistent across editions +input=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +set +e +${tools_dir}/grib_set -s dataDate=20180229 $input $outfile > $temp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "invalid date 20180229" $temp + +# 2016 did have 29th Feb +${tools_dir}/grib_set -s dataDate=20160229 $input $outfile + + # ECC-1359: string that can be converted to an integer # --------------------------------------------------- ${tools_dir}/grib_set -s month:s=6 $ECCODES_SAMPLES_PATH/GRIB2.tmpl $outfile @@ -156,6 +181,11 @@ set -e [ $status -ne 0 ] grep -q "centre: No such code table entry.*Did you mean.*ecmf" $temp +# Overflow/Underflow +# ------------------------ +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +${tools_dir}/grib_set -s missingValue=9223372036854776666 $input $outfile > $temp 2>&1 +grep -q "ECCODES WARNING : Setting .* causes overflow/underflow" $temp # ------------------------ # Unreadable message diff --git a/tests/grib_step.sh b/tests/grib_step.sh index e7e9e28ff..4ed45a3f1 100755 --- a/tests/grib_step.sh +++ b/tests/grib_step.sh @@ -14,8 +14,9 @@ REDIRECT=/dev/null label=grib_step_test tempGrb=${data_dir}/temp.$label.out.grib -templog=${data_dir}/temp.$label.log -rm -f $templog $tempGrb +tempLog=${data_dir}/temp.$label.log +tempFilt=${data_dir}/temp.$label.filt +rm -f $tempLog $tempGrb grib1_sample=$ECCODES_SAMPLES_PATH/GRIB1.tmpl grib2_sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl @@ -31,7 +32,7 @@ do #echo grib_set -s ${key}=$s ${data_dir}/timeRangeIndicator_${i}.grib $tempGrb #grib_get -p step,startStep,endStep,P1,P2,timeRangeIndicator,indicatorOfUnitOfTimeRange ${data_dir}/timeRangeIndicator_${i}.grib $tempGrb ${tools_dir}/grib_get -p mars.step,stepRange,startStep,endStep,P1,P2,timeRangeIndicator,indicatorOfUnitOfTimeRange:l \ - ${data_dir}/timeRangeIndicator_${i}.grib $tempGrb >> ${templog} + ${data_dir}/timeRangeIndicator_${i}.grib $tempGrb >> $tempLog done done done @@ -44,7 +45,7 @@ do #echo grib_set -s ${key}=$s ${data_dir}/timeRangeIndicator_${i}.grib $tempGrb #grib_ls -p step,startStep,endStep,P1,P2,timeRangeIndicator,indicatorOfUnitOfTimeRange ${data_dir}/timeRangeIndicator_${i}.grib $tempGrb ${tools_dir}/grib_get -p mars.step,stepRange,startStep,endStep,P1,P2,timeRangeIndicator,indicatorOfUnitOfTimeRange:l \ - ${data_dir}/timeRangeIndicator_${i}.grib $tempGrb >> ${templog} + ${data_dir}/timeRangeIndicator_${i}.grib $tempGrb >> $tempLog done rm -f $tempGrb @@ -52,17 +53,17 @@ rm -f $tempGrb # test added for ifs stepType=max,min ${tools_dir}/grib_set -s stepType=max,startStep=3,endStep=6 ${data_dir}/reduced_gaussian_model_level.grib1 $tempGrb ${tools_dir}/grib_get -p mars.step,stepRange,startStep,endStep,P1,P2,timeRangeIndicator,indicatorOfUnitOfTimeRange:l \ - ${data_dir}/reduced_gaussian_model_level.grib1 $tempGrb >> ${templog} + ${data_dir}/reduced_gaussian_model_level.grib1 $tempGrb >> $tempLog rm -f $tempGrb -diff ${data_dir}/step.log ${templog} +diff ${data_dir}/step.log $tempLog -(${tools_dir}/grib_filter ${data_dir}/step_grib1.filter ${data_dir}/timeRangeIndicator_0.grib > ${templog}) 2>$REDIRECT +(${tools_dir}/grib_filter ${data_dir}/step_grib1.filter ${data_dir}/timeRangeIndicator_0.grib > $tempLog) 2>$REDIRECT -diff ${data_dir}/step_grib1.log ${templog} +diff ${data_dir}/step_grib1.log $tempLog -rm -f ${templog} +rm -f $tempLog # GRIB-180 # ------------ @@ -166,10 +167,10 @@ grib_check_key_equals $temp day 7 # Seconds (ignored) # ----------------- -${tools_dir}/grib_ls -s second=9 -n time $grib2_sample 2>$templog +${tools_dir}/grib_ls -s second=9 -n time $grib2_sample 2>$tempLog # Something should have been written to stderr -[ -s $templog ] -grep -q "Truncating time: non-zero seconds.* ignored" $templog +[ -s $tempLog ] +grep -q "Truncating time: non-zero seconds.* ignored" $tempLog # Hour or minute set to 255 # --------------------------- @@ -214,33 +215,50 @@ ECCODES_GRIBEX_MODE_ON=1 ${tools_dir}/grib_set -s stepRange=11-12 $input $temp grib_check_key_equals $temp P1,P2 '0 11' set +e -${tools_dir}/grib_set -s stepRange=11-12 $input $temp 2>$templog +${tools_dir}/grib_set -s stepRange=11-12 $input $temp 2>$tempLog status=$? set -e [ $status -ne 0 ] -grep -q "Unable to set stepRange" $templog +grep -q "Unable to set stepRange" $tempLog # GRIB1: sub-hourly # ----------------- ${tools_dir}/grib_set -s unitOfTimeRange=0,P1=5 $grib1_sample $temp set +e -${tools_dir}/grib_get -p step $temp 2>$templog +${tools_dir}/grib_get -p step $temp 2>$tempLog status=$? set -e [ $status -ne 0 ] -grep -q "unable to represent the step in h" $templog +grep -q "unable to represent the step in h" $tempLog # GRIB1: Unknown timeRangeIndicator ${tools_dir}/grib_set -s timeRangeIndicator=138 $grib1_sample $temp set +e -${tools_dir}/grib_get -p step $temp 2>$templog +${tools_dir}/grib_get -p step $temp 2>$tempLog status=$? set -e [ $status -ne 0 ] -grep -q "Unknown stepType" $templog +grep -q "Unknown stepType" $tempLog +# Several time ranges +# -------------------- +cat >$tempFilt < $tempLog +cat $tempLog +grep -q "255 8 7" $tempLog # Clean up -rm -f $temp $templog +rm -f $temp $tempLog $tempFilt rm -f $grib2File.p8tmp ${grib2File}.tmp x.grib diff --git a/tests/grib_sub_area_check.sh b/tests/grib_sub_area_check.sh new file mode 100755 index 000000000..9b602e4cb --- /dev/null +++ b/tests/grib_sub_area_check.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_sub_area_check_test" +tempOut=temp.$label.txt + +if [ ! -x "${tools_dir}/gg_sub_area_check" ]; then + exit 0 +fi + +set +e +${tools_dir}/gg_sub_area_check +status=$? +set -e +[ $status -ne 0 ] + +f1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl +f2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +${tools_dir}/gg_sub_area_check $f1 $f2 > $tempOut + +f1=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib1.tmpl +f2=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl +${tools_dir}/gg_sub_area_check $f1 $f2 > $tempOut + +# Clean up +rm -f $tempOut diff --git a/tests/grib_sub_hourly.sh b/tests/grib_sub_hourly.sh index fdd174c28..bb7bac891 100755 --- a/tests/grib_sub_hourly.sh +++ b/tests/grib_sub_hourly.sh @@ -13,6 +13,14 @@ # See JIRA issues ECC-1620, ECC-1238 # ----------------------------------- +label="grib_sub_hourly" +temp=temp.1.$label +temp2=temp.2.$label +tempFilt=temp.$label.filt +tempText=temp.$label.txt + +sample_g2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + grib_expect_failure() { a_file=$1 @@ -51,97 +59,112 @@ if (set -u; : ${ECCODES_GRIB_HOURLY_STEPS_WITH_UNITS?}) 2> /dev/null; then fi -label="grib_sub_hourly" -temp=temp.1.$label -temp2=temp.2.$label -tempFilt=temp.$label.filt -tempText=temp.$label.txt - -sample_g2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl - instantaneous_field=$data_dir/reduced_gaussian_surface.grib2 accumulated_field=$data_dir/reduced_gaussian_sub_area.grib2 + +# ECC-1813: Test that we can set the stepUnits without setting the step +in="$instantaneous_field" +low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" +${tools_dir}/grib_set -s stepUnits=m,step=60 $in $temp +grib_check_key_equals $temp "-p $low_level_keys" "60 m" +${tools_dir}/grib_set -s stepUnits=s $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "3600 s" +${tools_dir}/grib_set -s stepUnits=m $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "60 m" +${tools_dir}/grib_set -s stepUnits=h $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "1 h" + +in="$accumulated_field" +low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" +${tools_dir}/grib_set -s stepUnits=m,stepRange=60-180 $in $temp +grib_check_key_equals $temp "-p $low_level_keys" "60 m 120 m" +${tools_dir}/grib_set -s stepUnits=s $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "3600 s 7200 s" +${tools_dir}/grib_set -s stepUnits=m $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "60 m 120 m" +${tools_dir}/grib_set -s stepUnits=h $temp $temp2 +grib_check_key_equals $temp2 "-p $low_level_keys" "1 h 2 h" + # Check the lowercase alias 'stepunits' for a variety of step types (instant, accum etc) ${tools_dir}/grib_get -p stepunits $data_dir/tigge_cf_ecmwf.grib2 #### Make sure that step, stepRange, startStep, endStep produce the same result for instantaneous fields -fn="$instantaneous_field" +in="$instantaneous_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" keys_step="step,step:s,step:i,step:d,stepUnits:s" keys_step_range="stepRange,stepRange:s,stepRange:i,stepRange:d,stepUnits:s" keys_start_step="startStep,startStep:s,startStep:i,startStep:d,stepUnits:s" keys_end_step="endStep,endStep:s,endStep:i,endStep:d,stepUnits:s" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 h" -${tools_dir}/grib_set -s stepUnits=m,step=59 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,step=59 $in $temp grib_check_key_equals $temp "-p $keys_step" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_step_range" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_start_step" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_end_step" "59m 59m 59 59 m" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 h" -${tools_dir}/grib_set -s step=59m $fn $temp +${tools_dir}/grib_set -s step=59m $in $temp grib_check_key_equals $temp "-p $keys_step" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_step_range" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_start_step" "59m 59m 59 59 m" grib_check_key_equals $temp "-p $keys_end_step" "59m 59m 59 59 m" - #### stepUnits overrides the units in the low level keys # if stepUnits=UNIT is set, then set the low level keys to UNIT # else optimise low level keys # instant fields: low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -fn="$instantaneous_field" +in="$instantaneous_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" keys__="step,stepUnits:s" keys_s="step:s" keys_i="step:i,stepUnits:s" keys_d="step:d,stepUnits:s" -${tools_dir}/grib_set -s stepUnits=m,step=60 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,step=60 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m" grib_check_key_equals $temp "-p $keys_s" "1$HOUR" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "60m" -${tools_dir}/grib_set -s stepUnits=m,step=60 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,step=60 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m" grib_check_key_equals $temp "-p $keys_s" "1$HOUR" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "60m" -${tools_dir}/grib_set -s step=60m $fn $temp +${tools_dir}/grib_set -s step=60m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1 h" grib_check_key_equals $temp "-p $keys_s" "1$HOUR" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "60m" # accumulated fields: -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" keys__="step,startStep,endStep,stepRange,stepUnits:s" keys_s="step:s,startStep:s,endStep:s,stepRange:s,stepUnits:s" keys_i="step:i,startStep:i,endStep:i,stepRange:i,stepUnits:s" keys_d="step:d,startStep:d,endStep:d,stepRange:d,stepUnits:s" -${tools_dir}/grib_set -s stepUnits=m,stepRange=60-120 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,stepRange=60-120 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m 60 m" grib_check_key_equals $temp "-p $keys_s" "2$HOUR 1$HOUR 2$HOUR 1$HOUR-2$HOUR h" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "120m 60m 120m 60m-120m m" -${tools_dir}/grib_set -s stepUnits=m,stepRange=60-120 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,stepRange=60-120 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m 60 m" grib_check_key_equals $temp "-p $keys_s" "2$HOUR 1$HOUR 2$HOUR 1$HOUR-2$HOUR h" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "120m 60m 120m 60m-120m m" -${tools_dir}/grib_set -s stepRange=60m-120m $fn $temp +${tools_dir}/grib_set -s stepRange=60m-120m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1 h 1 h" grib_check_key_equals $temp "-p $keys_s" "2$HOUR 1$HOUR 2$HOUR 1$HOUR-2$HOUR h" grib_check_key_equals $temp "-p $keys_s -s stepUnits=m" "120m 60m 120m 60m-120m m" #### CHECK units -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=96,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=96,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 h 96 h" grib_check_key_equals $temp " -w count=1 -s stepUnits=s -p step:i,stepUnits:s" "345600 s" @@ -162,38 +185,38 @@ grib_check_key_equals $temp " -w count=1 -s stepUnits=6h -p step,stepUnits:s" "1 grib_check_key_equals $temp " -w count=1 -s stepUnits=12h -p step,stepUnits:s" "8x12h 12h" grib_check_key_equals $temp " -w count=1 -s stepUnits=D -p step,stepUnits:s" "4D D" -${tools_dir}/grib_set -s stepUnits=s,startStep=0,endStep=345600 $fn $temp +${tools_dir}/grib_set -s stepUnits=s,startStep=0,endStep=345600 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 s 345600 s" -${tools_dir}/grib_set -s stepUnits=m,startStep=0,endStep=5760 $fn $temp +${tools_dir}/grib_set -s stepUnits=m,startStep=0,endStep=5760 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 m 5760 m" -${tools_dir}/grib_set -s stepUnits=h,startStep=0,endStep=96 $fn $temp +${tools_dir}/grib_set -s stepUnits=h,startStep=0,endStep=96 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 h 96 h" -${tools_dir}/grib_set -s stepUnits=6h,startStep=0,endStep=16 $fn $temp +${tools_dir}/grib_set -s stepUnits=6h,startStep=0,endStep=16 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 6h 16 6h" -${tools_dir}/grib_set -s stepUnits=12h,startStep=0,endStep=8 $fn $temp +${tools_dir}/grib_set -s stepUnits=12h,startStep=0,endStep=8 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 12h 8 12h" -${tools_dir}/grib_set -s stepUnits=D,startStep=0,endStep=4 $fn $temp +${tools_dir}/grib_set -s stepUnits=D,startStep=0,endStep=4 $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 D 4 D" #### CHECK negative forecastTime -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s forecastTime=-6,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=-6,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "-6 h 6 h" grib_check_key_equals $temp "-s stepUnits:s=h -p startStep:s,endStep:s" "-6$HOUR 0$HOUR" grib_check_key_equals $temp "-s stepUnits:s=m -p startStep:s,endStep:s" "-360m 0m" grib_check_key_equals $temp "-s stepUnits:s=s -p startStep:s,endStep:s" "-21600s 0s" -${tools_dir}/grib_set -s forecastTime=-48,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=0,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=-48,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=0,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p stepRange" "-48$HOUR" #### CHECK: check optimal units are set correctly in GRIB files -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D" ### TODO(maee): @Shahram: how to make parameters position independent @@ -220,18 +243,18 @@ grib_check_key_equals $temp2 "-p $low_level_keys" "60 h 120 h" ${tools_dir}/grib_set -s stepUnits:s=h,startStep:i=60,endStep:i=180 $temp $temp2 grib_check_key_equals $temp2 "-p $low_level_keys" "60 h 120 h" -#fn="$accumulated_field" +#in="$accumulated_field" #low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" ##high_level_keys="startStep:s,endStep:s" #high_level_keys="startStep:i,endStep:i" -#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp #grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D" #grib_check_key_equals $temp "-p $high_level_keys" "24 48" #${tools_dir}/grib_set -s startStep:i=24 $temp $temp2 #grib_check_key_equals $temp2 "-p $low_level_keys" "24 h 0 h" #grib_check_key_equals $temp2 "-p $high_level_keys" "24 24" -#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=24,indicatorOfUnitForTimeRange=h $fn $temp +#${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=24,indicatorOfUnitForTimeRange=h $in $temp #grib_check_key_equals $temp "-p $low_level_keys" "24 h 24 h" #grib_check_key_equals $temp "-p $high_level_keys" "24 48" #${tools_dir}/grib_set -s startStep:i=24 $temp $temp2 @@ -240,9 +263,9 @@ grib_check_key_equals $temp2 "-p $low_level_keys" "60 h 120 h" #exit #### CHECK: grib_set - endStep + stepUnits -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D" # Use range unit: hour @@ -302,14 +325,14 @@ ${tools_dir}/grib_set -s stepRange:s=62D-122D $temp $temp2 grib_check_key_equals $temp2 "-p $low_level_keys" "1488 h 1440 h" grib_check_key_equals $temp2 "-p stepRange:s" "1488$HOUR-2928$HOUR" -fn="$instantaneous_field" +in="$instantaneous_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" keys__="step,stepUnits:s" keys_s="step:s" keys_i="step:i,stepUnits:s" keys_d="step:d,stepUnits:s" -${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $keys__ -s stepUnits=s" "3540s s" grib_check_key_equals $temp "-p $keys__ -s stepUnits=m" "59m m" #grib_check_key_equals $temp "-p $keys__ -s stepUnits=h" "0" # not supported @@ -324,7 +347,7 @@ grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "59 m" #grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0.983333" # not supported -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $keys_i -s stepUnits=s" "0 s" grib_check_key_equals $temp "-p $keys_i -s stepUnits=m" "0 m" grib_check_key_equals $temp "-p $keys_i -s stepUnits=h" "0 h" @@ -333,14 +356,14 @@ grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "0 m" grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0 h" -fn="$instantaneous_field" +in="$instantaneous_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s" keys__="step,stepUnits:s" keys_s="step:s,stepUnits:s" keys_i="step:i,stepUnits:s" keys_d="step:d,stepUnits:s" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 m" grib_check_key_equals $temp "-p $keys__" "0m m" grib_check_key_equals $temp "-p $keys_s" "0m m" @@ -361,7 +384,7 @@ grib_check_key_equals $temp "-p $keys_d -s stepUnits=m" "0 m" grib_check_key_equals $temp "-p $keys_d -s stepUnits=h" "0 h" -${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "59 m" grib_check_key_equals $temp "-p $keys__" "59m m" #grib_check_key_equals $temp "-p $keys_s" "59" @@ -369,14 +392,14 @@ grib_check_key_equals $temp "-p $keys_s" "59m m" grib_check_key_equals $temp "-p $keys_i" "59 m" grib_check_key_equals $temp "-p $keys_d" "59 m" -${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m" grib_check_key_equals $temp "-p $keys__" "1$HOUR h" grib_check_key_equals $temp "-p $keys_s" "1$HOUR h" grib_check_key_equals $temp "-p $keys_i" "1 h" grib_check_key_equals $temp "-p $keys_d" "1 h" -${tools_dir}/grib_set -s forecastTime=61,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=61,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "61 m" grib_check_key_equals $temp "-p $keys__" "61m m" #grib_check_key_equals $temp "-p $keys_s" "61" @@ -384,14 +407,14 @@ grib_check_key_equals $temp "-p $keys_s" "61m m" grib_check_key_equals $temp "-p $keys_i" "61 m" grib_check_key_equals $temp "-p $keys_d" "61 m" -${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "24 h" grib_check_key_equals $temp "-p $keys__" "24$HOUR h" grib_check_key_equals $temp "-p $keys_s" "24$HOUR h" grib_check_key_equals $temp "-p $keys_i" "24 h" grib_check_key_equals $temp "-p $keys_d" "24 h" -${tools_dir}/grib_set -s forecastTime=1440,indicatorOfUnitOfTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=1440,indicatorOfUnitOfTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1440 m" grib_check_key_equals $temp "-p $keys__" "24$HOUR h" grib_check_key_equals $temp "-p $keys_s" "24$HOUR h" @@ -399,40 +422,40 @@ grib_check_key_equals $temp "-p $keys_i" "24 h" grib_check_key_equals $temp "-p $keys_d" "24 h" -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" -${tools_dir}/grib_set -s stepRange=60m-2h $fn $temp +${tools_dir}/grib_set -s stepRange=60m-2h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1 h 1 h" -fn="$accumulated_field" +in="$accumulated_field" low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s,lengthOfTimeRange,indicatorOfUnitForTimeRange:s" keys__="stepRange,startStep,endStep" keys_s="stepRange:s,startStep:s,endStep:s" keys_i="stepRange:i,startStep:i,endStep:i" keys_d="stepRange:d,startStep:d,endStep:d" -${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=0,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "0 m 2 h" grib_check_key_equals $temp "-p $keys__" "0$HOUR-2$HOUR 0$HOUR 2$HOUR" grib_check_key_equals $temp "-p $keys_s" "0$HOUR-2$HOUR 0$HOUR 2$HOUR" grib_check_key_equals $temp "-p $keys_i" "2 0 2" grib_check_key_equals $temp "-p $keys_d" "2 0 2" -${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +${tools_dir}/grib_set -s forecastTime=24,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp grib_check_key_equals $temp "-p $low_level_keys" "24 h 1 D" grib_check_key_equals $temp "-p $keys__" "24$HOUR-48$HOUR 24$HOUR 48$HOUR" grib_check_key_equals $temp "-p $keys_s" "24$HOUR-48$HOUR 24$HOUR 48$HOUR" grib_check_key_equals $temp "-p $keys_i" "48 24 48" grib_check_key_equals $temp "-p $keys_d" "48 24 48" -${tools_dir}/grib_set -s forecastTime=25,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $fn $temp +${tools_dir}/grib_set -s forecastTime=25,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=1,indicatorOfUnitForTimeRange=D $in $temp grib_check_key_equals $temp "-p $low_level_keys" "25 h 1 D" grib_check_key_equals $temp "-p $keys__" "25$HOUR-49$HOUR 25$HOUR 49$HOUR" grib_check_key_equals $temp "-p $keys_s" "25$HOUR-49$HOUR 25$HOUR 49$HOUR" grib_check_key_equals $temp "-p $keys_i" "49 25 49" grib_check_key_equals $temp "-p $keys_d" "49 25 49" -${tools_dir}/grib_set -s forecastTime=45,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=15,indicatorOfUnitForTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=45,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=15,indicatorOfUnitForTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "45 m 15 m" grib_check_key_equals $temp "-p $keys__" "45m-60m 45m 60m" #grib_check_key_equals $temp "-p $keys_s" "45-60 45 60" @@ -440,28 +463,28 @@ grib_check_key_equals $temp "-p $keys_s" "45m-60m 45m 60m" grib_check_key_equals $temp "-p $keys_i" "60 45 60" grib_check_key_equals $temp "-p $keys_d" "60 45 60" -${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=60,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=2,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "60 m 2 h" grib_check_key_equals $temp "-p $keys__" "1$HOUR-3$HOUR 1$HOUR 3$HOUR" grib_check_key_equals $temp "-p $keys_s" "1$HOUR-3$HOUR 1$HOUR 3$HOUR" grib_check_key_equals $temp "-p $keys_i" "3 1 3" grib_check_key_equals $temp "-p $keys_d" "3 1 3" -${tools_dir}/grib_set -s forecastTime=18,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=18,indicatorOfUnitOfTimeRange=h,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "18 h 6 h" grib_check_key_equals $temp "-p $keys__" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_s" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_i" "24 18 24" grib_check_key_equals $temp "-p $keys_d" "24 18 24" -${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=360,indicatorOfUnitForTimeRange=m $fn $temp +${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=360,indicatorOfUnitForTimeRange=m $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1080 m 360 m" grib_check_key_equals $temp "-p $keys__" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_s" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_i" "24 18 24" grib_check_key_equals $temp "-p $keys_d" "24 18 24" -${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $fn $temp +${tools_dir}/grib_set -s forecastTime=1080,indicatorOfUnitOfTimeRange=m,lengthOfTimeRange=6,indicatorOfUnitForTimeRange=h $in $temp grib_check_key_equals $temp "-p $low_level_keys" "1080 m 6 h" grib_check_key_equals $temp "-p $keys__" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" grib_check_key_equals $temp "-p $keys_s" "18$HOUR-24$HOUR 18$HOUR 24$HOUR" @@ -542,5 +565,30 @@ set -e [ $status -ne 0 ] grep -q "Invalid unit" $tempText + +# ECC-1800: Set stepUnits before paramIds, which cause changes in the PTDN +${tools_dir}/grib_set -s stepUnits=m,productDefinitionTemplateNumber=40 $sample_g2 $temp +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '0 m 40' + +${tools_dir}/grib_set -s stepUnits=m,step=6,productDefinitionTemplateNumber=40 $sample_g2 $temp +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,forecastTime' '0 m 6' + +${tools_dir}/grib_set -s stepUnits=s,paramId=210203 $sample_g2 $temp # is_chemical +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 40' + +${tools_dir}/grib_set -s stepUnits=s,paramId=131060 $sample_g2 $temp # probability forecasts +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 9' + +${tools_dir}/grib_set -s stepUnits=s,paramId=210073 $sample_g2 $temp # is_aerosol +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 48' + +${tools_dir}/grib_set -s stepUnits=s,paramId=210170 $sample_g2 $temp # is_chemical_srcsink +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 76' + +# Add a case with filter too +echo "set stepUnits='s'; set paramId=210203; write;" | ${tools_dir}/grib_filter -o $temp - $sample_g2 +grib_check_key_equals $temp '-p indicatorOfUnitOfTimeRange,stepUnits:s,productDefinitionTemplateNumber' '13 s 40' + + # Clean up rm -f $temp $temp2 $tempFilt $tempText diff --git a/tests/grib_to_json.sh b/tests/grib_to_json.sh new file mode 100755 index 000000000..be05aa00c --- /dev/null +++ b/tests/grib_to_json.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_to_json_test" +REDIRECT=/dev/null +tempOut=temp.$label.txt + +if [ ! -x "${tools_dir}/grib_to_json" ]; then + exit 0 +fi + +# Currently only works for GRIB edition 1 !!! +${tools_dir}/grib_to_json $ECCODES_SAMPLES_PATH/GRIB1.tmpl > $tempOut + +# 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 + +# Check the json_xs command actually works! +set +e +echo '[]' | json_xs > $REDIRECT 2>&1 +if [ $? -ne 0 ]; then JSON_CHECK=""; fi +set -e +echo "Using $JSON_CHECK ..." + +if test "x$JSON_CHECK" != "x"; then + json_xs < $tempOut >$REDIRECT 2> $REDIRECT +fi + +# Clean up +rm -f $tempOut diff --git a/tests/grib_to_netcdf.sh b/tests/grib_to_netcdf.sh index c07dc89e9..f13d8475b 100755 --- a/tests/grib_to_netcdf.sh +++ b/tests/grib_to_netcdf.sh @@ -148,7 +148,9 @@ set -e [ $status -ne 0 ] grep -q "Wrong number of fields" $tempText -# Not regular grid + +echo "Not a regular grid ..." +# -------------------------- input=${data_dir}/reduced_gaussian_pressure_level.grib2 set +e ${tools_dir}/grib_to_netcdf -o $tempNetcdf $input > $tempText 2>&1 @@ -158,6 +160,17 @@ set -e grep -q "not on a regular lat/lon grid or on a regular Gaussian grid" $tempText +# ECC-1783: No error message when input file has invalid fields +input=$data_dir/bad.grib +set +e +${tools_dir}/grib_to_netcdf -o $tempNetcdf $input > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Wrong message length" $tempText + + +# Validity time check export GRIB_TO_NETCDF_CHECKVALIDTIME=0 ${tools_dir}/grib_to_netcdf -o $tempNetcdf $tempGrib [ -f "$tempNetcdf" ] diff --git a/tests/grib_to_ppm.sh b/tests/grib_to_ppm.sh new file mode 100755 index 000000000..6deea0f8a --- /dev/null +++ b/tests/grib_to_ppm.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_to_ppm_test" +tempOut=temp.$label.txt + +if [ ! -x "${tools_dir}/grib2ppm" ]; then + exit 0 +fi + +# No options +${tools_dir}/grib2ppm + +${tools_dir}/grib2ppm -l 6 -u 7 -c $data_dir/sample.grib2 > $tempOut +${tools_dir}/grib2ppm $data_dir/sample.grib2 > $tempOut + +# Clean up +rm -f $tempOut diff --git a/tests/grib_units_bias_factor.sh b/tests/grib_units_bias_factor.sh new file mode 100755 index 000000000..4dbc9db81 --- /dev/null +++ b/tests/grib_units_bias_factor.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_units_bias_factor_test" +outfile=temp.$label.grib + +infiles="${data_dir}/sample.grib2 ${data_dir}/regular_latlon_surface.grib1" +for infile in $infiles; do + #infile=${data_dir}/sample.grib2 + max=`${tools_dir}/grib_get -F%.3f -p max $infile` + [ "$max" = "311.099" ] + + ${tools_dir}/grib_set -rs unitsFactor=1.1,unitsBias=4 $infile $outfile + max=`${tools_dir}/grib_get -F%.3f -p max $outfile` + [ "$max" = "346.209" ] + + ${tools_dir}/grib_set -rs unitsFactor=2 $infile $outfile + max=`${tools_dir}/grib_get -F%.3f -p max $outfile` + [ "$max" = "622.197" ] + + ${tools_dir}/grib_set -rs unitsBias=4 $infile $outfile + max=`${tools_dir}/grib_get -F%.3f -p max $outfile` + [ "$max" = "315.099" ] +done + +if [ $HAVE_JPEG -eq 1 ]; then + infile=${data_dir}/jpeg.grib2 + ${tools_dir}/grib_get -p max -s unitsBias=1.5 $infile $outfile + ${tools_dir}/grib_get -p min -s unitsFactor=2 $infile $outfile + ${tools_dir}/grib_get -p avg -s unitsFactor=1.1,unitsBias=100 $infile $outfile +fi + +# Clean up +rm -f $outfile diff --git a/tests/grib_unpack_subarray.cc b/tests/grib_unpack_subarray.cc index 3321b4040..1a7bfadab 100644 --- a/tests/grib_unpack_subarray.cc +++ b/tests/grib_unpack_subarray.cc @@ -34,12 +34,12 @@ int main(int argc, char** argv) Assert(sub_values); size_t len = nvalues; - GRIB_CHECK(grib_unpack_double(a, all_values, &len), 0); + GRIB_CHECK(a->unpack_double(all_values, &len), 0); size_t start = nvalues / 10; len = nvalues / 5; printf("nvalues=%zu, start=%zu, len=%zu\n", nvalues, start, len); - GRIB_CHECK(grib_unpack_double_subarray(a, sub_values, start, len), 0); + GRIB_CHECK(a->unpack_double_subarray(sub_values, start, len), 0); for (size_t i = 0; i < len; ++i) { //printf("sub[%zu]=%.10e\n", start + i, sub_values[i]); Assert(all_values[start+i] == sub_values[i]); diff --git a/tests/grib_unpack_subarray.sh b/tests/grib_unpack_subarray.sh index 43bc730d8..3ac3b2530 100755 --- a/tests/grib_unpack_subarray.sh +++ b/tests/grib_unpack_subarray.sh @@ -13,6 +13,9 @@ label="grib_unpack_subarray_test" temp=${label}".grib.tmp" +infile=$data_dir/constant_field.grib2 +$EXEC ${test_dir}/grib_unpack_subarray $infile + infile=$data_dir/sample.grib2 $EXEC ${test_dir}/grib_unpack_subarray $infile diff --git a/tests/grib_update_sections_lengths.cc b/tests/grib_update_sections_lengths.cc new file mode 100644 index 000000000..cda520643 --- /dev/null +++ b/tests/grib_update_sections_lengths.cc @@ -0,0 +1,50 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_api_internal.h" + +int main(int argc, char* argv[]) +{ + grib_handle* h = NULL; + FILE* inf = NULL; + FILE* ouf = NULL; + char* infile = 0; + char* oufile = 0; + int err = 0; + size_t size = 0; + const void* buffer = NULL; + + if (argc < 3) return 1; // prog in out + + infile = argv[1]; + oufile = argv[2]; + + inf = fopen(infile, "rb"); + Assert(inf); + + ouf = fopen(oufile, "wb"); + Assert(ouf); + + while ((h = grib_handle_new_from_file(0, inf, &err)) != NULL) { + grib_update_sections_lengths(h); + GRIB_CHECK(grib_get_message(h, &buffer, &size), 0); + printf("size = %zu\n", size); + if (fwrite(buffer, 1, size, ouf) != size) { + perror(oufile); + exit(1); + } + } + + grib_handle_delete(h); + fclose(inf); + fclose(ouf); + + return 0; +} diff --git a/tests/grib_update_sections_lengths.sh b/tests/grib_update_sections_lengths.sh new file mode 100755 index 000000000..698a8b975 --- /dev/null +++ b/tests/grib_update_sections_lengths.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# (C) Copyright 2005- ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# +# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by +# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. +# + +. ./include.ctest.sh + +label="grib_update_sections_lengths_test" +tempGrib=temp.$label.grib + +gfiles="$data_dir/sample.grib2 $data_dir/missing_field.grib1" +for f in $gfiles; do + $EXEC ${test_dir}/grib_update_sections_lengths $f $tempGrib + ${tools_dir}/grib_compare $f $tempGrib +done + +rm -f $tempGrib diff --git a/tests/grib_util_set_spec.cc b/tests/grib_util_set_spec.cc index 31af1bcb5..e47672868 100644 --- a/tests/grib_util_set_spec.cc +++ b/tests/grib_util_set_spec.cc @@ -132,6 +132,12 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi Assert(err == GRIB_ENCODING_ERROR); Assert(!h2); if (h2) exit(1); + + values[0] = -INFINITY; + h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); + Assert(err == GRIB_ENCODING_ERROR); + Assert(!h2); + if (h2) exit(1); #endif } diff --git a/tests/grib_util_set_spec2.cc b/tests/grib_util_set_spec2.cc index 11e86a915..ddd3f1dc5 100644 --- a/tests/grib_util_set_spec2.cc +++ b/tests/grib_util_set_spec2.cc @@ -14,12 +14,13 @@ static void dump_it(grib_handle* h) { int dump_flags = GRIB_DUMP_FLAG_CODED | GRIB_DUMP_FLAG_OCTET | GRIB_DUMP_FLAG_VALUES | GRIB_DUMP_FLAG_READ_ONLY; - grib_dump_content(h, stdout, "wmo", dump_flags, NULL); + grib_dump_content(h, stderr, "wmo", dump_flags, NULL); } // Lambert conformal static grib_handle* test0() { + fprintf(stderr, "Doing test %s\n-----------------\n", __func__); int err = 0; grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; @@ -37,7 +38,7 @@ static grib_handle* test0() // packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; // packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED; - grib_handle* finalh = grib_util_set_spec( + grib_handle* finalh = codes_grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); Assert(err == 0); @@ -47,6 +48,7 @@ static grib_handle* test0() // Lambert azimuthal static grib_handle* test1() { + fprintf(stderr, "Doing test %s\n-----------------\n", __func__); int err = 0; grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; @@ -68,6 +70,7 @@ static grib_handle* test1() // HEALPix static grib_handle* test2() { + fprintf(stderr, "Doing test %s\n-----------------\n", __func__); int err = 0; grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; @@ -75,14 +78,13 @@ static grib_handle* test2() int set_spec_flags = 0; size_t outlen = 4; - grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2"); + grib_handle* handle = grib_handle_new_from_samples(0, "GRIB1"); spec.grid_type = GRIB_UTIL_GRID_SPEC_HEALPIX; spec.N = 2; - packing_spec.extra_settings_count = 1; - packing_spec.extra_settings[0].type = GRIB_TYPE_LONG; - packing_spec.extra_settings[0].name = "tablesVersion"; - packing_spec.extra_settings[0].long_value = 32; + packing_spec.packing_type = GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER; + packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED; + packing_spec.editionNumber = 2; grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, @@ -94,6 +96,7 @@ static grib_handle* test2() // Spherical harmonics static grib_handle* test3() { + fprintf(stderr, "Doing test %s\n-----------------\n", __func__); int err = 0; grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; @@ -121,6 +124,7 @@ static grib_handle* test3() // Polar stereo static grib_handle* test4() { + fprintf(stderr, "Doing test %s\n-----------------\n", __func__); int err = 0; grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; @@ -129,10 +133,15 @@ static grib_handle* test4() size_t outlen = 0; grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2"); - grib_set_long(handle, "tablesVersion", 32); + //grib_set_long(handle, "tablesVersion", 32); spec.grid_type = GRIB_UTIL_GRID_SPEC_POLAR_STEREOGRAPHIC; outlen = 4; + packing_spec.extra_settings_count = 1; + packing_spec.extra_settings[0].type = GRIB_TYPE_LONG; + packing_spec.extra_settings[0].name = "tablesVersion"; + packing_spec.extra_settings[0].long_value = 32; + grib_handle* finalh = grib_util_set_spec( handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); @@ -143,6 +152,7 @@ static grib_handle* test4() // Regular Gaussian static grib_handle* test5() { + fprintf(stderr, "Doing test %s\n-----------------\n", __func__); int err = 0; grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; @@ -165,6 +175,7 @@ static grib_handle* test5() // Reduced LL static grib_handle* test6() { + fprintf(stderr, "Doing test %s\n-----------------\n", __func__); int err = 0; grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; @@ -187,6 +198,7 @@ static grib_handle* test6() // Unstructured static grib_handle* test7() { + fprintf(stderr, "Doing test %s\n-----------------\n", __func__); int err = 0; grib_util_grid_spec spec = {0,}; grib_util_packing_spec packing_spec = {0,}; diff --git a/tests/grib_util_set_spec2.sh b/tests/grib_util_set_spec2.sh index 95fc00c01..fa289d291 100755 --- a/tests/grib_util_set_spec2.sh +++ b/tests/grib_util_set_spec2.sh @@ -10,4 +10,5 @@ . ./include.ctest.sh +export ECCODES_DEBUG=-1 $EXEC ${test_dir}/grib_util_set_spec2 diff --git a/tests/index_orderby.cc b/tests/index_orderby.cc index f2346fc82..55ff9c2f5 100644 --- a/tests/index_orderby.cc +++ b/tests/index_orderby.cc @@ -10,12 +10,6 @@ #include "grib_api.h" -void usage(char* prog) -{ - printf("usage: %s infile\n", prog); - exit(1); -} - int main(int argc, char* argv[]) { grib_index* index = NULL; @@ -27,7 +21,7 @@ int main(int argc, char* argv[]) size_t lenshortName = 200; int ret = 0, count = 0; - if (argc != 2) usage(argv[0]); + if (argc != 2) return 1; infile = argv[1]; outfile = argv[2]; diff --git a/tests/julian.cc b/tests/julian.cc index 318429e79..559d9883a 100644 --- a/tests/julian.cc +++ b/tests/julian.cc @@ -14,18 +14,14 @@ #define EPSILON 1e-12 #define DBL_EQUAL(a, b) (fabs((a) - (b)) <= (EPSILON)*fabs((a))) -#define BOOL int -#define TRUE 1 -#define FALSE 0 - -static BOOL Check( +static bool Check( const long year1, const long month1, const long day1, const long hour1, const long min1, const long sec1, const long year2, const long month2, const long day2, const long hour2, const long min2, const long sec2) { if (year1 != year2 || month1 != month2 || day1 != day2 || hour1 != hour2 || min1 != min2 || sec1 != sec2) { - return FALSE; + return false; } - return TRUE; + return true; } static void TestDateTime(const long year, const long month, const long day, const long hour, const long min, const long sec) @@ -184,6 +180,7 @@ static void Test3() static void Test4() { const long iyear = 1582; + printf("Test4...\n"); TestDateTime(iyear, 9, 1, 1, 0, 0); TestDateTime(iyear, 9, 2, 1, 0, 0); @@ -215,6 +212,24 @@ static void Test4() */ } +static void Test5() +{ + printf("Test5...\n"); + + // Also see function is_date_valid() + + double jd = 0.0; + long year=2017, month=2, day=29, hour=0, min=0, sec=0; // Feb 2017 had 28 days + long year1, month1, day1, hour1, min1, sec1; + + codes_datetime_to_julian(year, month, day, hour, min, sec, &jd); + codes_julian_to_datetime(jd, &year1, &month1, &day1, &hour1, &min1, &sec1); + + if (Check(year, month, day, hour, min, sec, year1, month1, day1, hour1, min1, sec1)) { + Assert(!"Bad input should have failed checks"); + } +} + int main(int argc, char* argv[]) { Test0(); @@ -222,6 +237,7 @@ int main(int argc, char* argv[]) Test2(); Test3(); Test4(); + Test5(); printf("All OK\n"); return 0; } diff --git a/tests/largefile.cc b/tests/largefile.cc index a09d84be4..51e77949b 100644 --- a/tests/largefile.cc +++ b/tests/largefile.cc @@ -14,12 +14,6 @@ #include #endif -void usage(const char* prog) -{ - printf("usage: %s filename\n", prog); - exit(1); -} - int main(int argc, char* argv[]) { off_t offsetin = 0, offsetout = 0; @@ -30,7 +24,7 @@ int main(int argc, char* argv[]) char str[10]; int i; - if (argc != 2) usage(argv[0]); + if (argc != 2) return 1; printf("sizeof(off_t)=%zu sizeof(long)=%zu\n", sizeof(off_t), sizeof(long)); diff --git a/tests/list_all_keys.sh b/tests/list_all_keys.sh index 573d166d6..78ee26631 100755 --- a/tests/list_all_keys.sh +++ b/tests/list_all_keys.sh @@ -32,7 +32,7 @@ cat >keys <> keys diff --git a/tests/pseudo_budg.sh b/tests/pseudo_budg.sh index 4c50789d8..9c793a718 100755 --- a/tests/pseudo_budg.sh +++ b/tests/pseudo_budg.sh @@ -17,6 +17,9 @@ tempOut=temp.$label.txt tempRef=temp.$label.ref tempBud=temp.$label.bud +# Abort if any error messages are posted +export ECCODES_FAIL_IF_LOG_MESSAGE=1 + ${tools_dir}/grib_ls -j ${data_dir}/budg > $tempOut cat > $tempRef << EOF { "messages" : [ diff --git a/tests/pseudo_diag.sh b/tests/pseudo_diag.sh index 50208a45e..af45d6aea 100755 --- a/tests/pseudo_diag.sh +++ b/tests/pseudo_diag.sh @@ -20,6 +20,9 @@ REDIRECT=/dev/null sample=$ECCODES_SAMPLES_PATH/diag.tmpl +# Abort if any error messages are posted +export ECCODES_FAIL_IF_LOG_MESSAGE=1 + # Basic grib commands should not fail # ------------------------------------ ${tools_dir}/grib_ls $sample > $REDIRECT diff --git a/tests/read_any.cc b/tests/read_any.cc index f340aede9..98f1d450f 100644 --- a/tests/read_any.cc +++ b/tests/read_any.cc @@ -9,12 +9,6 @@ */ #include "grib_api.h" -static void usage(const char* prog) -{ - printf("usage: %s infile\n", prog); - exit(1); -} - static unsigned char buffer[50000000]; int main(int argc, char* argv[]) @@ -35,7 +29,7 @@ int main(int argc, char* argv[]) size_t len; if (argc != 2) - usage(argv[0]); + return 1; filename = argv[1]; f = fopen(filename, "rb"); diff --git a/tests/unit_tests.cc b/tests/unit_tests.cc index 539b03873..d5e228124 100644 --- a/tests/unit_tests.cc +++ b/tests/unit_tests.cc @@ -41,12 +41,23 @@ static void check_float_representation(const double val, const double expected, compare_doubles(out, expected, tolerance); } +static void test_get_package_name() +{ + printf("Running %s ...\n", __func__); + + const char* pn = codes_get_package_name(); + Assert(pn != NULL); + Assert(strlen(pn) > 1); + printf("Package name = %s\n", pn); +} + static void test_get_git_sha1() { printf("Running %s ...\n", __func__); - const char* sha1 = grib_get_git_sha1(); + const char* sha1 = codes_get_git_sha1(); Assert(sha1 != NULL); + printf("Git SHA1 = %s\n", sha1); } static void test_get_build_date() @@ -645,12 +656,13 @@ void test_codes_get_product_name() Assert( STR_EQUAL("BUFR", codes_get_product_name(PRODUCT_BUFR)) ); Assert( STR_EQUAL("GTS", codes_get_product_name(PRODUCT_GTS)) ); Assert( STR_EQUAL("METAR", codes_get_product_name(PRODUCT_METAR)) ); + Assert( STR_EQUAL("TAF", codes_get_product_name(PRODUCT_TAF)) ); } void test_codes_get_type_name() { printf("Running %s ...\n", __func__); - Assert( STR_EQUAL("long", grib_get_type_name(GRIB_TYPE_LONG)) ); + Assert( STR_EQUAL("long", codes_get_type_name(GRIB_TYPE_LONG)) ); Assert( STR_EQUAL("string", grib_get_type_name(GRIB_TYPE_STRING)) ); Assert( STR_EQUAL("double", grib_get_type_name(GRIB_TYPE_DOUBLE)) ); Assert( STR_EQUAL("bytes", grib_get_type_name(GRIB_TYPE_BYTES)) ); @@ -667,7 +679,7 @@ void test_grib2_select_PDTN() int chemical_srcsink = 1; int chemical_distfn = 1; int aerosol = 1; - //int aerosol_optical = 1; + int aerosol_optical = 1; // arguments = eps instant chemical chemical_srcsink chemical_distfn aerosol aerosol_optical @@ -678,19 +690,29 @@ void test_grib2_select_PDTN() Assert( 43 == grib2_select_PDTN(eps, !instant, chemical, 0, 0, 0, 0) ); // Chemical source/sink - Assert( 76 == grib2_select_PDTN(!eps, instant, !chemical, chemical_srcsink,0,0,0) ); - Assert( 77 == grib2_select_PDTN(eps, instant, !chemical, chemical_srcsink,0,0,0) ); - Assert( 78 == grib2_select_PDTN(!eps, !instant, !chemical, chemical_srcsink,0,0,0) ); - Assert( 79 == grib2_select_PDTN(eps, !instant, !chemical, chemical_srcsink,0,0,0) ); + Assert( 76 == grib2_select_PDTN(!eps, instant, !chemical, chemical_srcsink, 0,0,0) ); + Assert( 77 == grib2_select_PDTN(eps, instant, !chemical, chemical_srcsink, 0,0,0) ); + Assert( 78 == grib2_select_PDTN(!eps, !instant, !chemical, chemical_srcsink, 0,0,0) ); + Assert( 79 == grib2_select_PDTN(eps, !instant, !chemical, chemical_srcsink, 0,0,0) ); + + // Chemical distrib. function + Assert( 58 == grib2_select_PDTN(eps, instant, 0, 0, chemical_distfn, 0, 0) ); + Assert( 68 == grib2_select_PDTN(eps, !instant, 0, 0, chemical_distfn, 0, 0) ); + Assert( 57 == grib2_select_PDTN(!eps, instant, 0, 0, chemical_distfn, 0, 0) ); + Assert( 67 == grib2_select_PDTN(!eps, !instant, 0, 0, chemical_distfn, 0, 0) ); // Aerosols - Assert( 48 == grib2_select_PDTN(!eps, instant, !chemical, !chemical_srcsink, !chemical_distfn, aerosol, 0) ); - Assert( 46 == grib2_select_PDTN(!eps, !instant, !chemical, !chemical_srcsink, !chemical_distfn, aerosol, 0) ); - Assert( 45 == grib2_select_PDTN(eps, instant, !chemical, !chemical_srcsink, !chemical_distfn, aerosol, 0) ); - Assert( 85 == grib2_select_PDTN(eps, !instant, !chemical, !chemical_srcsink, !chemical_distfn, aerosol, 0) ); + Assert( 48 == grib2_select_PDTN(!eps, instant, 0, 0, 0, aerosol, 0) ); + Assert( 46 == grib2_select_PDTN(!eps, !instant, 0, 0, 0, aerosol, 0) ); + Assert( 45 == grib2_select_PDTN(eps, instant, 0, 0, 0, aerosol, 0) ); + Assert( 85 == grib2_select_PDTN(eps, !instant, 0, 0, 0, aerosol, 0) ); + + // Aerosol optical + Assert( 49 == grib2_select_PDTN(eps, instant, 0, 0, 0, 0, aerosol_optical) ); + Assert( 48 == grib2_select_PDTN(!eps, instant, 0, 0, 0, 0, aerosol_optical) ); // Plain vanilla - Assert( 0 == grib2_select_PDTN(!eps, instant, !chemical, !chemical_srcsink, !chemical_distfn, !aerosol,0) ); + Assert( 0 == grib2_select_PDTN(!eps, instant, !chemical, !chemical_srcsink, !chemical_distfn, !aerosol, 0) ); Assert( 1 == grib2_select_PDTN(1,1,0,0,0, !aerosol,0) ); Assert( 8 == grib2_select_PDTN(0,0,0,0,0, !aerosol,0) ); Assert( 11 == grib2_select_PDTN(1,0,0,0,0, !aerosol,0) ); @@ -728,6 +750,7 @@ int main(int argc, char** argv) test_parse_keyval_string(); test_get_git_sha1(); + test_get_package_name(); test_get_build_date(); test_gribex_mode(); test_gts_header_mode(); diff --git a/tools/big2gribex.cc b/tools/big2gribex.cc index a36b01126..c2797a821 100644 --- a/tools/big2gribex.cc +++ b/tools/big2gribex.cc @@ -8,18 +8,16 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/* - * Implementation: big2gribex - * - * Description: - * - */ - #include #include #include "grib_api.h" -void usage(char*); + +static void usage(const char* progname) +{ + printf("\nUsage: %s grib_in grib_out\n", progname); + exit(1); +} int main(int argc, char* argv[]) { @@ -70,12 +68,5 @@ int main(int argc, char* argv[]) exit(1); } - return 0; } - -void usage(char* progname) -{ - printf("\nUsage: %s grib_in grib_out\n", progname); - exit(1); -} diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc index c6714fedb..325c67cd3 100644 --- a/tools/bufr_compare.cc +++ b/tools/bufr_compare.cc @@ -26,7 +26,7 @@ grib_option grib_options[] = { { "A:", 0, 0, 0, 1, 0 }, { "t:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -R -A.\n", 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "f", 0, 0, 0, 1, 0 }, + { "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, { "q", 0, 0, 1, 0, 0 }, { "M", 0, 0, 1, 0, 0 }, @@ -84,7 +84,6 @@ static int compare_attribute(grib_handle* handle1, grib_handle* handle2, grib_ru static int error = 0; static int count = 0; -static int lastPrint = 0; static int force = 0; /* ECC-651: Boolean 'two_way' set to 1 when '-2' option used */ @@ -236,7 +235,7 @@ int grib_tool_before_getopt(grib_runtime_options* options) int grib_tool_init(grib_runtime_options* options) { - int ret = 0, i; + int ret = 0; grib_context* context = grib_context_get_default(); options->strict = 1; @@ -315,16 +314,6 @@ int grib_tool_init(grib_runtime_options* options) compare_double = &compare_double_absolute; if (grib_options_on("R:")) { global_tolerance = 0; - for (i = 0; i < options->tolerance_count; i++) { - if (!strcmp((options->tolerance[i]).name, "all")) { - global_tolerance = (options->tolerance[i]).double_value; - break; - } - if (!strcmp((options->tolerance[i]).name, "global")) { - global_tolerance = (options->tolerance[i]).double_value; - break; - } - } compare_double = &compare_double_relative; compareAbsolute = 0; } @@ -342,9 +331,9 @@ int grib_tool_init(grib_runtime_options* options) tolerance_factor = atof(grib_options_get_option("t:")); if (grib_options_on("R:")) { - char* sarg = grib_options_get_option("R:"); + char* sarg = grib_options_get_option("R:"); options->tolerance_count = MAX_KEYS; - ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); + ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); if (ret == GRIB_INVALID_ARGUMENT) { usage(); exit(1); @@ -389,7 +378,6 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi static void printInfo(grib_handle* h) { printf("== %d == DIFFERENCE == ", count); - lastPrint = count; } static void print_index_key_values(grib_index* index, int icounter, const char* error_message) @@ -771,11 +759,10 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g return GRIB_COUNT_MISMATCH; } */ - if (options->mode != MODE_BUFR) { + Assert(options->mode == MODE_BUFR); /* TODO: Ignore missing values for keys in BUFR. Not yet implemented */ //isMissing1 = ((grib_is_missing(handle1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0; //isMissing2 = ((grib_is_missing(handle2, name, &err2) == 1) && (err2 == 0)) ? 1 : 0; - } if ((isMissing1 == 1) && (isMissing2 == 1)) { // if (verbose) printf(" is set to missing in both fields\n"); @@ -1081,16 +1068,14 @@ static int compare_values(grib_runtime_options* options, grib_handle* handle1, g break; case GRIB_TYPE_BYTES: - if (options->mode == MODE_BUFR) - return 0; + return 0; // Not in BUFR break; case GRIB_TYPE_LABEL: break; default: - if (verbose) - printf("\n"); + if (verbose) printf("\n"); printInfo(handle1); save_error(c, name); printf("Cannot compare [%s], unsupported type %d\n", name, type1); @@ -1272,10 +1257,9 @@ static int compare_handles(grib_handle* handle1, grib_handle* handle2, grib_runt else { const void *msg1 = NULL, *msg2 = NULL; size_t size1 = 0, size2 = 0; - int memcmp_ret = 0; GRIB_CHECK_NOLINE(grib_get_message(handle1, &msg1, &size1), 0); GRIB_CHECK_NOLINE(grib_get_message(handle2, &msg2, &size2), 0); - if (size1 == size2 && !(memcmp_ret = memcmp(msg1, msg2, size1))) { + if (size1 == size2 && 0 == memcmp(msg1, msg2, size1)) { return 0; } #if defined(BUFR_COMPARE_BYTES) diff --git a/tools/bufr_dump.cc b/tools/bufr_dump.cc index ae4c485cc..6c31ce76e 100644 --- a/tools/bufr_dump.cc +++ b/tools/bufr_dump.cc @@ -9,6 +9,7 @@ */ #include "grib_tools.h" +#include "accessor/grib_accessor_class_bufr_data_array.h" grib_option grib_options[] = { /* {id, args, help}, on, command_line, value*/ diff --git a/tools/bufr_ls.cc b/tools/bufr_ls.cc index c57114617..b3ebaf531 100644 --- a/tools/bufr_ls.cc +++ b/tools/bufr_ls.cc @@ -17,7 +17,7 @@ grib_option grib_options[] = { { "F:", 0, 0, 1, 1, "%g" }, { "P:", 0, 0, 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "j", 0, "JSON output\n", 0, 1, 0 }, + { "j", 0, "JSON output.\n", 0, 1, 0 }, /* {"B:",0,0,0,1,0}, */ { "s:", 0, 0, 0, 1, 0 }, { "n:", 0, 0, 1, 1, "ls" }, diff --git a/tools/codes_export_resource.cc b/tools/codes_export_resource.cc index f2d484fbb..98ba7712d 100644 --- a/tools/codes_export_resource.cc +++ b/tools/codes_export_resource.cc @@ -24,6 +24,7 @@ static void usage(const char* prog) printf(" -d Extract a resource from the definitions directory\n"); printf("\n"); printf(" E.g., %s -s GRIB2.tmpl my.grib2\n", prog); + printf(" E.g., %s -d grib2/boot.def grib2_boot.txt\n", prog); exit(1); } @@ -57,53 +58,60 @@ int main(int argc, char* argv[]) resource_name = "definition"; } else { - fprintf(stderr, "Invalid option: Specify either -s or -d\n"); + fprintf(stderr, "Error: Invalid option: Specify either -s or -d\n"); return 1; } if (resource_type == SAMPLE) { - full_path = get_external_template_path(c, resource_path); + full_path = get_external_sample_path(c, resource_path); } else if (resource_type == DEFINITION) { full_path = grib_context_full_defs_path(c, resource_path); } if (!full_path) { - fprintf(stderr, "Failed to access %s: '%s'\n", resource_name, resource_path); + fprintf(stderr, "Error: Failed to access %s file: '%s'\n", resource_name, resource_path); return 1; } fout = fopen(out_file, "wb"); if (!fout) { - fprintf(stderr, "Failed to open output file '%s'\n", out_file); + fprintf(stderr, "Error: Failed to open output file '%s'\n", out_file); perror(out_file); return 1; } fin = codes_fopen(full_path, "r"); if (!fin) { - fprintf(stderr, "Failed to open resource '%s'\n", full_path); + fprintf(stderr, "Error: Failed to open resource '%s'\n", full_path); fclose(fout); return 1; } + /* write resource bytes to fout */ + int read_count = 0; while (0 < (bytes = fread(buffer, 1, sizeof(buffer), fin))) { if (fwrite(buffer, 1, bytes, fout) != bytes) { - fprintf(stderr, "Failed to write out bytes\n"); + fprintf(stderr, "Error: Failed to write out bytes\n"); return 1; } + ++read_count; } if (fclose(fin) != 0) { - fprintf(stderr, "Call to fclose failed (input)\n"); + fprintf(stderr, "Error: Call to fclose failed (input)\n"); return 1; } if (fclose(fout) != 0) { - fprintf(stderr, "Call to fclose failed (output)\n"); + fprintf(stderr, "Error: Call to fclose failed (output)\n"); return 1; } grib_context_free(c, full_path); - printf("Resource exported to file '%s'.\n", out_file); + if (read_count == 0) { + fprintf(stderr, "Error: Number of bytes read == 0. Please check the path refers to a file.\n"); + } else { + printf("Resource exported to file '%s'.\n", out_file); + } return 0; } diff --git a/tools/codes_info.cc b/tools/codes_info.cc index a351ec34e..a73dcde14 100644 --- a/tools/codes_info.cc +++ b/tools/codes_info.cc @@ -136,8 +136,8 @@ int main(int argc, char* argv[]) "It is recommended you use ECCODES_SAMPLES_PATH instead!)\n"); } else { - printf("Default SAMPLES path is used: %s\n", context->grib_samples_path); - printf("SAMPLES path can be changed by setting the ECCODES_SAMPLES_PATH environment variable.\n"); + printf("Default samples path is used: %s\n", context->grib_samples_path); + printf("Samples path can be changed by setting the ECCODES_SAMPLES_PATH environment variable.\n"); } if ((path = getenv("ECCODES_EXTRA_SAMPLES_PATH")) != NULL) { printf("Environment variable ECCODES_EXTRA_SAMPLES_PATH=%s\n", path); diff --git a/tools/bufr_3to4.cc b/tools/deprecated/bufr_3to4.cc similarity index 100% rename from tools/bufr_3to4.cc rename to tools/deprecated/bufr_3to4.cc diff --git a/tools/mars_request.cc b/tools/deprecated/mars_request.cc similarity index 100% rename from tools/mars_request.cc rename to tools/deprecated/mars_request.cc diff --git a/tools/grib2ppm.cc b/tools/grib2ppm.cc index cac306481..820178789 100644 --- a/tools/grib2ppm.cc +++ b/tools/grib2ppm.cc @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) continue; } - f = fopen(argv[i], "r"); + f = fopen(argv[i], "rb"); if (!f) { perror(argv[i]); exit(1); @@ -226,7 +226,9 @@ int main(int argc, char* argv[]) if (v > ucap) { v = ucap; } - c = (v - min) * 65535 / (max - min); + double denom = 1; + if (max != min) denom = max - min; + c = (v - min) * 65535 / denom; hh = c >> 8; l = c & 0xff; printf("%c", hh); diff --git a/tools/grib_check_gaussian_grid.cc b/tools/grib_check_gaussian_grid.cc index ce944fa28..9c0e8ab2a 100644 --- a/tools/grib_check_gaussian_grid.cc +++ b/tools/grib_check_gaussian_grid.cc @@ -227,7 +227,8 @@ static int process_file(const char* filename) } if (fabs(lon2 - expected_lon2) > angular_tolerance) { - error(filename, msg_num, "longitudeOfLastGridPointInDegrees=%f but should be %f\n", lon2, expected_lon2); + error(filename, msg_num, "longitudeOfLastGridPointInDegrees=%f but should be %f (= 360 - 360/max(pl) )\n", + lon2, expected_lon2); } GRIB_CHECK(grib_get_size(h, "values", &sizeOfValuesArray), 0); diff --git a/tools/grib_compare.cc b/tools/grib_compare.cc index e70119d6d..ba86c1a1f 100644 --- a/tools/grib_compare.cc +++ b/tools/grib_compare.cc @@ -27,7 +27,7 @@ grib_option grib_options[] = { { "P", 0, "Compare data values using the packing error as tolerance.\n", 0, 1, 0 }, { "T:", "factor", "Compare data values using factor multiplied by the tolerance specified in options -P -R -A.\n", 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "f", 0, 0, 0, 1, 0 }, + { "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, { "q", 0, 0, 1, 0, 0 }, { "M", 0, 0, 1, 0, 0 }, @@ -330,18 +330,7 @@ int grib_tool_init(grib_runtime_options* options) global_tolerance = 0; compare_double = &compare_double_absolute; if (grib_options_on("R:")) { - int i; global_tolerance = 0; - for (i = 0; i < options->tolerance_count; i++) { - if (!strcmp((options->tolerance[i]).name, "all")) { - global_tolerance = (options->tolerance[i]).double_value; - break; - } - if (!strcmp((options->tolerance[i]).name, "global")) { - global_tolerance = (options->tolerance[i]).double_value; - break; - } - } compare_double = &compare_double_relative; compareAbsolute = 0; } @@ -374,9 +363,9 @@ int grib_tool_init(grib_runtime_options* options) tolerance_factor = atof(grib_options_get_option("T:")); if (grib_options_on("R:")) { - char* sarg = grib_options_get_option("R:"); + char* sarg = grib_options_get_option("R:"); options->tolerance_count = MAX_KEYS; - ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); + ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); if (ret == GRIB_INVALID_ARGUMENT) { usage(); exit(1); @@ -1212,8 +1201,9 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option grib_handle *h11, *h22; GRIB_CHECK_NOLINE(grib_get_message_headers(h1, &msg1, &size1), 0); GRIB_CHECK_NOLINE(grib_get_message_headers(h2, &msg2, &size2), 0); - if (size1 == size2 && !memcmp(msg1, msg2, size1)) + if ( size1 == size2 && (0 == memcmp(msg1, msg2, size1)) ) { return 0; + } err = 0; h11 = grib_handle_new_from_partial_message(h1->context, msg1, size1); @@ -1279,8 +1269,9 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option size_t size1 = 0, size2 = 0; GRIB_CHECK_NOLINE(grib_get_message(h1, &msg1, &size1), 0); GRIB_CHECK_NOLINE(grib_get_message(h2, &msg2, &size2), 0); - if (size1 == size2 && !memcmp(msg1, msg2, size1)) + if ( size1 == size2 && (0 == memcmp(msg1, msg2, size1)) ) { return 0; + } iter = grib_keys_iterator_new(h1, GRIB_KEYS_ITERATOR_SKIP_COMPUTED, NULL); if (!iter) { diff --git a/tools/grib_histogram.cc b/tools/grib_histogram.cc index 90a7e8532..6c84da43a 100644 --- a/tools/grib_histogram.cc +++ b/tools/grib_histogram.cc @@ -62,7 +62,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) size_t last_size = 0; long missingValuesPresent; double delta; - int err = 0; double* values = NULL; size_t size; @@ -76,14 +75,6 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h) names[name_count++] = options->requested_print_keys[i].name; } - if (!options->skip) { - if (options->set_values_count != 0) - err = grib_set_values(h, options->set_values, options->set_values_count); - - if (err != GRIB_SUCCESS && options->fail) - exit(err); - } - GRIB_CHECK(grib_get_long(h, "missingValuesPresent", &missingValuesPresent), 0); GRIB_CHECK(grib_get_size(h, "values", &size), 0); diff --git a/tools/grib_ls.cc b/tools/grib_ls.cc index 59f25306b..c5d06df01 100644 --- a/tools/grib_ls.cc +++ b/tools/grib_ls.cc @@ -17,7 +17,7 @@ grib_option grib_options[] = { { "F:", 0, 0, 1, 1, "%g" }, { "P:", 0, 0, 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "j", 0, "JSON output\n", 0, 1, 0 }, + { "j", 0, "JSON output.\n", 0, 1, 0 }, { "B:", 0, 0, 0, 1, 0 }, { "l:", 0, 0, 0, 1, 0 }, { "s:", 0, 0, 0, 1, 0 }, diff --git a/tools/grib_options.cc b/tools/grib_options.cc index f9ef49400..b612db63a 100644 --- a/tools/grib_options.cc +++ b/tools/grib_options.cc @@ -39,7 +39,7 @@ static grib_options_help grib_options_help_list[] = { { "e:", "tolerance", "\n\t\tOnly values whose difference is more than tolerance are considered different.\n" }, { "f", 0, "Force. Force the execution not to fail on error.\n" }, { "F:", "format", "\n\t\tC style format for floating-point values.\n" }, - { "g", 0, "Copy GTS header. \n" }, + { "g", 0, "Copy GTS header.\n" }, { "G", 0, "GRIBEX compatibility mode.\n" }, { "i:", "index", "\n\t\tData value corresponding to the given index is printed.\n" }, @@ -81,7 +81,7 @@ static grib_options_help grib_options_help_list[] = { "\n\t\tIn the value you can also use the forward-slash character '/' to specify an OR condition (i.e. a logical disjunction)" "\n\t\tNote: only one -w clause is allowed.\n" }, { "v", 0, "Verbose.\n" }, - { "7", 0, "Does not fail when the message has wrong length\n" }, + { "7", 0, "Does not fail when the message has wrong length.\n" }, { "A:", "absolute error\n", "\tCompare floating-point values using the absolute error as tolerance.\n\t\tDefault is absolute error=0\n" }, { "C", 0, "C code mode. A C code program generating the message is dumped.\n" }, @@ -98,7 +98,7 @@ static grib_options_help grib_options_help_list[] = { { "S", 0, "Strict. Only messages matching all the constraints are copied to" "\n\t\tthe output file\n" }, - { "T:", "T | B | M | A", "Message type. T->GTS, B->BUFR, M->METAR (Experimental), A->Any (Experimental).\n\t\t\t\tThe input file is interpreted according to the message type.\n" }, + { "T:", "T | B | A", "Message type. T->GTS, B->BUFR, A->Any (Experimental).\n\t\t\tThe input file is interpreted according to the message type.\n" }, { "V", 0, "Version.\n" }, { "W:", "width", "\n\t\tMinimum width of each column in output. Default is 10.\n" }, { "X:", "offset", "\n\t\tInput file offset in bytes. Processing of the input file will start from the given offset.\n" }, @@ -139,7 +139,7 @@ char* grib_options_get_option(const char* id) int i = 0; for (i = 0; i < grib_options_count; i++) { if (!strcmp(id, grib_options[i].id)) - return grib_options[i].value; + return (char*)grib_options[i].value; } return NULL; } @@ -357,12 +357,6 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g else grib_gts_header_off(context); - if (grib_options_on("V")) { - printf("\necCodes Version "); - grib_print_api_version(stdout); - printf("\n\n"); - } - if (grib_options_on("s:")) { sarg = grib_options_get_option("s:"); options->set_values_count = MAX_KEYS; diff --git a/tools/grib_to_netcdf.cc b/tools/grib_to_netcdf.cc index c1e09d7cc..0dad044ab 100644 --- a/tools/grib_to_netcdf.cc +++ b/tools/grib_to_netcdf.cc @@ -4225,7 +4225,15 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil grib_handle_delete(h); } - grib_file_close(file->name, 0, &e); + if (e != GRIB_SUCCESS) { + grib_context_log(ctx, GRIB_LOG_ERROR, "%s (message %d)", grib_get_error_message(e), i); + } + + int e2 = 0; + grib_file_close(file->name, 0, &e2); + if (e2 != GRIB_SUCCESS) { + grib_context_log(ctx, GRIB_LOG_ERROR, "Failed to close file %s (%s)", file->name, grib_get_error_message(e2)); + } { /* Now do some checks */ diff --git a/tools/grib_tools.cc b/tools/grib_tools.cc index 2124bc0ab..976f712be 100644 --- a/tools/grib_tools.cc +++ b/tools/grib_tools.cc @@ -10,6 +10,7 @@ #include "grib_tools.h" #include +#include #if HAVE_LIBJASPER /* Remove compiler warnings re macros being redefined */ @@ -76,7 +77,6 @@ static grib_runtime_options global_options = { 0, /* grib_tools_file* infile */ 0, /* grib_tools_file* outfile */ 0, /* grib_action* action */ - 0, /* grib_rule* rules */ 0, /* int dump_flags; */ 0, /* char* dump_mode; */ 0, /* repack */ @@ -308,6 +308,29 @@ static int grib_tool_with_orderby(grib_runtime_options* options) static char iobuf[1024 * 1024]; +// Read the first few bytes of the file to guess what kind of product +// it could be. Returns an empty string if it fails +static std::string guess_file_product(const std::string& filename) +{ + std::string result; + char buffer[5] = {0,}; + FILE* fin = fopen(filename.c_str(), "rb"); + if (fin) { + size_t bytes = fread(buffer, 1, sizeof(buffer), fin); + if (bytes == sizeof(buffer)) { + if (strncmp(buffer, "GRIB", 4)==0) { + result = "GRIB"; + } else if (strncmp(buffer, "BUDG", 4)==0) { + result = "GRIB"; + } else if (strncmp(buffer, "BUFR", 4)==0) { + result = "BUFR"; + } + } + fclose(fin); + } + return result; +} + static int grib_tool_without_orderby(grib_runtime_options* options) { int err = 0; @@ -419,6 +442,10 @@ static int grib_tool_without_orderby(grib_runtime_options* options) if (infile->handle_count == 0) { fprintf(stderr, "%s: No messages found in %s\n", tool_name, infile->name); + std::string product = guess_file_product(infile->name); + if (!product.empty()) { + fprintf(stderr, "%s: Input file seems to be %s\n", tool_name, product.c_str()); + } if (options->fail) exit(1); } @@ -1312,16 +1339,15 @@ void grib_print_file_statistics(grib_runtime_options* options, grib_tools_file* file->name); if (!failed) return; - /* - fprintf(dump_file,"Following bad messages found in %s\n", file->name); - fprintf(dump_file,"N Error\n"); - while (failed){ - fprintf(dump_file,"%-*d %s\n", 7,failed->count, - grib_get_error_message(failed->error)); - failed=failed->next; - } - fprintf(dump_file,"\n"); - */ + + // fprintf(dump_file,"Following bad messages found in %s\n", file->name); + // fprintf(dump_file,"N Error\n"); + // while (failed){ + // fprintf(dump_file,"%-*d %s\n", 7,failed->count, + // grib_get_error_message(failed->error)); + // failed=failed->next; + // } + // fprintf(dump_file,"\n"); } void grib_print_full_statistics(grib_runtime_options* options) @@ -1395,7 +1421,7 @@ void grib_tools_write_message(grib_runtime_options* options, grib_handle* h) } if (options->gts && h->gts_header) { - char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' }; + const char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' }; if (fwrite(gts_trailer, 1, 4, of->handle) != 4) { grib_context_log(h->context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), "Error writing GTS trailer to %s", filename); diff --git a/tools/grib_tools.h b/tools/grib_tools.h index 34465b628..700d91027 100644 --- a/tools/grib_tools.h +++ b/tools/grib_tools.h @@ -83,7 +83,7 @@ typedef struct grib_option const char* help; int on; int command_line; - char* value; + const char* value; } grib_option; typedef struct grib_failed grib_failed; @@ -137,7 +137,6 @@ typedef struct grib_runtime_options grib_tools_file* infile; grib_tools_file* outfile; grib_action* action; - grib_rule* rules; int dump_flags; char* dump_mode; int repack; diff --git a/tools/gts_compare.cc b/tools/gts_compare.cc index cedbfa4b6..3a084893d 100644 --- a/tools/gts_compare.cc +++ b/tools/gts_compare.cc @@ -23,7 +23,7 @@ grib_option grib_options[] = { /*{"R:",0,0,0,1,0},*/ /*{"A:",0,0,0,1,0},*/ { "w:", 0, 0, 0, 1, 0 }, - { "f", 0, 0, 0, 1, 0 }, + { "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, { "q", 0, 0, 1, 0, 0 }, { "I", 0, 0, 1, 0, 0 }, @@ -74,7 +74,6 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option int error = 0; int count = 0; -int lastPrint = 0; int force = 0; double maxAbsoluteError = 1e-19; int onlyListed = 1; @@ -184,7 +183,7 @@ int grib_tool_init(grib_runtime_options* options) onlyListed = 1; if (grib_options_on("a") && !grib_options_on("c:")) { - printf("Error: -a option requires -c option. Please define a list of keys with the -c option.\n"); + fprintf(stderr, "Error: -a option requires -c option. Please define a list of keys with the -c option.\n"); exit(1); } @@ -245,7 +244,6 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi static void printInfo(grib_handle* h) { printf("== %d == DIFFERENCE == ", count); - lastPrint = count; } static grib_handle* gts_handle_new_from_file_x( @@ -375,14 +373,11 @@ static void save_error(grib_context* c, const char* key) static int compare_values(const grib_runtime_options* options, grib_handle* h1, grib_handle* h2, const char* name, int type) { - size_t len1 = 0; - size_t len2 = 0; - int err = 0; - int err1; - int err2; + size_t len1 = 0, len2 = 0; + int err = 0, err1 = 0, err2 = 0; int type1, type2; int countdiff; - int isMissing1 = 0, isMissing2 = 0; + // int isMissing1 = 0, isMissing2 = 0; char *sval1 = NULL, *sval2 = NULL; long *lval1 = NULL, *lval2 = NULL; @@ -439,36 +434,10 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, save_error(c, name); return err; } - - //if (options->mode != MODE_GTS) { + Assert(options->mode == MODE_GTS); /* TODO: Ignore missing values for keys in GTS. Not yet implemented */ //isMissing1 = ((grib_is_missing(h1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0; //isMissing2 = ((grib_is_missing(h2, name, &err2) == 1) && (err2 == 0)) ? 1 : 0; - //} - - if ((isMissing1 == 1) && (isMissing2 == 1)) { - if (verbose) - printf(" is set to missing in both fields\n"); - return GRIB_SUCCESS; - } - - if (isMissing1 == 1) { - if (verbose) printf(" is set to missing in 1st field\n"); - printInfo(h1); - printf("%s is set to missing in 1st field but is not missing in 2nd field\n", name); - err1 = GRIB_VALUE_MISMATCH; - save_error(c, name); - return GRIB_VALUE_MISMATCH; - } - - if (isMissing2 == 1) { - if (verbose) printf(" is set to missing in 1st field\n"); - printInfo(h1); - printf("%s is set to missing in 2nd field but is not missing in 1st field\n", name); - err1 = GRIB_VALUE_MISMATCH; - save_error(c, name); - return GRIB_VALUE_MISMATCH; - } switch (type1) { case GRIB_TYPE_STRING: @@ -573,11 +542,8 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, break; case GRIB_TYPE_BYTES: - if (options->mode == MODE_GTS) { - // We do not want to compare the message itself - return 0; - } - break; + // We do not want to compare the message itself + return 0; case GRIB_TYPE_LABEL: break; @@ -586,15 +552,14 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, if (verbose) printf("\n"); printInfo(h1); save_error(c, name); - printf("Cannot compare [%s], unsupported type %d\n", name, type1); + fprintf(stderr, "Cannot compare [%s], unsupported type %d\n", name, type1); return GRIB_UNABLE_TO_COMPARE_ACCESSORS; - break; } return GRIB_SUCCESS; } -static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* err) +static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* pErr) { int ret = 0; const char* name = NULL; @@ -615,7 +580,7 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_ if (xa == NULL || (xa->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) continue; if (compare_values(options, h1, h2, name, GRIB_TYPE_UNDEFINED)) { - err++; + (*pErr)++; write_messages(h1, h2); ret = 1; } @@ -664,34 +629,13 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option else { const void *msg1 = NULL, *msg2 = NULL; size_t size1 = 0, size2 = 0; - int memcmp_ret = 0; /* int ii=0; */ GRIB_CHECK_NOLINE(grib_get_message(h1, &msg1, &size1), 0); GRIB_CHECK_NOLINE(grib_get_message(h2, &msg2, &size2), 0); - if (size1 == size2 && !(memcmp_ret = memcmp(msg1, msg2, size1))) { + if ( size1 == size2 && (0 == memcmp(msg1, msg2, size1)) ) { return 0; } -// else { -// int lcount=count,ii; -// if (options->current_infile) lcount=options->current_infile->filter_handle_count; -// if (size1 != size2) { -// printf("#%d different size: %d!=%d\n",lcount,(int)size1,(int)size2); -// } -// if (memcmp_ret) { -// unsigned char *m1=(unsigned char*)msg1; -// unsigned char *m2=(unsigned char*)msg2; -// printf("=== list of different bytes for message %d\n",lcount); -// for (ii=0;iicompare_count; i++) { if (blocklisted(name)) diff --git a/tools/metar_compare.cc b/tools/metar_compare.cc index 973794988..6ffc5db5a 100644 --- a/tools/metar_compare.cc +++ b/tools/metar_compare.cc @@ -16,13 +16,11 @@ grib_option grib_options[] = { { "d", 0, "Write different messages on files\n", 0, 1, 0 }, { "T:", 0, 0, 1, 0, "M" }, /* METAR */ { "c:", 0, 0, 0, 1, 0 }, - { "S:", "start", "First field to be processed.\n", 0, 1, 0 }, - { "E:", "end", "Last field to be processed.\n", 0, 1, 0 }, { "a", 0, "-c option modifier. The keys listed with the option -c will be added to the list of keys compared without -c.\n", 0, 1, 0 }, { "R:", 0, 0, 0, 1, 0 }, { "A:", 0, 0, 0, 1, 0 }, { "w:", 0, 0, 0, 1, 0 }, - { "f", 0, 0, 0, 1, 0 }, + { "f", 0, "Forcefully compare, do not stop after first difference.\n", 0, 1, 0 }, { "F", 0, 0, 1, 0, 0 }, { "q", 0, 0, 1, 0, 0 }, { "I", 0, 0, 1, 0, 0 }, @@ -74,7 +72,6 @@ static int compareAbsolute = 1; static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_options* options); static int error = 0; static int count = 0; -static int lastPrint = 0; static int force = 0; static double maxAbsoluteError = 1e-19; static int onlyListed = 1; @@ -85,8 +82,6 @@ static int verbose = 0; static double tolerance_factor = 1; static int write_error = 0; static grib_handle* global_handle = NULL; -static int start = -1; -static int end = -1; static int write_count = 0; GRIB_INLINE static double compare_double_absolute(const double* a, const double* b, const double* err) @@ -192,11 +187,6 @@ int grib_tool_init(grib_runtime_options* options) grib_context* context = grib_context_get_default(); options->strict = 1; - if (grib_options_on("S:")) - start = atoi(grib_options_get_option("S:")); - - if (grib_options_on("E:")) - end = atoi(grib_options_get_option("E:")); if (grib_options_on("f")) force = 1; @@ -249,16 +239,6 @@ int grib_tool_init(grib_runtime_options* options) compare_double = &compare_double_absolute; if (grib_options_on("R:")) { global_tolerance = 0; - for (int i = 0; i < options->tolerance_count; i++) { - if (!strcmp((options->tolerance[i]).name, "all")) { - global_tolerance = (options->tolerance[i]).double_value; - break; - } - if (!strcmp((options->tolerance[i]).name, "global")) { - global_tolerance = (options->tolerance[i]).double_value; - break; - } - } compare_double = &compare_double_relative; compareAbsolute = 0; } @@ -276,7 +256,7 @@ int grib_tool_init(grib_runtime_options* options) tolerance_factor = atof(grib_options_get_option("t:")); if (grib_options_on("R:")) { - char* sarg = grib_options_get_option("R:"); + char* sarg = grib_options_get_option("R:"); options->tolerance_count = MAX_KEYS; int err = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); if (err == GRIB_INVALID_ARGUMENT) { @@ -316,7 +296,6 @@ int grib_tool_new_file_action(grib_runtime_options* options, grib_tools_file* fi static void printInfo(grib_handle* h) { printf("== %d == DIFFERENCE == ", count); - lastPrint = count; } static grib_handle* metar_handle_new_from_file_x(grib_context* c, FILE* f, int mode, int headers_only, int* err) @@ -447,19 +426,17 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, { size_t len1 = 0; size_t len2 = 0; - int err = 0, i = 0; - int err1; - int err2; + int err = 0, i = 0, err1 = 0, err2 = 0; int type1, type2; int countdiff; - int isMissing1 = 0, isMissing2 = 0; + //int isMissing1 = 0, isMissing2 = 0; char *sval1 = NULL, *sval2 = NULL; double *dval1 = NULL, *dval2 = NULL; long *lval1 = NULL, *lval2 = NULL; - double maxdiff = 0; + double maxdiff = 0; double value_tolerance = 0; - grib_context* c = h1->context; + grib_context* c = h1->context; type1 = type; type2 = type; @@ -514,37 +491,10 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, return err; } - // if (options->mode != MODE_METAR) { + Assert(options->mode == MODE_METAR); // // TODO: Ignore missing values for keys in METAR. Not yet implemented // isMissing1 = ((grib_is_missing(h1, name, &err1) == 1) && (err1 == 0)) ? 1 : 0; // isMissing2 = ((grib_is_missing(h2, name, &err2) == 1) && (err2 == 0)) ? 1 : 0; - // } - - if ((isMissing1 == 1) && (isMissing2 == 1)) { - if (verbose) - printf(" is set to missing in both fields\n"); - return GRIB_SUCCESS; - } - - if (isMissing1 == 1) { - if (verbose) - printf(" is set to missing in 1st field\n"); - printInfo(h1); - printf("%s is set to missing in 1st field but is not missing in 2nd field\n", name); - err1 = GRIB_VALUE_MISMATCH; - save_error(c, name); - return GRIB_VALUE_MISMATCH; - } - - if (isMissing2 == 1) { - if (verbose) - printf(" is set to missing in 1st field\n"); - printInfo(h1); - printf("%s is set to missing in 2nd field but is not missing in 1st field\n", name); - err1 = GRIB_VALUE_MISMATCH; - save_error(c, name); - return GRIB_VALUE_MISMATCH; - } switch (type1) { case GRIB_TYPE_STRING: @@ -746,9 +696,7 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, break; case GRIB_TYPE_BYTES: - if (options->mode == MODE_METAR) - return 0; - break; + return 0; // No such type for METAR case GRIB_TYPE_LABEL: break; @@ -758,15 +706,14 @@ static int compare_values(const grib_runtime_options* options, grib_handle* h1, printf("\n"); printInfo(h1); save_error(c, name); - printf("Cannot compare [%s], unsupported type %d\n", name, type1); + fprintf(stderr, "Cannot compare [%s], unsupported type %d\n", name, type1); return GRIB_UNABLE_TO_COMPARE_ACCESSORS; - break; } return GRIB_SUCCESS; } -static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* err) +static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_options* options, int* pErr) { int ret = 0; const char* name = NULL; @@ -786,7 +733,7 @@ static int compare_all_dump_keys(grib_handle* h1, grib_handle* h2, grib_runtime_ if (xa == NULL || (xa->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) continue; if (compare_values(options, h1, h2, name, GRIB_TYPE_UNDEFINED)) { - err++; + (*pErr)++; write_messages(h1, h2); ret = 1; } @@ -835,10 +782,9 @@ static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_option else { const void *msg1 = NULL, *msg2 = NULL; size_t size1 = 0, size2 = 0; - int memcmp_ret = 0; GRIB_CHECK_NOLINE(grib_get_message(h1, &msg1, &size1), 0); GRIB_CHECK_NOLINE(grib_get_message(h2, &msg2, &size2), 0); - if (size1 == size2 && !(memcmp_ret = memcmp(msg1, msg2, size1))) { + if ( size1 == size2 && (0 == memcmp(msg1, msg2, size1)) ) { return 0; }