      PROGRAM LPLOT2N
C
C     LPLOT VERSION 2.02   8 DEC. 1989
C
      PARAMETER (NDFAST=8200,NDFILE=21,NDDATA=40,NDLINE=21)

      COMPLEX*8 FFT(NDFAST),WORK(NDFAST)
      DIMENSION Y(NDFAST),MDATA(NDFILE,NDDATA),
     *          NTYPE(NDFILE),NDATA(NDFILE),
     *          NUNI1(NDFILE),NUNI2(NDFILE),NMUL(NDFILE),
     *          NDVA(3),NST(2),NSTEP(NDFILE),DURTN(NDFILE),
     *          LINT(NDLINE),LINW(NDLINE),LINA(NDLINE)
      CHARACTER FNAME(NDFILE)*30

C     **********  INPUT OPERATION DATA  **********

      CALL INODATN(MDATA,FNAME,NTYPE,NDATA,NUNI1,NUNI2,NMUL,
     *            NSTEP,DURTN,NDVA,NST,LINT,LINW,LINA,NDFILE,
     *            NDDATA,NDLINE,IPAPER,IX0,IY0,NFILE,NOVRW,
     *            NINIT,NTERM) 

C     **********  INITIALIZATION  **********

      IF(NINIT.EQ.1) THEN
        CALL LINIT(IPAPER)
        CALL LSOT (IX0,IY0)
        CALL LLATR(LINT(1),LINW(1),LINA(1))
      END IF

      IGN0   = 0
      NCOUNT = 0
      NTOTAL = 0
      DO 50 I = 1, NFILE
        NTOTAL = NTOTAL + NDATA(I)
   50 CONTINUE

C     **********  LOOP FOR INPUT & PLOT  **********

      DO 300 IFILE = 1, NFILE
        DO 200 IDATA = 1, NDATA(IFILE)

C         **********  INPUT WAVE DATA  **********

          IF(NTYPE(IFILE).NE.3) THEN
            CALL  INBEM(FFT,NDFAST,DO,NO,IFILE,IDATA,NUNI2,
     *                  MDATA,NTYPE,FNAME,NDFILE,NDDATA)
          ELSE 
            CALL INRIKO(FFT,NDFAST,MDATA,FNAME,NDFILE,NDDATA,NUNI2,
     *                  IFILE,IDATA,DO,NO,NSTEP,DURTN)
          END IF

C         **********  PLOT DATA  **********

          DO 100 J = 1, 3

            IF(NDVA(J).EQ.0) GO TO 100

            IF(NST(1).EQ.1) THEN
              CALL MKSPC(FFT,Y,NUNI1,NDFAST,NDFILE,
     *                   DO,DELTA,NO,NN,XSI0,J,IFILE)
              CALL PLOTS(Y,NDFAST,DELTA,NN,XSI0,NDVA,NST,LINT,
     *                   LINW,LINA,NDLINE,NTOTAL,NCOUNT,NUMS,
     *                   NUMT,J,NOVRW,NRET)
              IF(NRET.EQ.1) GO TO 400
              IGN0 = IGN0 + 1
              NUMS = NUMS + 1
            END IF

            IF(NST(2).EQ.1) THEN
              CALL MKTIM(FFT,WORK,NUNI1,NMUL,NDFAST,NDFILE,
     *                   DO,NO,DT,NT,XSJ0,Y,J,IFILE)
              CALL PLOTT(Y,NDFAST,DT,NT,XSJ0,NDVA,NST,LINT,LINW,LINA,
     *                   NDLINE,NTOTAL,NCOUNT,NUMS,NUMT,J,
     *                   NOVRW,NRET)
              IF(NRET.EQ.1) GO TO 400
              IGN0 = IGN0 + 1
              NUMT = NUMT + 1
            END IF

  100     CONTINUE

          IF(NOVRW.EQ.1) IGN0 = 0
          NUMS   = 0
          NUMT   = 0
          NCOUNT = NCOUNT + 1

  200   CONTINUE
  300 CONTINUE
          
C     **********  TERMINATION  **********

  400 WRITE(*,*)
      IF(NTERM.EQ.1) CALL LTERM

      STOP
      END
