C    DASPEC.FTN
C   PROGRAM TO REPACK NIH ELEMENTAL DATA BASE INTO DIRECT ACCESS
C       FILE TO BE READ BY SPECPLOT
C
C    WRITTEN BY M.F.GARBAUSKAS MARCH,1982
C
C    FILE READ: MASTER.TRS
C    FILE CREATED: LAMBDA.SPC
C        BOTH ON PSEUDO DEVICE XF1:
C
C   MAXIMUM 120 LINES PER ELEMENT DICTATED BY DIMENSION OF ARRAYS
C      AND RECORDSIZE OF LAMBDA.SPC
C
      DIMENSION WAVE(120)
      DIMENSION INT(120)
      OPEN(UNIT=1,NAME='XF1:MASTER.TRS',TYPE='OLD',READONLY)
      OPEN(UNIT=2,NAME='XF1:LAMBDA.SPC',TYPE='NEW',ACCESS='DIRECT'
     % ,RECORDSIZE=180)
C
      K=1
100   READ(1,9100,END=900,ERR=800)IZ,ITEST,W,RELINT
9100  FORMAT(I2,13X,A2,2X,F12.8,1X,F7.3)
200   IF(K.EQ.1)IOLD=IZ
      IF(IOLD.NE.IZ)GO TO 500
      IF(ITEST.EQ.'AB')GO TO 100
      IF(RELINT.LT.0.01)GO TO 100
      WAVE(K)=W
      INT(K)=100.*RELINT
      K=K+1
      IF(K.LE.120)GO TO 100
      WRITE(5,9500)IZ
9500  FORMAT(' * LINE COUNT EXCEEDED FOR ELEMENT NO. ',I3)
      STOP
500   K=K-1
      WRITE(2'IOLD)WAVE,INT
      WRITE(5,9600)IOLD,K
9600  FORMAT(' * ELEMENT NO. ',I3,' HAS ',I3,' LINES STORED')
      DO 550 I=1,120
      WAVE(I)=0.
      INT(I)=0
550   CONTINUE
      K=1
      GO TO 200
800   WRITE(5,9800)IZ,K
9800  FORMAT(' * ERROR READING ELEMENT NO. ',I3,'  LINE NO. ',I3)
      STOP
900   CLOSE(UNIT=1)
      CLOSE(UNIT=2)
      STOP
      END
