!  This program was automatically generated with bufr_dump -Efortran
!  Using ecCodes version: 2.0.2

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(1))
  ivalues=(/ 31 /)
  call codes_set(ibufr,'inputDelayedDescriptorReplicationFactor',ivalues)
  if(allocated(ivalues)) deallocate(ivalues)
  allocate(ivalues(7))
  ivalues=(/   &
      1, 1, 1, 1, 0, 0, 0 /)
  call codes_set(ibufr,'inputShortDelayedDescriptorReplicationFactor',ivalues)
  call codes_set(ibufr,'edition',4)
  call codes_set(ibufr,'masterTableNumber',0)
  call codes_set(ibufr,'bufrHeaderCentre',85)
  call codes_set(ibufr,'bufrHeaderSubCentre',0)
  call codes_set(ibufr,'updateSequenceNumber',0)
  call codes_set(ibufr,'dataCategory',1)
  call codes_set(ibufr,'internationalDataSubCategory',25)
  call codes_set(ibufr,'dataSubCategory',25)
  call codes_set(ibufr,'masterTablesVersionNumber',22)
  call codes_set(ibufr,'localTablesVersionNumber',0)
  call codes_set(ibufr,'typicalYear',2016)
  call codes_set(ibufr,'typicalMonth',11)
  call codes_set(ibufr,'typicalDay',7)
  call codes_set(ibufr,'typicalHour',0)
  call codes_set(ibufr,'typicalMinute',0)
  call codes_set(ibufr,'typicalSecond',0)
  call codes_set(ibufr,'numberOfSubsets',1)
  call codes_set(ibufr,'observedData',1)
  call codes_set(ibufr,'compressedData',0)
  call codes_set(ibufr,'unexpandedDescriptors',315008)
  call codes_set(ibufr,'marineObservingPlatformIdentifier',6100002)
  call codes_set(ibufr,'stationOrSiteName','BOUEE_LION')
  call codes_set(ibufr,'dataBuoyType',16)
  call codes_set(ibufr,'year',2016)
  call codes_set(ibufr,'month',11)
  call codes_set(ibufr,'day',7)
  call codes_set(ibufr,'hour',0)
  call codes_set(ibufr,'minute',0)
  call codes_set(ibufr,'latitude',4.206000000000000227d+01)
  call codes_set(ibufr,'longitude',4.660000000000000142d+00)
  call codes_set(ibufr,'nonCoordinatePressure',1.009400000000000000d+05)
  call codes_set(ibufr,'pressureReducedToMeanSeaLevel',1.009900000000000000d+05)
  call codes_set(ibufr,'#1#heightOfSensorAboveWaterSurface',0.000000000000000000d+00)
  call codes_set(ibufr,'airTemperature',2.865500000000000114d+02)
  call codes_set(ibufr,'dewpointTemperature',2.798500000000000227d+02)
  call codes_set(ibufr,'relativeHumidity',64)
  call codes_set(ibufr,'#2#heightOfSensorAboveWaterSurface',0.000000000000000000d+00)
  call codes_set(ibufr,'#1#timeSignificance',2)
  call codes_set(ibufr,'#1#timePeriod',-10)
  call codes_set(ibufr,'windDirection',320)
  call codes_set(ibufr,'windSpeed',6.300000000000000711d+00)
  call codes_set(ibufr,'#2#timePeriod',-10)
  call codes_set(ibufr,'temperatureObservationPrecision',1.000000000000000056d-01)
  call codes_set(ibufr,'depthBelowWaterSurface',0.000000000000000000d+00)
  call codes_set(ibufr,'seaSurfaceTemperature',2.901500000000000341d+02)
  call codes_set(ibufr,'#4#timePeriod',-1)
  call codes_set(ibufr,'totalPrecipitationOrTotalWaterEquivalent',0.000000000000000000d+00)
  call codes_set(ibufr,'#5#timePeriod',60)
  call codes_set(ibufr,'longWaveRadiationIntegratedOverPeriodSpecified',1.269000000000000000d+06)
  call codes_set(ibufr,'shortWaveRadiationIntegratedOverPeriodSpecified',0.000000000000000000d+00)
  call codes_set(ibufr,'#1#durationOfWaveRecord',1024)
  call codes_set(ibufr,'significantWaveHeight',2.200000000000000178d+00)
  call codes_set(ibufr,'maximumWaveHeight',3.899999999999999911d+00)
  call codes_set(ibufr,'averageWavePeriod',6.000000000000000000d+00)
  call codes_set(ibufr,'#2#durationOfWaveRecord',1024)
  call codes_set(ibufr,'maximumNonDirectionalSpectralWaveDensity',7.900000000000000355d-01)
  call codes_set(ibufr,'#1#wavebandCentralFrequency',1.700000000000000122d-02)
  call codes_set(ibufr,'#1#spectralWaveDensity',1.799999999999999933d-01)
  call codes_set(ibufr,'#2#wavebandCentralFrequency',4.100000000000000172d-02)
  call codes_set(ibufr,'#2#spectralWaveDensity',2.199999999999999872d-02)
  call codes_set(ibufr,'#3#wavebandCentralFrequency',5.200000000000000455d-02)
  call codes_set(ibufr,'#3#spectralWaveDensity',2.600000000000000228d-02)
  call codes_set(ibufr,'#4#wavebandCentralFrequency',6.400000000000000133d-02)
  call codes_set(ibufr,'#4#spectralWaveDensity',2.900000000000000147d-02)
  call codes_set(ibufr,'#5#wavebandCentralFrequency',7.599999999999999811d-02)
  call codes_set(ibufr,'#5#spectralWaveDensity',3.699999999999999817d-02)
  call codes_set(ibufr,'#6#wavebandCentralFrequency',8.700000000000000788d-02)
  call codes_set(ibufr,'#6#spectralWaveDensity',5.100000000000000366d-02)
  call codes_set(ibufr,'#7#wavebandCentralFrequency',9.900000000000000466d-02)
  call codes_set(ibufr,'#7#spectralWaveDensity',1.120000000000000023d-01)
  call codes_set(ibufr,'#8#wavebandCentralFrequency',1.110000000000000014d-01)
  call codes_set(ibufr,'#8#spectralWaveDensity',1.380000000000000115d-01)
  call codes_set(ibufr,'#9#wavebandCentralFrequency',1.229999999999999982d-01)
  call codes_set(ibufr,'#9#spectralWaveDensity',4.040000000000000258d-01)
  call codes_set(ibufr,'#10#wavebandCentralFrequency',1.340000000000000080d-01)
  call codes_set(ibufr,'#10#spectralWaveDensity',7.169999999999999707d-01)
  call codes_set(ibufr,'#11#wavebandCentralFrequency',1.459999999999999909d-01)
  call codes_set(ibufr,'#11#spectralWaveDensity',7.860000000000000320d-01)
  call codes_set(ibufr,'#12#wavebandCentralFrequency',1.580000000000000016d-01)
  call codes_set(ibufr,'#12#spectralWaveDensity',5.250000000000000222d-01)
  call codes_set(ibufr,'#13#wavebandCentralFrequency',1.690000000000000113d-01)
  call codes_set(ibufr,'#13#spectralWaveDensity',3.900000000000000133d-01)
  call codes_set(ibufr,'#14#wavebandCentralFrequency',1.809999999999999942d-01)
  call codes_set(ibufr,'#14#spectralWaveDensity',2.750000000000000222d-01)
  call codes_set(ibufr,'#15#wavebandCentralFrequency',1.930000000000000049d-01)
  call codes_set(ibufr,'#15#spectralWaveDensity',3.330000000000000182d-01)
  call codes_set(ibufr,'#16#wavebandCentralFrequency',2.050000000000000155d-01)
  call codes_set(ibufr,'#16#spectralWaveDensity',2.500000000000000000d-01)
  call codes_set(ibufr,'#17#wavebandCentralFrequency',2.159999999999999976d-01)
  call codes_set(ibufr,'#17#spectralWaveDensity',3.470000000000000306d-01)
  call codes_set(ibufr,'#18#wavebandCentralFrequency',2.280000000000000082d-01)
  call codes_set(ibufr,'#18#spectralWaveDensity',2.610000000000000098d-01)
  call codes_set(ibufr,'#19#wavebandCentralFrequency',2.399999999999999911d-01)
  call codes_set(ibufr,'#19#spectralWaveDensity',2.419999999999999929d-01)
  call codes_set(ibufr,'#20#wavebandCentralFrequency',2.510000000000000009d-01)
  call codes_set(ibufr,'#20#spectralWaveDensity',2.080000000000000182d-01)
  call codes_set(ibufr,'#21#wavebandCentralFrequency',2.630000000000000115d-01)
  call codes_set(ibufr,'#21#spectralWaveDensity',2.149999999999999967d-01)
  call codes_set(ibufr,'#22#wavebandCentralFrequency',2.750000000000000222d-01)
  call codes_set(ibufr,'#22#spectralWaveDensity',1.930000000000000049d-01)
  call codes_set(ibufr,'#23#wavebandCentralFrequency',2.870000000000000329d-01)
  call codes_set(ibufr,'#23#spectralWaveDensity',2.200000000000000011d-01)
  call codes_set(ibufr,'#24#wavebandCentralFrequency',2.979999999999999871d-01)
  call codes_set(ibufr,'#24#spectralWaveDensity',1.610000000000000042d-01)
  call codes_set(ibufr,'#25#wavebandCentralFrequency',3.099999999999999978d-01)
  call codes_set(ibufr,'#25#spectralWaveDensity',1.580000000000000016d-01)
  call codes_set(ibufr,'#26#wavebandCentralFrequency',3.220000000000000084d-01)
  call codes_set(ibufr,'#26#spectralWaveDensity',1.300000000000000044d-01)
  call codes_set(ibufr,'#27#wavebandCentralFrequency',3.330000000000000182d-01)
  call codes_set(ibufr,'#27#spectralWaveDensity',1.539999999999999980d-01)
  call codes_set(ibufr,'#28#wavebandCentralFrequency',3.450000000000000289d-01)
  call codes_set(ibufr,'#28#spectralWaveDensity',1.590000000000000024d-01)
  call codes_set(ibufr,'#29#wavebandCentralFrequency',3.569999999999999840d-01)
  call codes_set(ibufr,'#29#spectralWaveDensity',1.069999999999999979d-01)
  call codes_set(ibufr,'#30#wavebandCentralFrequency',3.689999999999999947d-01)
  call codes_set(ibufr,'#30#spectralWaveDensity',9.600000000000000200d-02)
  call codes_set(ibufr,'#31#wavebandCentralFrequency',3.800000000000000044d-01)
  call codes_set(ibufr,'#31#spectralWaveDensity',6.900000000000000577d-02)
  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
