*------------- Telecommunications & Signal Processing Lab --------------
*                          McGill University
*
*
* Module:
*     integer function iceil (k, l)
*
*
* Purpose:
*     Calculate the ceiling function of a ratio of integers
*
*
* Description:
*     This function calculate the ceiling function of k/l.  It returns
*     the smallest integer that is greater than or equal to the
*     quotient.
*
*
* Parameters:
* I <-  iceil - Resultant value
*
* I ->  k     - Numerator integer value
* I ->  l     - Denominator integer value
*
*
* Author / revision:
*     P. Kabal
*     $Revision: 1.5 $  $Date: 1995/03/08 15:26:39 $
*
*
*-----------------------------------------------------------------------

      integer function iceil (k, l)


      integer k,l
      integer la,ka


* Find the signs of the input terms
* Find ka and la, such that ka/la=k/l where la is positive
      if (l.gt.0) then
        la=l
        ka=k
      else
        la=-l
        ka=-k
      end if

* Integer division forms the correct result for negative numbers
      if (ka.le.0) then
        iceil=ka/la
      else
        iceil=(ka-1)/la +1
       end if


      return

      end
