CDC   PROGRAM PDAT(INPUT,OUTPUT,CARDS,TAPE5=INPUT,TAPE6=OUTPUT,          PDAT-1
CDC  1 TAPE7=CARDS)                                                      PDAT-1
CDC                                                                      PDAT
C--- VERSION 6, DATED 20 MAY 1979                                        PDAT
                                                                         PDAT
      DIMENSION TITLE(20),D(100),DELTAD(100),TWOTH(100),QOBS(100),       PDAT
     1AINTNS(100)                                                        PDAT
                                                                         PDAT
      DATA ISPACE/3H   /                                                 PDAT
                                                                         PDAT
      INCH=5                                                             PDAT
      IOUT=6                                                             PDAT
      IPUN=7                                                             PDAT
                                                                         PDAT
      ALAMDF=1.54178                                                     PDAT
                                                                         PDAT
      READ(INCH,1000)(TITLE(I),I=1,20)                                   PDAT
1000  FORMAT(20A4)                                                       PDAT
      READ(INCH,1001) IDTYPE,ISTYLE,NSPURI,IFZON,ILOUS,ITRER,IKOHL,      PDAT
     1 IPOWD,ISPDI,D2TH,ALAMBD,AMOLWT,DENS,DDENS,ZMULT                   PDAT
1001  FORMAT(2I1,I2,6I1,6F10.0)                                          PDAT
                                                                         PDAT
      DEG=57.29577951308                                                 PDAT
      RAD=1.0/DEG                                                        PDAT
      ISTFLG=0                                                           PDAT
      IF(IDTYPE.EQ.0) IDTYPE=1                                           PDAT
      IF(ISTYLE.LT.0.OR.ISTYLE.GT.2) ISTYLE=0                            PDAT
      IF(IFZON.EQ.0) IFZON=2                                             PDAT
      IF(IFZON.EQ.9) IFZON=0                                             PDAT
      IF(ILOUS.EQ.0) ILOUS=3                                             PDAT
      IF(ILOUS.EQ.9) ILOUS=0                                             PDAT
      IF(ITRER.EQ.0) ITRER=1                                             PDAT
      IF(ITRER.EQ.9) ITRER=0                                             PDAT
      IF(IKOHL.EQ.0) IKOHL=1                                             PDAT
      IF(IKOHL.EQ.9) IKOHL=0                                             PDAT
      IF(IPOWD.EQ.0) IPOWD=2                                             PDAT
      IF(IPOWD.EQ.9) IPOWD=0                                             PDAT
      IF(ISPDI.EQ.0) ISPDI=2                                             PDAT
      IF(ISPDI.EQ.9) ISPDI=0                                             PDAT
      IF(D2TH.EQ.0.0) D2TH=0.06                                          PDAT
      IF(ALAMBD.EQ.0.0) ALAMBD=ALAMDF                                    PDAT
      IF(DDENS.EQ.0.0) DDENS=0.1                                         PDAT
      IF(DENS.EQ.0.0) DDENS=0.0                                          PDAT
      IF(ZMULT.EQ.0.0) ZMULT=1.                                          PDAT
      QCONST=4.0/(ALAMBD*ALAMBD)                                         PDAT
      AMCELL=ZMULT*AMOLWT                                                PDAT
                                                                         PDAT
      WRITE(IOUT,1003)                                                   PDAT
 1003 FORMAT(/45H0** POWDER DATA FORMAT TRANSLATION PROGRAM **,3X,       PDAT
     1 8HVERSION ,                                                       PDAT
     2 '6, DATED 20 MAY 1979'                                            PDAT
     3 /1H0,                                                             PDAT
     4 42H NO   2THETA   THETA     SINTH     SINTHSQ,8X,1HQ,9X,1HD,6X,   PDAT
     5 8HINT   NO/)                                                      PDAT
      I=0                                                                PDAT
   1  READ(INCH,1005)X,AINT                                              PDAT
1005  FORMAT(F10.0,A3)                                                   PDAT
      IF(X.LE.0.0) GO TO 2                                               PDAT
      I=I+1                                                              PDAT
      IF(IDTYPE.EQ.1) X=0.5*X                                            PDAT
      IF(IDTYPE.LE.2) X=SIN(X/DEG)                                       PDAT
      IF(IDTYPE.LE.3) X=X*X                                              PDAT
      IF(IDTYPE.EQ.5) X=0.00001*X                                        PDAT
      IF(IDTYPE.LE.5) X=QCONST*X                                         PDAT
      IF(IDTYPE.EQ.7) X=0.0001*X                                         PDAT
      IF(IDTYPE.LE.7) X=SQRT(1.0/X)                                      PDAT
                                                                         PDAT
C---WHATEVER THE INPUT TYPE, X IS NOW THE D-SPACING IN ANGSTROMS         PDAT
                                                                         PDAT
      D(I)=X                                                             PDAT
      QOBS(I)=10000.0/(X*X)                                              PDAT
      THETA=DEG*ASIN(0.5*ALAMBD/X)                                       PDAT
      TWOTH(I)=2.0*THETA                                                 PDAT
      SINTH=SIN(RAD*THETA)                                               PDAT
      SINSQ=SINTH*SINTH                                                  PDAT
      DMAX=0.5*ALAMBD/SIN(0.5/DEG*(TWOTH(I)-D2TH))                       PDAT
      DELTAD(I)=DMAX-X                                                   PDAT
      AINTNS(I)=AINT                                                     PDAT
      IF(AINT.NE.ISPACE) ISTFLG=1                                        PDAT
      WRITE(IOUT,1010) I,TWOTH(I),THETA,SINTH,SINSQ,QOBS(I),D(I),AINT,I  PDAT
1010  FORMAT(1H ,I3,1X,2F8.3,F11.6,F12.7,F11.3,F10.4,3X,A3,I5)           PDAT
      GOTO 1                                                             PDAT
                                                                         PDAT
C---END OF INPUT                                                         PDAT
                                                                         PDAT
   2  NOBS=I                                                             PDAT
      WRITE(IOUT,1020) NOBS                                              PDAT
1020  FORMAT(/17H INPUT COMPLETED,,I3,22H LINES TO BE PROCESSED)         PDAT
      IF(IFZON.EQ.0) GOTO 10                                             PDAT
                                                                         PDAT
C---FZON(6)                                                              PDAT
      DO 199 IFZN=1,IFZON                                                PDAT
      WRITE(IPUN,1100) IFZN,(TITLE(I),I=1,20),ALAMBD,AMOLWT,DENS         PDAT
1100  FORMAT(20H** FZON(6) **   COPY,I2/                                 PDAT
     1 20A4/                                                             PDAT
     2 3H9 1,17X,F10.6,3X,5H1 4 8,9X,3H1  ,F10.3,F10.4,10X)              PDAT
      IF(ISTFLG.EQ.0) WRITE(IPUN,1150) (QOBS(I),I=1,NOBS)                PDAT
      IF(ISTFLG.EQ.1) WRITE(IPUN,1151) (TWOTH(I),AINTNS(I),I=1,NOBS)     PDAT
1150  FORMAT(8(F10.4))                                                   PDAT
1151  FORMAT(8(F7.4,A3))                                                 PDAT
      WRITE(IPUN,1190)                                                   PDAT
1190  FORMAT(1H0/3HEND)                                                  PDAT
 199  CONTINUE                                                           PDAT
  10  IF(ILOUS.EQ.0) GOTO 20                                             PDAT
                                                                         PDAT
C---LOUV(7), LOUM(7) @ LOSH(3)                                           PDAT
      AMAX=30.                                                           PDAT
      BMAX=30.                                                           PDAT
      CMAX=30.                                                           PDAT
      VOLMIN=0.                                                          PDAT
      VOLMAX=6000.                                                       PDAT
      BEMIN=90.                                                          PDAT
      BEMAX=130.                                                         PDAT
      DO 299 ILOU=1,ILOUS                                                PDAT
      IF(ILOU.EQ.2) BMAX=25.                                             PDAT
      IF(ILOU.EQ.2) CMAX=20.                                             PDAT
      IF(ILOU.EQ.2) VOLMAX=3000.                                         PDAT
      WRITE(IPUN,1200) ILOU,(TITLE(I),I=1,15),NOBS,AMOLWT,DENS,DDENS,    PDAT
     1 AMAX,BMAX,CMAX,VOLMIN,VOLMAX,BEMIN,BEMAX                          PDAT
 1200 FORMAT(36H** LOUV(7), LOUM(7) @ LOSH(3) - COPY,I2,                 PDAT
     1 42H (FOR LOSH, INSERT QABCF 4F10.5 AS CARD 2)/                    PDAT
     2 15A4/                                                             PDAT
     3 I3,3X,F10.3,2F10.4/                                               PDAT
     4 7F7.0,17H  0  30.00  30.00)                                       PDAT
      WRITE(IPUN,1250) (D(I),DELTAD(I),I,AINTNS(I),D2TH,ILOU,I=1,NOBS)   PDAT
 1250 FORMAT(2F7.4,6X,4HLINE,I3,3X,A3,17X,5HD2TH=,F6.3,4H DEG,7X,        PDAT
     1 6HLOUVMS,I2)                                                      PDAT
 299  CONTINUE                                                           PDAT
  20  IF(ITRER.EQ.0) GOTO 30                                             PDAT
                                                                         PDAT
C---TRER                                                                 PDAT
      DO 399 ITRE=1,ITRER                                                PDAT
      WRITE(IPUN,1300) ITRE,(TITLE(I),I=1,20)                            PDAT
1300  FORMAT(17H** TRER **   COPY,I2/                                    PDAT
     1 20A4)                                                             PDAT
      WRITE(IPUN,1350) (D(I),I,AINTNS(I),I=1,NOBS)                       PDAT
1350  FORMAT(F15.4,6H  LINE,I3,2X,A3,43X,4HTRER)                         PDAT
      WRITE(IPUN,1390) ALAMBD                                            PDAT
1390  FORMAT(47HMONOSET=7, MONOGAM=1, MONO=130, MERIT=20, WAVE=,F8.6,    PDAT
     1 16H, CHOICE=4, END*,9X)                                           PDAT
 399  CONTINUE                                                           PDAT
  30  IF(IKOHL.EQ.0) GOTO 40                                             PDAT
                                                                         PDAT
C---KOHL                                                                 PDAT
      DO 499 IKOH=1,IKOHL                                                PDAT
      WRITE(IPUN,1400) IKOH,(TITLE(I),I=1,20),ALAMBD                     PDAT
1400  FORMAT(17H** KOHL **   COPY,I2/                                    PDAT
     1 20A4/                                                             PDAT
     2 5H $OPA,75X/                                                      PDAT
     3 34H H4MAX=4, K4MAX=4, L4MAX=4, WLENG=,F10.6,1H,,35X)              PDAT
      WRITE(IPUN,1450) (D(I),I=1,NOBS)                                   PDAT
1450  FORMAT(6H D=   ,9(F7.4,1H,),2X/                                    PDAT
     1 3X,11(F6.4,1H,)/                                                  PDAT
     2 (6X,10(F6.4,1H,),4X))                                             PDAT
      WRITE(IPUN,1490)                                                   PDAT
 1490 FORMAT(5H $END)                                                    PDAT
 499  CONTINUE                                                           PDAT
  40  IF(IPOWD.EQ.0) GOTO 50                                             PDAT
                                                                         PDAT
C---POWDER(49)                                                           PDAT
      DO 599 IPOW=1,IPOWD                                                PDAT
      WRITE(IPUN,1500) IPOW,((TITLE(I),I=1,20),J=1,2)                    PDAT
1500  FORMAT(22H** POWD(49S) **   COPY,I2/                               PDAT
     1 6H+TITLE/                                                         PDAT
     2 20A4/                                                             PDAT
     3 4H*END//                                                          PDAT
     4 6H+INPAT/                                                         PDAT
     5 20A4/                                                             PDAT
     6 4H*END/                                                           PDAT
     7 4H*2,7)                                                           PDAT
      IF(ISTYLE.NE.0) WRITE(IPUN,1501) ISTYLE                            PDAT
1501  FORMAT(3H*5,,I1)                                                   PDAT
      IF(ALAMBD.NE.ALAMDF) WRITE(IPUN,1502) ALAMBD                       PDAT
1502  FORMAT(3H*7,,F10.6)                                                PDAT
      IF(AMCELL.NE.0.0) WRITE(IPUN,1503) AMCELL                          PDAT
1503  FORMAT(3H*8,,F10.3)                                                PDAT
      IF(DENS.NE.0.0) WRITE(IPUN,1504) DENS,DDENS                        PDAT
1504  FORMAT(3H*9,,2F8.4)                                                PDAT
      IF(NSPURI.NE.0) WRITE(IPUN,1505) NSPURI                            PDAT
1505  FORMAT(4H*10,,I2)                                                  PDAT
      WRITE(IPUN,1510)                                                   PDAT
1510  FORMAT(2H*D)                                                       PDAT
      IF(ISTYLE.EQ.0) WRITE(IPUN,1550) (QOBS(I),I=1,NOBS)                PDAT
1550  FORMAT(F10.5)                                                      PDAT
      IF(ISTYLE.NE.0) WRITE(IPUN,1551) (QOBS(I),AINTNS(I),I=1,NOBS)      PDAT
1551  FORMAT(F10.5,2X,A3)                                                PDAT
      WRITE(IPUN,1590)                                                   PDAT
1590  FORMAT(1H//2H*0)                                                   PDAT
 599  CONTINUE                                                           PDAT
   50 IF(ISPDI.EQ.0) GOTO 60                                             PDAT
                                                                         PDAT
C---SPDIF(4)                                                             PDAT
      DO 699 ISPD=1,ISPDI                                                PDAT
      WRITE(IPUN,1600) ISPD,ISPD,(TITLE(I),I=1,17),ISPD,                 PDAT
     1 ISTYLE,D2TH,ALAMBD,ISPD                                           PDAT
 1600 FORMAT(21H** SPDIF(4) **   COPY,I2/                                PDAT
     1 10HSPDIF    4,63X,5HSPDIF,I2/                                     PDAT
     2 7HTITLE  ,16A4,A1,6H SPDIF,I2/                                    PDAT
     3 7HDEFPAR ,I3,5X,F5.3,F10.6,43X,5HSPDIF,I2)                        PDAT
      ZM=ZMULT                                                           PDAT
      IF(AMOLWT.EQ.0.) ZM=0.                                             PDAT
      IF((NSPURI.NE.0).OR.(AMOLWT.NE.0.).OR.(DENS.NE.0.))                PDAT
     1 WRITE(IPUN,1601) NSPURI,AMOLWT,DENS,DDENS,ZM,ISPD                 PDAT
 1601 FORMAT(7HCELMAX ,I3,10X,F10.3,F10.4,F5.3,F5.2,23X,5HSPDIF,I2)      PDAT
      IF(ISTYLE.NE.1) WRITE(IPUN,1650) (TWOTH(I),AINTNS(I),I,ISPD,       PDAT
     1 I=1,NOBS)                                                         PDAT
 1650 FORMAT(4HLINE,6X,F10.5,A3,38X,I3,9X,5HSPDIF,I2)                    PDAT
      IF(ISTYLE.EQ.1) WRITE(IPUN,1651) (TWOTH(I),AINTNS(I),I,ISPD,       PDAT
     1 I=1,NOBS)                                                         PDAT
 1651 FORMAT(4HLINE,6X,F10.5,7X,A3,31X,I3,9X,5HSPDIF,I2)                 PDAT
      WRITE(IPUN,1690) ISPD                                              PDAT
 1690 FORMAT(3HEND,70X,5HSPDIF,I2)                                       PDAT
  699 CONTINUE                                                           PDAT
      WRITE(IPUN,1699) ISPD                                              PDAT
 1699 FORMAT(6HFINISH,67X,5HSPDIF,I2)                                    PDAT
   60 CONTINUE                                                           PDAT
                                                                         PDAT
      STOP                                                               PDAT
      END                                                                PDAT
 
