*     *************************************************************************

      double precision function mxflow( x, u, l, iarc, next,
     +                                  rgmx, bigfl )

*     *************************************************************************

*     Purpose :
*     ---------

*     Given the orientation (sign of NEXT) of the basic arc
*     IARC in the cycle formed by the nonbasic arc with the
*     basis spanning tree and the direction (opposite sign
*     of RGMAX) of the change of flow on the nonbasic arc, the
*     function determines the direction (opposite sign of the
*     product NEXT*RGMAX) of the change of flow on the basic
*     arc IARC and computes the maximum steplength (MXFLOW)
*     for keeping feasibility on basic arc IARC.

*     Parameters :
*     ------------

*     x       ( dble )

*       input  : the value of the flow on the basic arc IARC.
*       output : unmodified.

*     u       ( dble )

*       input  : the upper bound on the basic arc IARC.
*       output : unmodified.

*     l       ( dble )

*       input  : the lower bound on the basic arc IARC.
*       output : unmodified.

*     iarc    ( int )

*       input  : the indice of the basic arc for which we
*                compute the maxixmum steplength MXFLOW
*                for keeping feasibility.
*                If IARC <= ARCS, then the basic variable is
*                                 is a non artificial variable.
*                If IARC >  ARCS, then the basic variable is
*                                 is an artificial variable.
*       output : unmodified.

*     next    ( int )

*       input  : the sign of this value determines the
*                orientation of the basic arc IARC in the
*                cycle formed by the nonbasic arc and the
*                basis spanning tree.
*                If NEXT > 0, then the basic arc IARC has
*                             an orientation identical to
*                             that of the nonbasic arc in
*                             the cycle.
*                If NEXT < 0, then the basic arc IARC has
*                             an orientation opposite to
*                             that of the nonbasic arc in
*                             the cycle.
*       output : unmodified.

*     rgmx    ( dble )

*       input  : the reduced cost of the nonbasic variable.
*                The opposite sign of RGMAX determines the
*                direction of the change of flow on the
*                nonbasic arc.
*       output : unmodified.

*     bigfl   ( dble )

*       input  : a constant whose value is greater then
*                the maximum steplength allowed for keeping
*                feasibility.
*       output : unmodified.

*     mxflow  ( dble )

*       input  : meaningless.
*       output : the maximum steplength for keeping feasibility
*                on basic arc IARC.

*     Routines used :
*     ---------------

*     None.

*     Programming :
*     -------------

*     D. Tuyttens

*     ========================================================================

*     Routine parameters

      double precision  x, l, u, rgmx, bigfl
      integer           iarc, next

*     Common specifications

      integer           arcs, nodes, elem
      common / prbdim / arcs, nodes, elem

      double precision  zero, one, two, three, half, tenm1, tenm2, tenm4
      common / prbcst / zero, one, two, three, half, tenm1, tenm2, tenm4

      if( next*rgmx.lt.zero ) then
*
*       The direction of the change of flow
*       on the basic arc IARC is positive.
*       The change of flow is limited by the
*       upper bound of the basic arc IARC.
*
        if( iarc.le.arcs ) then
          mxflow = u - x
        else
          mxflow = bigfl
        endif
*
      else
*
*       The direction of the change of flow
*       on the basic arc IARC is negative.
*       The change of flow is limited by the
*       lower bound of the basic arc IARC.
*
        if( iarc.le.arcs ) then
          mxflow = x - l
        else
          mxflow = x
        endif
*
      endif
*
      return
      end