      PROGRAM EXMAIN
*
*  The example from the user's guide
*
*  D. Tuyttens and Ph. Toint, 1992.
*
      INTEGER           NAMAX, NELMAX, NA, NN, NEL, INFORM,
     +                  LELVAR, LELPTR, LFUVAL, LGPTR,
     +                  LHPTR, LFCALC, LFC, LIWK, LWK, MAXIT,
     +                  IPDEVC, WHAT, FREQ, INFO, IFLAG
      PARAMETER         ( NAMAX  = 5          , NELMAX = 3          )
      PARAMETER         ( LIWK   = 10000      , LWK    = 10000      )
      PARAMETER         ( LELVAR = 7          , LELPTR = NELMAX + 1 )
      PARAMETER         ( LGPTR  = NELMAX + 1 , LHPTR  = NELMAX + 1 )
      PARAMETER         ( LFUVAL = 10000      , LFCALC = NELMAX     )
      PARAMETER         ( MAXIT  = 100        , IPDEVC = 6          )
      PARAMETER         ( FREQ   = 1          , WHAT   = 2          )
      INTEGER           ELVAR(LELVAR), ELPTR(LELPTR), ELST(NELMAX),
     +                  XST(NAMAX), FR(NAMAX), TO(NAMAX), IT(3),
     +                  GPTR(LGPTR), HPTR(LHPTR), IWK(LIWK),
     +                  FCALC(LFCALC), IFC(3), I
      LOGICAL           PREC, NIPST
      DOUBLE PRECISION  X(NAMAX), FX, FUVAL(LFUVAL),
     +                  EPSF, WK(LWK)
      DATA  NA / 5 /, NN / 4 /, NEL / 3 /
      DATA  FR / 1, 1, 3, 2, 3  /
      DATA  TO / 2, 3, 2, 4, 4  /
      DATA  ELVAR / 1, 2, 3, 3, 4, 3, 5 /
      DATA  ELPTR / 1, 4, 6, 8 /
      DATA  ELST  / 1, 1, 1 /
      DATA  X     / 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0 /
      DATA  XST   / 1, 1, 1, -1, -1 /
      DATA  EPSF  / 1.D-5 /
      DATA  PREC  / .FALSE. /, NIPST / .FALSE. /
      INFORM = 0
*
*     SOLVING THE PROBLEN WITH LSNNO.
*
 100  CONTINUE
      CALL LSNNO( NA, NN, NEL,  ELVAR, ELPTR, ELST, FR, TO,
     +            X, XST, FX,
     +            FUVAL, LFUVAL, GPTR, HPTR, INFORM, FCALC,
     +            LFC, IFC,  IT, MAXIT,  EPSF, PREC, NIPST,
     +            IWK, LIWK,  WK, LWK,  IPDEVC, WHAT, FREQ,
     +            INFO, IFLAG )
*
      IF( INFORM.GT.0 ) THEN
*
        IF( INFORM.EQ.1 ) THEN
          CALL ELFNCT( FUVAL, X, NA, NEL, FCALC, LFC, 0,
     +                 ELVAR, ELPTR, GPTR, HPTR )
        ENDIF
*
        IF( INFORM.EQ.2 .OR. INFORM.EQ.4 ) THEN
          CALL ELFNCT( FUVAL, X, NA, NEL, FCALC, LFC, 1,
     +                 ELVAR, ELPTR, GPTR, HPTR )
        ENDIF
*
        IF( INFORM.EQ.3 .OR. INFORM.EQ.4 ) THEN
          CALL ELFNCT( FUVAL, X, NA, NEL, FCALC, LFC, 2,
     +                 ELVAR, ELPTR, GPTR, HPTR )
        ENDIF
*
        GO TO 100
*
      ELSE
        WRITE(IPDEVC,1000)
        DO 200 I = 1 , NA
          WRITE(IPDEVC,1010) I,X(I)
 200    CONTINUE
      ENDIF
*
      STOP
 1000 FORMAT(/, ' VARIABLE NAME    VALUE ',
     +       /, ' -------------    ----- ')
 1010 FORMAT(7X,'X',I1,4X,D12.5)
      END