    PROGRAM nag_ip_ex02

      ! Example Program Text for nag_ip
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_in, nag_std_out
      USE nag_ip, ONLY : nag_ip_sol, nag_ip_cntrl_init, &
       nag_ip_cntrl_wp => nag_ip_cntrl_dp
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      ! .. Local Scalars ..
      INTEGER :: i, m, n
      REAL (wp) :: obj_f
      TYPE (nag_ip_cntrl_wp) :: control
      ! .. Local Arrays ..
      REAL (wp), ALLOCATABLE :: a(:,:), ax_lower(:), ax_upper(:), c(:), x(:), &
       x_upper(:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_ip_ex02'

      READ (nag_std_in,*)          ! Skip heading in data file

      ! Read number of linear constraints (m) and variables (n)
      READ (nag_std_in,*) m, n

       ALLOCATE (x(n),c(n),x_upper(n),a(m,n),ax_lower(m), &
       ax_upper(m))                ! Allocate storage

      ! Read in problem data
      READ (nag_std_in,*) (a(i,:),i=1,m)
      READ (nag_std_in,*) ax_lower
      READ (nag_std_in,*) ax_upper
      READ (nag_std_in,*) x
      READ (nag_std_in,*) x_upper
      READ (nag_std_in,*) c

      ! Initialize control structure and set required control parameters

      CALL nag_ip_cntrl_init(control)

      control%print_level = 1
      control%iter_lim = 99

      ! Solve the problem

      CALL nag_ip_sol(x,c,obj_f,x_upper=x_upper,a=a,ax_lower=ax_lower, &
       ax_upper=ax_upper,control=control)

      DEALLOCATE (x,c,x_upper,a,ax_lower,ax_upper) ! Deallocate storage

    END PROGRAM nag_ip_ex02
