      SUBROUTINE SCFINP(TITLE,ITAPE)
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      CHARACTER*(*) TITLE
      DIMENSION NI(8),NOCC1(8),NOCC2(8),IOCC(150)
      LOGICAL IOPEN,OPN
c     Maximum string length of terminal lines
      INTEGER LINELEN
      PARAMETER (LINELEN=80)
      CHARACTER*(linelen) FMTA
      COMMON /FLAGS/IFLAGS(100),IFLAGS2(500)
C
      DATA ZERO,ONE,IONE/0.D0,1.D0,1/
C
C   SET DEFAULTS
C
      IPRCT=-5
      ISCF=IFLAGS(5)
      I2CON=0
      INFLG=-1
      IVECT=-1 
      IF(IFLAGS(1).GT.0) IVECT=0
      IPUNCH=8
      IPRINT=0
      IDEBUG=0 
      ISAVE=0
      ITMAX=IFLAGS(16)
      ISTO=20
      MICMX=0
      IAUTO=0
      IDFIX=1
      ITPREP=0
      ITCON=0
      IALL=1
      IVO=0
      IGRAD=0
      IDMAT=0
      DAMP=ZERO
      DAMP1=ONE
      FMTA='(3F25.15)'

C  GET NUMBER OF IRREPS AND OCCUPATIONS FROM JOBARC
      CALL GETREC(20,'JOBARC','COMPORDR',IONE,LAU)
      CALL GETREC(20,'JOBARC','OCCUPYA ',LAU,NOCC1)
      IF (IFLAGS(11).NE.0) THEN
         CALL GETREC(20,'JOBARC','OCCUPYB ',LAU,NOCC2)
      ELSE
         DO LA = 1, LAU
            NOCC2(LA) = NOCC1(LA)
         END DO
      END IF
      DO 11 LA=1,LAU
         NI(LA)=MAX(NOCC1(LA),NOCC2(LA))
 11   CONTINUE

C  OPEN FILE
      INQUIRE (FILE='SCFINPT', OPENED=OPN)
      IF (.NOT.OPN) THEN
         OPEN (ITAPE, FILE='SCFINPT', FORM='FORMATTED',
     $     STATUS='UNKNOWN')
      ELSE
         WRITE(6,*) ' FILE ',ITAPE,' IS OPEN, CAN NOT WRITE IT'
      ENDIF
C
C  WRITE SCF INPUT FILE
C
      REWIND ITAPE
      WRITE(ITAPE,501) TITLE
  501 FORMAT(A)
      WRITE(ITAPE,502) IPRCT,ISCF,I2CON,INFLG,IVECT,IPUNCH,IPRINT,
     1                 IDEBUG,ISAVE,ITMAX,ISTO,MICMX,IAUTO,IDFIX,
     2                 ITPREP,ITCON,IALL,IVO,IGRAD,IDMAT
  502 FORMAT(24I4)
C
      WRITE(ITAPE,503) (NI(LA),LA=1,LAU)
  503 FORMAT(20I4)
C
      IOPEN=.FALSE.
      DO 1 LA=1,LAU
         IF(NOCC1(LA).NE.0.OR.NOCC2(LA).NE.0) THEN
            IF(NOCC1(LA).NE.NOCC2(LA)) IOPEN=.TRUE.
            DO 2 I=1,NOCC1(LA)
               IOCC(I)=1
 2          CONTINUE 
            DO 3 I=1,NOCC2(LA)
               IOCC(I)=IOCC(I)+1
 3          CONTINUE
            WRITE(ITAPE,503) (IOCC(I),I=1,NI(LA))
         ENDIF
 1    CONTINUE
C
      IF(IOPEN) THEN
         WRITE(ITAPE,*) 'HERE YOU HAVE TO INSERT THE OPEN-SHELL ENERGY',
     $      'COEFFICENTS'    
      ENDIF
C
      WRITE(ITAPE,504) DAMP,DAMP1
 504  FORMAT(2F20.0)
C
      WRITE(ITAPE,505) FMTA
 505  FORMAT(A80)
C
      WRITE(ITAPE,503) IONE
C
      CLOSE(ITAPE)
      RETURN
      END
