C PROGRAM TO CALCULATE 2-THETA AND I/I0 FOR POWDER PATTERNS
      DIMENSION THET(250), BRIGHT(250),D(250)
      DATA YES/'Y'/
      RAD = 6.283184/360.
      ITYP = 6
      IREAD = 5
      BMAX = 0.0
      WRITE(ITYP,1)
    1 FORMAT(/'PROGRAM TO CALCULATE D AND I/I0 FOR POWDER PATTERNS'/
     1' TYPE LAMBDA FOR K ALPHA 1 IN F10.6')
      READ(IREAD,5)WAVE
    5 FORMAT(F10.6)
   50 WRITE(ITYP,10)
   10 FORMAT(/'TYPE 2-THETA AND INTENSITY WITH DECIMAL IN 2F10.6'/
     1'AFTER ALL DATA HAS BEEN ENTERED HIT CARRIAGE RETURN')
      I = 1
  100 READ(IREAD,15)THET(I),BRIGHT(I)
   15 FORMAT(2F10.6)
      IF(THET(I) .EQ.0.0) GO TO 300
      IF(BMAX.LT.BRIGHT(I))BMAX = BRIGHT(I)
      D(I) = WAVE/(2.0*SIN(THET(I)*RAD/2.0))
      I = I + 1
      GO TO 100
  300 N = I - 1
      T1 = 4. / WAVE**2
      DELTAT = .001
      WRITE(ITYP,20)
   20 FORMAT(//' 2-THETA',6X,'D LO',7X,'D HI',9X,'D',7X,'I')
      DO400 I=1,N
      BRIGHT(I) = BRIGHT(I) * 100. / BMAX
      DELTAD = D(I)**2 * SQRT(T1 - 1.0/D(I)**2)     * DELTAT
      DHI = D(I) + DELTAD
      DLO = D(I) - DELTAD
      WRITE(ITYP,25)THET(I),DLO,DHI,D(I),BRIGHT(I)
   25 FORMAT(F8.3,3(3XF8.4),3XF6.0)
  400 CONTINUE
      WRITE(ITYP,30)
   30 FORMAT(//'DO YOU WISH ANOTHER RUN?  (YES OR NO)')
      READ(IREAD,35,END=90)Y
   35 FORMAT(A1)
      IF(Y.NE.YES) GO TO 90
      WRITE(ITYP,500)
500   FORMAT(/,'DO YOU WISH TO CHANGE LAMBDA?  (YES OR NO)')
      READ(IREAD,35)Y
      IF(Y.NE.YES) GO TO 502
      WRITE(ITYP,501)
501   FORMAT(/,'INPUT LAMBDA IN F10.6')
      READ(IREAD,5)WAVE
502   BMAX=0.0
      GO TO 50
   90 CALL EXIT
      END
