Step-by-step guide

There is a "-E" option in the bufr_dump tool to generate instructions to create (encode) the input BUFR message.  Its argument can be one of:

  • -Efilter  This generates the set of rules to be passed to the bufr_filter tool
  • -Efortran This generates a Fortran 90 program
  • -Epython  This generates a Python script
  • -EC       This generates a C program
  1. For compiled languages like C and Fortran, the user can then compile/link the generated program and run it to reproduce the input message. For filter and Python, the generated code can be used directly (either passed to bufr_filter or the Python interpreter)
  2. The user can then edit the generated code to tailor it to his/her own needs.

    Note: The generated code for bufr_filter only applies to a single BUFR message.  The other languages support encoding of multiple BUFR messages in a file.

  3. Example

    This is an example of BUFR synoptic surface observation (SYNOP):  synop.bufr


    ! This program was automatically generated with bufr_dump -Efortran
    ! Using ecCodes version: 2.0.0
    program bufr_encode
     use eccodes
     implicit none
     integer :: iret
     integer :: outfile
     integer :: ibufr
     integer(kind=4), dimension(:), allocatable :: ivalues
     integer, parameter :: max_strsize = 100
     character(len=max_strsize) , dimension(:),allocatable :: svalues
     real(kind=8), dimension(:), allocatable :: rvalues
     call codes_bufr_new_from_samples(ibufr,'BUFR4',iret)
     if (iret/=CODES_SUCCESS) then
     print *,'ERROR creating BUFR from BUFR4'
     stop 1
     endif
     if(allocated(ivalues)) deallocate(ivalues)
     allocate(ivalues(4))
     ivalues=(/ &
     0, 0, 1, 0 /)
     call codes_set(ibufr,'inputDelayedDescriptorReplicationFactor',ivalues)
     call codes_set(ibufr,'edition',4)
     call codes_set(ibufr,'masterTableNumber',0)
     call codes_set(ibufr,'bufrHeaderCentre',74)
     call codes_set(ibufr,'bufrHeaderSubCentre',0)
     call codes_set(ibufr,'updateSequenceNumber',0)
     call codes_set(ibufr,'dataCategory',0)
     call codes_set(ibufr,'internationalDataSubCategory',2)
     call codes_set(ibufr,'dataSubCategory',0)
     call codes_set(ibufr,'masterTablesVersionNumber',22)
     call codes_set(ibufr,'localTablesVersionNumber',0)
     call codes_set(ibufr,'typicalYear',2016)
     call codes_set(ibufr,'typicalMonth',9)
     call codes_set(ibufr,'typicalDay',29)
     call codes_set(ibufr,'typicalHour',12)
     call codes_set(ibufr,'typicalMinute',0)
     call codes_set(ibufr,'typicalSecond',0)
     call codes_set(ibufr,'numberOfSubsets',2)
     call codes_set(ibufr,'observedData',1)
     call codes_set(ibufr,'compressedData',0)
    
     ! Create the structure of the data section
     call codes_set(ibufr,'unexpandedDescriptors',307080)
     call codes_set(ibufr,'#1#blockNumber',89)
     call codes_set(ibufr,'#1#stationNumber',22)
     call codes_set(ibufr,'#1#stationOrSiteName','HALLEY')
     call codes_set(ibufr,'#1#stationType',1)
     call codes_set(ibufr,'#1#year',2016)
     call codes_set(ibufr,'#1#month',9)
     call codes_set(ibufr,'#1#day',29)
     call codes_set(ibufr,'#1#hour',12)
     call codes_set(ibufr,'#1#minute',0)
     call codes_set(ibufr,'#1#latitude',-7.553300000000000125d+01)
     call codes_set(ibufr,'#1#longitude',-2.663300000000000267d+01)
     call codes_set(ibufr,'#1#heightOfStationGroundAboveMeanSeaLevel',3.000000000000000000d+01)
     call codes_set(ibufr,'#1#heightOfBarometerAboveMeanSeaLevel',3.000000000000000000d+01)
     call codes_set(ibufr,'#1#nonCoordinatePressure',9.869000000000000000d+04)
     call codes_set(ibufr,'#1#pressureReducedToMeanSeaLevel',9.911000000000000000d+04)
     call codes_set(ibufr,'#1#3HourPressureChange',-2.400000000000000000d+02)
     call codes_set(ibufr,'#1#characteristicOfPressureTendency',7)
     call codes_set(ibufr,'#1#airTemperature',2.459500000000000171d+02)
     call codes_set(ibufr,'#1#dewpointTemperature',2.432500000000000000d+02)
     call codes_set(ibufr,'#1#horizontalVisibility',6.000000000000000000d+04)
     call codes_set(ibufr,'#1#cloudCoverTotal',0)
     call codes_set(ibufr,'#1#verticalSignificanceSurfaceObservations',62)
     call codes_set(ibufr,'#1#cloudAmount',0)
     call codes_set(ibufr,'#1#cloudType',30)
     call codes_set(ibufr,'#2#cloudType',20)
     call codes_set(ibufr,'#3#cloudType',10)
     call codes_set(ibufr,'#2#verticalSignificanceSurfaceObservations',7)
     call codes_set(ibufr,'#3#verticalSignificanceSurfaceObservations',8)
     call codes_set(ibufr,'#4#verticalSignificanceSurfaceObservations',9)
     call codes_set(ibufr,'#1#presentWeather',508)
     call codes_set(ibufr,'#1#timePeriod',-6)
     call codes_set(ibufr,'#1#pastWeather1',10)
     call codes_set(ibufr,'#1#pastWeather2',10)
     call codes_set(ibufr,'#2#timePeriod',-24)
     call codes_set(ibufr,'#3#timePeriod',-1)
     call codes_set(ibufr,'#4#timePeriod',-12)
     call codes_set(ibufr,'#5#timePeriod',-1)
     call codes_set(ibufr,'#6#timePeriod',-12)
     call codes_set(ibufr,'#7#timePeriod',0)
     call codes_set(ibufr,'#1#maximumTemperatureAtHeightAndOverPeriodSpecified',2.469500000000000171d+02)
     call codes_set(ibufr,'#8#timePeriod',-12)
     call codes_set(ibufr,'#9#timePeriod',0)
     call codes_set(ibufr,'#1#minimumTemperatureAtHeightAndOverPeriodSpecified',2.423499999999999943d+02)
     call codes_set(ibufr,'#1#instrumentationForWindMeasurement',12)
     call codes_set(ibufr,'#1#timeSignificance',2)
     call codes_set(ibufr,'#10#timePeriod',-10)
     call codes_set(ibufr,'#1#windDirection',190)
     call codes_set(ibufr,'#1#windSpeed',2.600000000000000089d+00)
     call codes_set(ibufr,'#11#timePeriod',-10)
     call codes_set(ibufr,'#12#timePeriod',-360)
     call codes_set(ibufr,'#13#timePeriod',-24)
     call codes_set(ibufr,'#14#timePeriod',-1)
     call codes_set(ibufr,'#15#timePeriod',-24)
     call codes_set(ibufr,'#2#blockNumber',89)
     call codes_set(ibufr,'#2#stationNumber',62)
     call codes_set(ibufr,'#2#stationOrSiteName','ROTHERA')
     call codes_set(ibufr,'#2#stationType',1)
     call codes_set(ibufr,'#2#year',2016)
     call codes_set(ibufr,'#2#month',9)
     call codes_set(ibufr,'#2#day',29)
     call codes_set(ibufr,'#2#hour',12)
     call codes_set(ibufr,'#2#minute',0)
     call codes_set(ibufr,'#2#latitude',-6.773300000000000409d+01)
     call codes_set(ibufr,'#2#longitude',-6.811700000000000443d+01)
     call codes_set(ibufr,'#2#heightOfStationGroundAboveMeanSeaLevel',1.600000000000000000d+01)
     call codes_set(ibufr,'#2#heightOfBarometerAboveMeanSeaLevel',1.600000000000000000d+01)
     call codes_set(ibufr,'#2#nonCoordinatePressure',9.887000000000000000d+04)
     call codes_set(ibufr,'#2#pressureReducedToMeanSeaLevel',9.928000000000000000d+04)
     call codes_set(ibufr,'#2#3HourPressureChange',3.000000000000000000d+02)
     call codes_set(ibufr,'#2#characteristicOfPressureTendency',2)
     call codes_set(ibufr,'#2#airTemperature',2.727500000000000000d+02)
     call codes_set(ibufr,'#2#dewpointTemperature',2.635500000000000114d+02)
     call codes_set(ibufr,'#2#horizontalVisibility',4.500000000000000000d+04)
     call codes_set(ibufr,'#2#cloudCoverTotal',100)
     call codes_set(ibufr,'#6#verticalSignificanceSurfaceObservations',7)
     call codes_set(ibufr,'#2#cloudAmount',8)
     call codes_set(ibufr,'#2#heightOfBaseOfCloud',1.200000000000000000d+03)
     call codes_set(ibufr,'#5#cloudType',36)
     call codes_set(ibufr,'#6#cloudType',61)
     call codes_set(ibufr,'#7#cloudType',60)
     call codes_set(ibufr,'#7#verticalSignificanceSurfaceObservations',1)
     call codes_set(ibufr,'#3#cloudAmount',8)
     call codes_set(ibufr,'#8#cloudType',7)
     call codes_set(ibufr,'#3#heightOfBaseOfCloud',1.200000000000000000d+03)
     call codes_set(ibufr,'#8#verticalSignificanceSurfaceObservations',7)
     call codes_set(ibufr,'#9#verticalSignificanceSurfaceObservations',8)
     call codes_set(ibufr,'#10#verticalSignificanceSurfaceObservations',9)
     call codes_set(ibufr,'#2#presentWeather',3)
     call codes_set(ibufr,'#18#timePeriod',-6)
     call codes_set(ibufr,'#2#pastWeather1',2)
     call codes_set(ibufr,'#2#pastWeather2',1)
     call codes_set(ibufr,'#19#timePeriod',-24)
     call codes_set(ibufr,'#20#timePeriod',-1)
     call codes_set(ibufr,'#21#timePeriod',-12)
     call codes_set(ibufr,'#22#timePeriod',-1)
     call codes_set(ibufr,'#23#timePeriod',-12)
     call codes_set(ibufr,'#24#timePeriod',0)
     call codes_set(ibufr,'#2#maximumTemperatureAtHeightAndOverPeriodSpecified',2.752500000000000000d+02)
     call codes_set(ibufr,'#25#timePeriod',-12)
     call codes_set(ibufr,'#26#timePeriod',0)
     call codes_set(ibufr,'#2#minimumTemperatureAtHeightAndOverPeriodSpecified',2.706499999999999773d+02)
     call codes_set(ibufr,'#2#instrumentationForWindMeasurement',12)
     call codes_set(ibufr,'#3#timeSignificance',2)
     call codes_set(ibufr,'#27#timePeriod',-10)
     call codes_set(ibufr,'#2#windDirection',320)
     call codes_set(ibufr,'#2#windSpeed',5.100000000000000533d+00)
     call codes_set(ibufr,'#28#timePeriod',-10)
     call codes_set(ibufr,'#29#timePeriod',-360)
     call codes_set(ibufr,'#30#timePeriod',-24)
     call codes_set(ibufr,'#31#timePeriod',-1)
     call codes_set(ibufr,'#32#timePeriod',-24)
     call codes_set(ibufr,'pack',1)
     call codes_open_file(outfile,'outfile.bufr','w')
     call codes_write(ibufr,outfile)
     call codes_close_file(outfile)
     call codes_release(ibufr)
     if(allocated(ivalues)) deallocate(ivalues)
     if(allocated(rvalues)) deallocate(rvalues)
     if(allocated(svalues)) deallocate(svalues)
    end program bufr_encode
    # This program was automatically generated with bufr_dump -Epython
    # Using ecCodes version: 2.0.0
    import traceback
    import sys
    from eccodes import *
    
    def bufr_encode():
     ibufr = codes_bufr_new_from_samples('BUFR4')
     ivalues = ( 0, 0, 1, 0 ,)
     codes_set_array(ibufr, 'inputDelayedDescriptorReplicationFactor', ivalues)
     codes_set(ibufr, 'edition', 4)
     codes_set(ibufr, 'masterTableNumber', 0)
     codes_set(ibufr, 'bufrHeaderCentre', 74)
     codes_set(ibufr, 'bufrHeaderSubCentre', 0)
     codes_set(ibufr, 'updateSequenceNumber', 0)
     codes_set(ibufr, 'dataCategory', 0)
     codes_set(ibufr, 'internationalDataSubCategory', 2)
     codes_set(ibufr, 'dataSubCategory', 0)
     codes_set(ibufr, 'masterTablesVersionNumber', 22)
     codes_set(ibufr, 'localTablesVersionNumber', 0)
     codes_set(ibufr, 'typicalYear', 2016)
     codes_set(ibufr, 'typicalMonth', 9)
     codes_set(ibufr, 'typicalDay', 29)
     codes_set(ibufr, 'typicalHour', 12)
     codes_set(ibufr, 'typicalMinute', 0)
     codes_set(ibufr, 'typicalSecond', 0)
     codes_set(ibufr, 'numberOfSubsets', 2)
     codes_set(ibufr, 'observedData', 1)
     codes_set(ibufr, 'compressedData', 0)
    
     # Create the structure of the data section
     codes_set(ibufr, 'unexpandedDescriptors', 307080)
    
     codes_set(ibufr, '#1#blockNumber', 89)
     codes_set(ibufr, '#1#stationNumber', 22)
     codes_set(ibufr, '#1#stationOrSiteName','HALLEY')
     codes_set(ibufr, '#1#stationType', 1)
     codes_set(ibufr, '#1#year', 2016)
     codes_set(ibufr, '#1#month', 9)
     codes_set(ibufr, '#1#day', 29)
     codes_set(ibufr, '#1#hour', 12)
     codes_set(ibufr, '#1#minute', 0)
     codes_set(ibufr, '#1#latitude', -7.553300000000000125e+01)
     codes_set(ibufr, '#1#longitude', -2.663300000000000267e+01)
     codes_set(ibufr, '#1#heightOfStationGroundAboveMeanSeaLevel', 3.000000000000000000e+01)
     codes_set(ibufr, '#1#heightOfBarometerAboveMeanSeaLevel', 3.000000000000000000e+01)
     codes_set(ibufr, '#1#nonCoordinatePressure', 9.869000000000000000e+04)
     codes_set(ibufr, '#1#pressureReducedToMeanSeaLevel', 9.911000000000000000e+04)
     codes_set(ibufr, '#1#3HourPressureChange', -2.400000000000000000e+02)
     codes_set(ibufr, '#1#characteristicOfPressureTendency', 7)
     codes_set(ibufr, '#1#airTemperature', 2.459500000000000171e+02)
     codes_set(ibufr, '#1#dewpointTemperature', 2.432500000000000000e+02)
     codes_set(ibufr, '#1#horizontalVisibility', 6.000000000000000000e+04)
     codes_set(ibufr, '#1#cloudCoverTotal', 0)
     codes_set(ibufr, '#1#verticalSignificanceSurfaceObservations', 62)
     codes_set(ibufr, '#1#cloudAmount', 0)
     codes_set(ibufr, '#1#cloudType', 30)
     codes_set(ibufr, '#2#cloudType', 20)
     codes_set(ibufr, '#3#cloudType', 10)
     codes_set(ibufr, '#2#verticalSignificanceSurfaceObservations', 7)
     codes_set(ibufr, '#3#verticalSignificanceSurfaceObservations', 8)
     codes_set(ibufr, '#4#verticalSignificanceSurfaceObservations', 9)
     codes_set(ibufr, '#1#presentWeather', 508)
     codes_set(ibufr, '#1#timePeriod', -6)
     codes_set(ibufr, '#1#pastWeather1', 10)
     codes_set(ibufr, '#1#pastWeather2', 10)
     codes_set(ibufr, '#2#timePeriod', -24)
     codes_set(ibufr, '#3#timePeriod', -1)
     codes_set(ibufr, '#4#timePeriod', -12)
     codes_set(ibufr, '#5#timePeriod', -1)
     codes_set(ibufr, '#6#timePeriod', -12)
     codes_set(ibufr, '#7#timePeriod', 0)
     codes_set(ibufr, '#1#maximumTemperatureAtHeightAndOverPeriodSpecified', 2.469500000000000171e+02)
     codes_set(ibufr, '#8#timePeriod', -12)
     codes_set(ibufr, '#9#timePeriod', 0)
     codes_set(ibufr, '#1#minimumTemperatureAtHeightAndOverPeriodSpecified', 2.423499999999999943e+02)
     codes_set(ibufr, '#1#instrumentationForWindMeasurement', 12)
     codes_set(ibufr, '#1#timeSignificance', 2)
     codes_set(ibufr, '#10#timePeriod', -10)
     codes_set(ibufr, '#1#windDirection', 190)
     codes_set(ibufr, '#1#windSpeed', 2.600000000000000089e+00)
     codes_set(ibufr, '#11#timePeriod', -10)
     codes_set(ibufr, '#12#timePeriod', -360)
     codes_set(ibufr, '#13#timePeriod', -24)
     codes_set(ibufr, '#14#timePeriod', -1)
     codes_set(ibufr, '#15#timePeriod', -24)
     codes_set(ibufr, '#2#blockNumber', 89)
     codes_set(ibufr, '#2#stationNumber', 62)
     codes_set(ibufr, '#2#stationOrSiteName','ROTHERA')
     codes_set(ibufr, '#2#stationType', 1)
     codes_set(ibufr, '#2#year', 2016)
     codes_set(ibufr, '#2#month', 9)
     codes_set(ibufr, '#2#day', 29)
     codes_set(ibufr, '#2#hour', 12)
     codes_set(ibufr, '#2#minute', 0)
     codes_set(ibufr, '#2#latitude', -6.773300000000000409e+01)
     codes_set(ibufr, '#2#longitude', -6.811700000000000443e+01)
     codes_set(ibufr, '#2#heightOfStationGroundAboveMeanSeaLevel', 1.600000000000000000e+01)
     codes_set(ibufr, '#2#heightOfBarometerAboveMeanSeaLevel', 1.600000000000000000e+01)
     codes_set(ibufr, '#2#nonCoordinatePressure', 9.887000000000000000e+04)
     codes_set(ibufr, '#2#pressureReducedToMeanSeaLevel', 9.928000000000000000e+04)
     codes_set(ibufr, '#2#3HourPressureChange', 3.000000000000000000e+02)
     codes_set(ibufr, '#2#characteristicOfPressureTendency', 2)
     codes_set(ibufr, '#2#airTemperature', 2.727500000000000000e+02)
     codes_set(ibufr, '#2#dewpointTemperature', 2.635500000000000114e+02)
     codes_set(ibufr, '#2#horizontalVisibility', 4.500000000000000000e+04)
     codes_set(ibufr, '#2#cloudCoverTotal', 100)
     codes_set(ibufr, '#6#verticalSignificanceSurfaceObservations', 7)
     codes_set(ibufr, '#2#cloudAmount', 8)
     codes_set(ibufr, '#2#heightOfBaseOfCloud', 1.200000000000000000e+03)
     codes_set(ibufr, '#5#cloudType', 36)
     codes_set(ibufr, '#6#cloudType', 61)
     codes_set(ibufr, '#7#cloudType', 60)
     codes_set(ibufr, '#7#verticalSignificanceSurfaceObservations', 1)
     codes_set(ibufr, '#3#cloudAmount', 8)
     codes_set(ibufr, '#8#cloudType', 7)
     codes_set(ibufr, '#3#heightOfBaseOfCloud', 1.200000000000000000e+03)
     codes_set(ibufr, '#8#verticalSignificanceSurfaceObservations', 7)
     codes_set(ibufr, '#9#verticalSignificanceSurfaceObservations', 8)
     codes_set(ibufr, '#10#verticalSignificanceSurfaceObservations', 9)
     codes_set(ibufr, '#2#presentWeather', 3)
     codes_set(ibufr, '#18#timePeriod', -6)
     codes_set(ibufr, '#2#pastWeather1', 2)
     codes_set(ibufr, '#2#pastWeather2', 1)
     codes_set(ibufr, '#19#timePeriod', -24)
     codes_set(ibufr, '#20#timePeriod', -1)
     codes_set(ibufr, '#21#timePeriod', -12)
     codes_set(ibufr, '#22#timePeriod', -1)
     codes_set(ibufr, '#23#timePeriod', -12)
     codes_set(ibufr, '#24#timePeriod', 0)
     codes_set(ibufr, '#2#maximumTemperatureAtHeightAndOverPeriodSpecified', 2.752500000000000000e+02)
     codes_set(ibufr, '#25#timePeriod', -12)
     codes_set(ibufr, '#26#timePeriod', 0)
     codes_set(ibufr, '#2#minimumTemperatureAtHeightAndOverPeriodSpecified', 2.706499999999999773e+02)
     codes_set(ibufr, '#2#instrumentationForWindMeasurement', 12)
     codes_set(ibufr, '#3#timeSignificance', 2)
     codes_set(ibufr, '#27#timePeriod', -10)
     codes_set(ibufr, '#2#windDirection', 320)
     codes_set(ibufr, '#2#windSpeed', 5.100000000000000533e+00)
     codes_set(ibufr, '#28#timePeriod', -10)
     codes_set(ibufr, '#29#timePeriod', -360)
     codes_set(ibufr, '#30#timePeriod', -24)
     codes_set(ibufr, '#31#timePeriod', -1)
     codes_set(ibufr, '#32#timePeriod', -24)
    
     codes_set(ibufr, 'pack', 1)
     outfile = open('outfile.bufr', 'w')
     codes_write(ibufr, outfile)
     codes_release(ibufr)
    
    def main():
     try:
       bufr_encode()
     except CodesInternalError as err:
       traceback.print_exc(file=sys.stderr)
       return 1
    
    if __name__ == "__main__":
      sys.exit(main())
    /* This program was automatically generated with bufr_dump -EC */
    /* Using ecCodes version: 2.0.0 */
    #include "eccodes.h"
    int main()
    {
     size_t size=0;
     const void* buffer = NULL;
     FILE* fout = NULL;
     codes_handle* h = NULL;
     long* ivalues = NULL;
     char** svalues = NULL;
     double* rvalues = NULL;
     const char* sampleName = "BUFR4";
     h = codes_bufr_handle_new_from_samples(NULL, sampleName);
     if (h == NULL) {
      fprintf(stderr, "ERROR creating BUFR from %s\n", sampleName);
      return 1;
     }
     free(ivalues); ivalues = NULL;
     ivalues = (long*)malloc(4*sizeof(long));
     if (!ivalues) { fprintf(stderr, "Failed to allocate memory (ivalues).\n"); return 1; }
     size = 4;
     ivalues[0]=0; ivalues[1]=0; ivalues[2]=1; ivalues[3]=0;
     CODES_CHECK(codes_set_long_array(h, "inputDelayedDescriptorReplicationFactor", ivalues, size), 0);
     CODES_CHECK(codes_set_long(h, "edition", 4), 0);
     CODES_CHECK(codes_set_long(h, "masterTableNumber", 0), 0);
     CODES_CHECK(codes_set_long(h, "bufrHeaderCentre", 74), 0);
     CODES_CHECK(codes_set_long(h, "bufrHeaderSubCentre", 0), 0);
     CODES_CHECK(codes_set_long(h, "updateSequenceNumber", 0), 0);
     CODES_CHECK(codes_set_long(h, "dataCategory", 0), 0);
     CODES_CHECK(codes_set_long(h, "internationalDataSubCategory", 2), 0);
     CODES_CHECK(codes_set_long(h, "dataSubCategory", 0), 0);
     CODES_CHECK(codes_set_long(h, "masterTablesVersionNumber", 22), 0);
     CODES_CHECK(codes_set_long(h, "localTablesVersionNumber", 0), 0);
     CODES_CHECK(codes_set_long(h, "typicalYear", 2016), 0);
     CODES_CHECK(codes_set_long(h, "typicalMonth", 9), 0);
     CODES_CHECK(codes_set_long(h, "typicalDay", 29), 0);
     CODES_CHECK(codes_set_long(h, "typicalHour", 12), 0);
     CODES_CHECK(codes_set_long(h, "typicalMinute", 0), 0);
     CODES_CHECK(codes_set_long(h, "typicalSecond", 0), 0);
     CODES_CHECK(codes_set_long(h, "numberOfSubsets", 2), 0);
     CODES_CHECK(codes_set_long(h, "observedData", 1), 0);
     CODES_CHECK(codes_set_long(h, "compressedData", 0), 0);
    
     /* Create the structure of the data section */
     CODES_CHECK(codes_set_long(h, "unexpandedDescriptors", 307080), 0);
    
     CODES_CHECK(codes_set_long(h, "#1#blockNumber", 89), 0);
     CODES_CHECK(codes_set_long(h, "#1#stationNumber", 22), 0);
     codes_set_string(h, "#1#stationOrSiteName", "HALLEY", &size);
     CODES_CHECK(codes_set_long(h, "#1#stationType", 1), 0);
     CODES_CHECK(codes_set_long(h, "#1#year", 2016), 0);
     CODES_CHECK(codes_set_long(h, "#1#month", 9), 0);
     CODES_CHECK(codes_set_long(h, "#1#day", 29), 0);
     CODES_CHECK(codes_set_long(h, "#1#hour", 12), 0);
     CODES_CHECK(codes_set_long(h, "#1#minute", 0), 0);
     CODES_CHECK(codes_set_double(h, "#1#latitude", -7.553300000000000125e+01), 0);
     CODES_CHECK(codes_set_double(h, "#1#longitude", -2.663300000000000267e+01), 0);
     CODES_CHECK(codes_set_double(h, "#1#heightOfStationGroundAboveMeanSeaLevel", 3.000000000000000000e+01), 0);
     CODES_CHECK(codes_set_double(h, "#1#heightOfBarometerAboveMeanSeaLevel", 3.000000000000000000e+01), 0);
     CODES_CHECK(codes_set_double(h, "#1#nonCoordinatePressure", 9.869000000000000000e+04), 0);
     CODES_CHECK(codes_set_double(h, "#1#pressureReducedToMeanSeaLevel", 9.911000000000000000e+04), 0);
     CODES_CHECK(codes_set_double(h, "#1#3HourPressureChange", -2.400000000000000000e+02), 0);
     CODES_CHECK(codes_set_long(h, "#1#characteristicOfPressureTendency", 7), 0);
     CODES_CHECK(codes_set_double(h, "#1#airTemperature", 2.459500000000000171e+02), 0);
     CODES_CHECK(codes_set_double(h, "#1#dewpointTemperature", 2.432500000000000000e+02), 0);
     CODES_CHECK(codes_set_double(h, "#1#horizontalVisibility", 6.000000000000000000e+04), 0);
     CODES_CHECK(codes_set_long(h, "#1#cloudCoverTotal", 0), 0);
     CODES_CHECK(codes_set_long(h, "#1#verticalSignificanceSurfaceObservations", 62), 0);
     CODES_CHECK(codes_set_long(h, "#1#cloudAmount", 0), 0);
     CODES_CHECK(codes_set_long(h, "#1#cloudType", 30), 0);
     CODES_CHECK(codes_set_long(h, "#2#cloudType", 20), 0);
     CODES_CHECK(codes_set_long(h, "#3#cloudType", 10), 0);
     CODES_CHECK(codes_set_long(h, "#2#verticalSignificanceSurfaceObservations", 7), 0);
     CODES_CHECK(codes_set_long(h, "#3#verticalSignificanceSurfaceObservations", 8), 0);
     CODES_CHECK(codes_set_long(h, "#4#verticalSignificanceSurfaceObservations", 9), 0);
     CODES_CHECK(codes_set_long(h, "#1#presentWeather", 508), 0);
     CODES_CHECK(codes_set_long(h, "#1#timePeriod", -6), 0);
     CODES_CHECK(codes_set_long(h, "#1#pastWeather1", 10), 0);
     CODES_CHECK(codes_set_long(h, "#1#pastWeather2", 10), 0);
     CODES_CHECK(codes_set_long(h, "#2#timePeriod", -24), 0);
     CODES_CHECK(codes_set_long(h, "#3#timePeriod", -1), 0);
     CODES_CHECK(codes_set_long(h, "#4#timePeriod", -12), 0);
     CODES_CHECK(codes_set_long(h, "#5#timePeriod", -1), 0);
     CODES_CHECK(codes_set_long(h, "#6#timePeriod", -12), 0);
     CODES_CHECK(codes_set_long(h, "#7#timePeriod", 0), 0);
     CODES_CHECK(codes_set_double(h, "#1#maximumTemperatureAtHeightAndOverPeriodSpecified", 2.469500000000000171e+02), 0);
     CODES_CHECK(codes_set_long(h, "#8#timePeriod", -12), 0);
     CODES_CHECK(codes_set_long(h, "#9#timePeriod", 0), 0);
     CODES_CHECK(codes_set_double(h, "#1#minimumTemperatureAtHeightAndOverPeriodSpecified", 2.423499999999999943e+02), 0);
     CODES_CHECK(codes_set_long(h, "#1#instrumentationForWindMeasurement", 12), 0);
     CODES_CHECK(codes_set_long(h, "#1#timeSignificance", 2), 0);
     CODES_CHECK(codes_set_long(h, "#10#timePeriod", -10), 0);
     CODES_CHECK(codes_set_long(h, "#1#windDirection", 190), 0);
     CODES_CHECK(codes_set_double(h, "#1#windSpeed", 2.600000000000000089e+00), 0);
     CODES_CHECK(codes_set_long(h, "#11#timePeriod", -10), 0);
     CODES_CHECK(codes_set_long(h, "#12#timePeriod", -360), 0);
     CODES_CHECK(codes_set_long(h, "#13#timePeriod", -24), 0);
     CODES_CHECK(codes_set_long(h, "#14#timePeriod", -1), 0);
     CODES_CHECK(codes_set_long(h, "#15#timePeriod", -24), 0);
     CODES_CHECK(codes_set_long(h, "#2#blockNumber", 89), 0);
     CODES_CHECK(codes_set_long(h, "#2#stationNumber", 62), 0);
     codes_set_string(h, "#2#stationOrSiteName", "ROTHERA", &size);
     CODES_CHECK(codes_set_long(h, "#2#stationType", 1), 0);
     CODES_CHECK(codes_set_long(h, "#2#year", 2016), 0);
     CODES_CHECK(codes_set_long(h, "#2#month", 9), 0);
     CODES_CHECK(codes_set_long(h, "#2#day", 29), 0);
     CODES_CHECK(codes_set_long(h, "#2#hour", 12), 0);
     CODES_CHECK(codes_set_long(h, "#2#minute", 0), 0);
     CODES_CHECK(codes_set_double(h, "#2#latitude", -6.773300000000000409e+01), 0);
     CODES_CHECK(codes_set_double(h, "#2#longitude", -6.811700000000000443e+01), 0);
    CODES_CHECK(codes_set_double(h, "#2#heightOfStationGroundAboveMeanSeaLevel", 1.600000000000000000e+01), 0);
     CODES_CHECK(codes_set_double(h, "#2#heightOfBarometerAboveMeanSeaLevel", 1.600000000000000000e+01), 0);
     CODES_CHECK(codes_set_double(h, "#2#nonCoordinatePressure", 9.887000000000000000e+04), 0);
     CODES_CHECK(codes_set_double(h, "#2#pressureReducedToMeanSeaLevel", 9.928000000000000000e+04), 0);
     CODES_CHECK(codes_set_double(h, "#2#3HourPressureChange", 3.000000000000000000e+02), 0);
     CODES_CHECK(codes_set_long(h, "#2#characteristicOfPressureTendency", 2), 0);
     CODES_CHECK(codes_set_double(h, "#2#airTemperature", 2.727500000000000000e+02), 0);
     CODES_CHECK(codes_set_double(h, "#2#dewpointTemperature", 2.635500000000000114e+02), 0);
     CODES_CHECK(codes_set_double(h, "#2#horizontalVisibility", 4.500000000000000000e+04), 0);
     CODES_CHECK(codes_set_long(h, "#2#cloudCoverTotal", 100), 0);
     CODES_CHECK(codes_set_long(h, "#6#verticalSignificanceSurfaceObservations", 7), 0);
     CODES_CHECK(codes_set_long(h, "#2#cloudAmount", 8), 0);
     CODES_CHECK(codes_set_double(h, "#2#heightOfBaseOfCloud", 1.200000000000000000e+03), 0);
     CODES_CHECK(codes_set_long(h, "#5#cloudType", 36), 0);
     CODES_CHECK(codes_set_long(h, "#6#cloudType", 61), 0);
     CODES_CHECK(codes_set_long(h, "#7#cloudType", 60), 0);
     CODES_CHECK(codes_set_long(h, "#7#verticalSignificanceSurfaceObservations", 1), 0);
     CODES_CHECK(codes_set_long(h, "#3#cloudAmount", 8), 0);
     CODES_CHECK(codes_set_long(h, "#8#cloudType", 7), 0);
     CODES_CHECK(codes_set_double(h, "#3#heightOfBaseOfCloud", 1.200000000000000000e+03), 0);
     CODES_CHECK(codes_set_long(h, "#8#verticalSignificanceSurfaceObservations", 7), 0);
     CODES_CHECK(codes_set_long(h, "#9#verticalSignificanceSurfaceObservations", 8), 0);
     CODES_CHECK(codes_set_long(h, "#10#verticalSignificanceSurfaceObservations", 9), 0);
     CODES_CHECK(codes_set_long(h, "#2#presentWeather", 3), 0);
     CODES_CHECK(codes_set_long(h, "#18#timePeriod", -6), 0);
     CODES_CHECK(codes_set_long(h, "#2#pastWeather1", 2), 0);
     CODES_CHECK(codes_set_long(h, "#2#pastWeather2", 1), 0);
     CODES_CHECK(codes_set_long(h, "#19#timePeriod", -24), 0);
     CODES_CHECK(codes_set_long(h, "#20#timePeriod", -1), 0);
     CODES_CHECK(codes_set_long(h, "#21#timePeriod", -12), 0);
     CODES_CHECK(codes_set_long(h, "#22#timePeriod", -1), 0);
     CODES_CHECK(codes_set_long(h, "#23#timePeriod", -12), 0);
     CODES_CHECK(codes_set_long(h, "#24#timePeriod", 0), 0);
     CODES_CHECK(codes_set_double(h, "#2#maximumTemperatureAtHeightAndOverPeriodSpecified", 2.752500000000000000e+02), 0);
     CODES_CHECK(codes_set_long(h, "#25#timePeriod", -12), 0);
     CODES_CHECK(codes_set_long(h, "#26#timePeriod", 0), 0);
     CODES_CHECK(codes_set_double(h, "#2#minimumTemperatureAtHeightAndOverPeriodSpecified", 2.706499999999999773e+02), 0);
     CODES_CHECK(codes_set_long(h, "#2#instrumentationForWindMeasurement", 12), 0);
     CODES_CHECK(codes_set_long(h, "#3#timeSignificance", 2), 0);
     CODES_CHECK(codes_set_long(h, "#27#timePeriod", -10), 0);
     CODES_CHECK(codes_set_long(h, "#2#windDirection", 320), 0);
     CODES_CHECK(codes_set_double(h, "#2#windSpeed", 5.100000000000000533e+00), 0);
     CODES_CHECK(codes_set_long(h, "#28#timePeriod", -10), 0);
     CODES_CHECK(codes_set_long(h, "#29#timePeriod", -360), 0);
     CODES_CHECK(codes_set_long(h, "#30#timePeriod", -24), 0);
     CODES_CHECK(codes_set_long(h, "#31#timePeriod", -1), 0);
     CODES_CHECK(codes_set_long(h, "#32#timePeriod", -24), 0);
    
     /* Encode the keys back in the data section */
     codes_set_long(h, "pack", 1);
     fout = fopen("outfile.bufr", "w");
     if (!fout) {
       fprintf(stderr, "Failed to open output file.\n");
       return 1;
     }
     CODES_CHECK(codes_get_message(h,&buffer,&size),0);
     if (fwrite(buffer,1,size,fout) != size) {
       fprintf(stderr, "Failed to write data.\n");
       return 1;
     }
     if (fclose(fout)!=0) {
       fprintf(stderr, "Failed to close file handle.\n");
       return 1;
     }
     
     codes_handle_delete(h);
     free(ivalues); ivalues = NULL;
     free(rvalues); rvalues = NULL;
     free(svalues); svalues = NULL;
     return 0;
    }
    # This filter was automatically generated with bufr_dump -Efilter
    # Using ecCodes version: 2.0.0
    set inputDelayedDescriptorReplicationFactor= {
     0, 0, 1, 0};
    set edition=4;
    set masterTableNumber=0;
    set bufrHeaderCentre=74;
    set bufrHeaderSubCentre=0;
    set updateSequenceNumber=0;
    set dataCategory=0;
    set internationalDataSubCategory=2;
    set dataSubCategory=0;
    set masterTablesVersionNumber=22;
    set localTablesVersionNumber=0;
    set typicalYear=2016;
    set typicalMonth=9;
    set typicalDay=29;
    set typicalHour=12;
    set typicalMinute=0;
    set typicalSecond=0;
    set numberOfSubsets=2;
    set observedData=1;
    set compressedData=0;
    set unexpandedDescriptors=307080;
    set #1#blockNumber=89;
    set #1#stationNumber=22;
    set #1#stationOrSiteName="HALLEY";
    set #1#stationType=1;
    set #1#year=2016;
    set #1#month=9;
    set #1#day=29;
    set #1#hour=12;
    set #1#minute=0;
    set #1#latitude=-7.553300000000000125e+01;
    set #1#longitude=-2.663300000000000267e+01;
    set #1#heightOfStationGroundAboveMeanSeaLevel=3.000000000000000000e+01;
    set #1#heightOfBarometerAboveMeanSeaLevel=3.000000000000000000e+01;
    set #1#nonCoordinatePressure=9.869000000000000000e+04;
    set #1#pressureReducedToMeanSeaLevel=9.911000000000000000e+04;
    set #1#3HourPressureChange=-2.400000000000000000e+02;
    set #1#characteristicOfPressureTendency=7;
    set #1#airTemperature=2.459500000000000171e+02;
    set #1#dewpointTemperature=2.432500000000000000e+02;
    set #1#horizontalVisibility=6.000000000000000000e+04;
    set #1#cloudCoverTotal=0;
    set #1#verticalSignificanceSurfaceObservations=62;
    set #1#cloudAmount=0;
    set #1#cloudType=30;
    set #2#cloudType=20;
    set #3#cloudType=10;
    set #2#verticalSignificanceSurfaceObservations=7;
    set #3#verticalSignificanceSurfaceObservations=8;
    set #4#verticalSignificanceSurfaceObservations=9;
    set #1#presentWeather=508;
    set #1#timePeriod=-6;
    set #1#pastWeather1=10;
    set #1#pastWeather2=10;
    set #2#timePeriod=-24;
    set #3#timePeriod=-1;
    set #4#timePeriod=-12;
    set #5#timePeriod=-1;
    set #6#timePeriod=-12;
    set #7#timePeriod=0;
    set #1#maximumTemperatureAtHeightAndOverPeriodSpecified=2.469500000000000171e+02;
    set #8#timePeriod=-12;
    set #9#timePeriod=0;
    set #1#minimumTemperatureAtHeightAndOverPeriodSpecified=2.423499999999999943e+02;
    set #1#instrumentationForWindMeasurement=12;
    set #1#timeSignificance=2;
    set #10#timePeriod=-10;
    set #1#windDirection=190;
    set #1#windSpeed=2.600000000000000089e+00;
    set #11#timePeriod=-10;
    set #12#timePeriod=-360;
    set #13#timePeriod=-24;
    set #14#timePeriod=-1;
    set #15#timePeriod=-24;
    set #2#blockNumber=89;
    set #2#stationNumber=62;
    set #2#stationOrSiteName="ROTHERA";
    set #2#stationType=1;
    set #2#year=2016;
    set #2#month=9;
    set #2#day=29;
    set #2#hour=12;
    set #2#minute=0;
    set #2#latitude=-6.773300000000000409e+01;
    set #2#longitude=-6.811700000000000443e+01;
    set #2#heightOfStationGroundAboveMeanSeaLevel=1.600000000000000000e+01;
    set #2#heightOfBarometerAboveMeanSeaLevel=1.600000000000000000e+01;
    set #2#nonCoordinatePressure=9.887000000000000000e+04;
    set #2#pressureReducedToMeanSeaLevel=9.928000000000000000e+04;
    set #2#3HourPressureChange=3.000000000000000000e+02;
    set #2#characteristicOfPressureTendency=2;
    set #2#airTemperature=2.727500000000000000e+02;
    set #2#dewpointTemperature=2.635500000000000114e+02;
    set #2#horizontalVisibility=4.500000000000000000e+04;
    set #2#cloudCoverTotal=100;
    set #6#verticalSignificanceSurfaceObservations=7;
    set #2#cloudAmount=8;
    set #2#heightOfBaseOfCloud=1.200000000000000000e+03;
    set #5#cloudType=36;
    set #6#cloudType=61;
    set #7#cloudType=60;
    set #7#verticalSignificanceSurfaceObservations=1;
    set #3#cloudAmount=8;
    set #8#cloudType=7;
    set #3#heightOfBaseOfCloud=1.200000000000000000e+03;
    set #8#verticalSignificanceSurfaceObservations=7;
    set #9#verticalSignificanceSurfaceObservations=8;
    set #10#verticalSignificanceSurfaceObservations=9;
    set #2#presentWeather=3;
    set #18#timePeriod=-6;
    set #2#pastWeather1=2;
    set #2#pastWeather2=1;
    set #19#timePeriod=-24;
    set #20#timePeriod=-1;
    set #21#timePeriod=-12;
    set #22#timePeriod=-1;
    set #23#timePeriod=-12;
    set #24#timePeriod=0;
    set #2#maximumTemperatureAtHeightAndOverPeriodSpecified=2.752500000000000000e+02;
    set #25#timePeriod=-12;
    set #26#timePeriod=0;
    set #2#minimumTemperatureAtHeightAndOverPeriodSpecified=2.706499999999999773e+02;
    set #2#instrumentationForWindMeasurement=12;
    set #3#timeSignificance=2;
    set #27#timePeriod=-10;
    set #2#windDirection=320;
    set #2#windSpeed=5.100000000000000533e+00;
    set #28#timePeriod=-10;
    set #29#timePeriod=-360;
    set #30#timePeriod=-24;
    set #31#timePeriod=-1;
    set #32#timePeriod=-24;
    set pack=1;
    write;