      SUBROUTINE grib_set(what, kvec, nvec)
      implicit none

      character*(*), intent(in) :: what
      integer, intent(in)       :: nvec, kvec(nvec)
! === END OF INTERFACE BLOCK ===

#include "grib_internal.h"
      integer j, idgl

      if (nvec <= 0) return

      if (what == 'nloen' .or. what == 'NLOEN') then

         idgl      = nsec2(3)
         if (nvec == 1) then
            do j=1,idgl
               nsec2(22 + j) = kvec(1)
            enddo
         else
            do j=1,idgl
               nsec2(22 + j) = kvec(j)
            enddo
         endif
         
      else if (what == 'regular' .or. what == 'REGULAR') then
         
         if (kvec(1) /= 0) then
            nsec2(17) = 0
         else
            nsec2(17) = 1
            nsec2(6)  = 0
            idgl      = nsec2(3)
            nsec4(1)  = sum(nsec2(22 + 1:22 + idgl))
         endif

      else if (what == 'local17' .or. what == 'LOCAL17') then

        nsec1(24) = 1           ! Local use of section 1 : ON
        nsec1(37) = 17          ! ECMWF local GRIB definition 17
        nsec1(39) = 2           ! type   = Analysis
        nsec1(40) = 1025        ! stream = Daily archive
        nsec1(44) = kvec(1)     ! SST date
        nsec1(45) = kvec(2)     ! type of SST data (clim,1x1,2x2)
        nsec1(46) = kvec(3)     ! number of ICE days averaged
        nsec1(47) = kvec(4)     ! ICE first date in average
        nsec1(48) = kvec(5)     ! first date satellite number
        nsec1(49) = kvec(6)     ! ICE second date in average
        nsec1(50) = kvec(7)     ! second date satellite number
        nsec1(51) = kvec(8)     ! ICE third date in average
        nsec1(52) = kvec(9)     ! third date satellite number
        nsec1(53) = kvec(10)    ! ICE forth date in average
        nsec1(54) = kvec(11)    ! fourth date satellite number

      else if (what == 'missing_data_on' .or. 
     &         what == 'MISSING_DATA_ON') then

        nsec1(5)=192
        rsec3(2)=kvec(1)

      else if (what == 'missing_data_off' .or. 
     &         what == 'MISSING_DATA_OFF') then

        nsec1(5)=128

      endif

      END SUBROUTINE grib_set
