      SUBROUTINE INRIKO(FFT,NDFAST,MDATA,FNAME,NDFILE,NDDATA,NUNI2,
     *                  IFILE,IDATA,DO,NO,NSTEP,DURTN)
C
      CHARACTER FNAME(NDFILE)*30, TITL*50
      COMPLEX*8 FFT(NDFAST)
      DIMENSION MDATA(NDFILE,NDDATA),NSTEP(NDFILE),DURTN(NDFILE),
     *          NUNI2(NDFILE) 
      INTEGER*2 IWV(128)

      COMMON /STYLE/ NSTYLE,IXR,IYR,JXR,JYR,NSX,NSTY

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

      PAI = ATAN(1.0)*4.0

      MP = NSTY-NUNI2(IFILE)
      PW = 100.D0**MP

      DO 50 I = 1, NDFAST
        FFT(I) = (0.D0, 0.D0)
   50 CONTINUE

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

      WRITE(*,'(A,A,I4)')' >> ',FNAME(IFILE),MDATA(IFILE,IDATA)

      OPEN (4,FILE=FNAME(IFILE),FORM='UNFORMATTED',STATUS='OLD',
     &      ACCESS='DIRECT',RECL=256,ERR=30)

      MSTEP = NSTEP(IFILE)
      DURA  = DURTN(IFILE)

      READ(4,REC=1) IWV
      LREC = IWV(MDATA(IFILE,IDATA))
      READ(4,REC=LREC,ERR=20) TITL

      LREC = LREC+1
      READ(4,REC=LREC) IWV
      NT0=IWV(1)
      NDT=IWV(3)
      NAF=IWV(5)
      DT=1.0/FLOAT(NDT)
      AFAC= 2.0**NAF

      NT = INT(DURA/DT)
      IF(NT.GT.NT0) NT = NT0

      MM = 128
      NC   = 0
      NREC = NT/MM+1
      LREC = LREC+1

      DO 110 I = 1, NREC
        READ(4,REC=LREC) IWV
        NUM0 = MM*(I-1)
        NUM1 = NUM0+MSTEP-1 
        DO 100 K = 1, 128
          IF(NUM0+K.GT.NT) GO TO 120 
          IF(MOD(NUM1+K,MSTEP).NE.0) GO TO 100
          NC = NC+1
          FFT(NC) = CMPLX(IWV(K)*AFAC,0.0)
  100   CONTINUE
        LREC = LREC+1
  110 CONTINUE

  120 CLOSE(4)

C     **********  TRANSFORMATION TO FREQUENCY DOMAIN  **********

      NT    = NC
      NTNEW = 2
  150 IF(NTNEW.GE.NT) GO TO 200
      NTNEW = NTNEW*2
      GO TO 150
  200 NT = NTNEW 
      NO = NT/2
      DT = DT*MSTEP
      DO = 2.0*PAI/FLOAT(NT)/DT

      CALL FAST(NT,FFT,NDFAST,-1)

      DTPW     = DT*PW

      DO 250 I = 1, NT
        FFT(I) = FFT(I)*DTPW
  250 CONTINUE

      RETURN

C     *** ERROR ***

   20 WRITE(*,*) 'Channel access error.'
      STOP

   30 WRITE(*,*) 'File access error.'
      STOP

      END
