      PROGRAM EXTRACT
      REAL*8 A(10000,20)
      INTEGER S(20),D,C
      OPEN(1, FILE='CLUSDAT')
      OPEN(2, FILE='CDAT')
      OPEN(3, FILE='VARS')
      READ(1,*) M,D,C
      DO I = 1,M
        READ(1,*) (A(I,J),J=1,D)
      END DO
      WRITE(*,*) 'NUMBER OF VARS TO SELECT'
      READ(3,*) KSEL
      DO K = 1,KSEL
        READ(3,*) S(K)
      END DO
      WRITE(2,*) M,KSEL,C
      DO I = 1,M
        WRITE(2,30) (A(I,S(J)),J=1,KSEL)
      END DO
  30  FORMAT(15F10.4)
      END
