      SUBROUTINE INPUT (IEF)
C
C        THIS ROUTINE REVISED   MARCH 10, 1970
C
C             SUBROUTINE TO READ STRUCTURE FACTOR CARDS, COMPUTE
C              SCATTERING FACTORS AND WEIGHTS
C
      DIMENSION HK(3)
C
      INCLUDE 'RFINE.PRM'
      INCLUDE 'D.INC'
      INCLUDE 'E.INC'
      INCLUDE 'CNSTRS.INC'
      INCLUDE 'F.INC'
      INCLUDE 'G.INC'
      INCLUDE 'C.INC'
      INCLUDE 'EXTN.INC'
C
      DATA RAD/.0174533/
C
      GO TO (300,310,320,320),IEF
  300 READ(INN,FRMT,END=420)IH,FOBS,SIGMA,EXBETA,I,MREJ,IEF,TTH,OMEG
     1,CHI,PHI
C        CALCULATE ANGLES FOR ANISOTROPIC EXTINCTION
      EXANG(3)=CHI*RAD
      EXANG(4)=PHI*RAD
      EXANG(1)=RAD*0.5*TTH
      EXANG(2)=RAD*OMEG
      IF(MREJ.EQ.0)MREJ=1
      IF(IEF.NE.0)GO TO 420
      GO TO 330
  310 READ(INN,FRMT,END=420)IH,MREJ,I,FOBS,EXBETA,SIGMA
      IF(IH(1).EQ.0.AND.IH(2).EQ.0.AND.IH(3).EQ.0)GO TO 310
      GO TO 330
  320 READ(INN,FRMT,END=420)IH,MREJ,FOBS,SIGMA
      IF(IH(1).EQ.0.AND.IH(2).EQ.0.AND.IH(3).EQ.0)GO TO 320
      I=1
  330 RHO=0.0
      IF(IH(1).EQ.99.AND.IH(2).EQ.99.AND.IH(3).EQ.99)GO TO 420
      MREJ=MREJ-1
      IF(SIGMA.EQ.0.0)SIGMA=1.0
      DO 340 K=1,3
      H(K)=IH(K)
      HK(K)=H(K)*RECELL(K)
  340 RHO=RHO+HK(K)**2
      RHO=(RHO+2.0*(HK(1)*HK(2)*RECELL(6)+HK(1)*HK(3)*RECELL(5)+HK(2)*HK
     1 (3)*RECELL(4)))*0.25
      IF(FOBS.GT.FOMAX)FOMAX=FOBS
      IF(FOBS.LT.FOMIN)FOMIN=FOBS
      IF(RHO.GT.RHOMX)RHOMX=RHO
      IF(RHO.LT.RHOMN)RHOMN=RHO
      SIG=SQRT(RHO)
      IF(IEF.GE.3)TTH=2.*ASIN(SIG*WVLNTH)
      IF(IEF.GE.3)EXBETA=BETFAC/SIN(TTH)
      IF(IEF.EQ.4)EXBETA=EXBETA*((1.+COS(TTH)**4)/(1.+COS(TTH)**2))
      IEF=0
C             COMPUTE SCATTERING FACTORS
                             DO 350 L=1,NSCAT
      SCAT(L)=FCURVE(9,L)+ANOM(1,L)
                             DO 350 M=1,8,2
  350 SCAT(L)=SCAT(L)+FCURVE(M,L)*EXP(-FCURVE(M+1,L)*RHO)
      WT=SIGMA
C        COMPUTE SIGMA(F) FROM INFORMATION ON CARD
      GO TO (410,360,370,390,390,400),IWT
C        SIGMA(F**2) ON CARDS
  360 WT=0.5*SIGMA/FOBS
      GO TO 410
C        WEIGHT ON CARD
  370 WT=1.0/SQRT(WT)
      IF(MREF)380,410,380
  380 WT=2.0*FOBS*WT
      GO TO 410
C        USE SPECIAL ROUTINE
  390 CALL WEIGHT
      IF(IWT-4)370,410,370
C     INCORPORATE 'IGNORANCE FACTOR'.
  400 IF(MREJ.EQ.0)WT=SQRT(WT**2+(WTFAC*FOBS)**2)
C        SET SCALE FACTOR FOR REFLECTION
  410 IF(I.EQ.0)THEN
        ISCL=1
      ELSE
        ISCL=I
      END IF
C
C CONVERT ZACHARIASEN BETA TO GAMMA-S IF BECKER-COPPENS EXTINCTION
C
      IF(IZACH.EQ.0)THEN
        STH=SIG*WVLNTH
        CTH=SQRT(1.0-STH**2)
        IF(INEUT.GT.0)THEN
C X-RAY SOURCE
          COSTTH=CTH**2-STH**2
          EXBETA=EXBETA*(1.0+COSTTH)/(1.0+COSTTH**2)/0.1589
        END IF
        EXBETA=EXBETA*2.0*STH*CTH*WVLNTH*1.0E-5
      END IF
      RETURN
  420 IEF=1
      RETURN
      END
