C
C ***********************************************************************
C
C  FIX_10.FOR----READS 2004 ICPSR DATA FILE -- ELEC2004_CLASS_2007.DAT
C                  AND ANNENBERG2004_THERMOMETER2.DAT AND WRITES THE
C                  10 COMMON THERMOMETERS TO DISK
C
C                           22 NOVEMBER 2007
C
C ***********************************************************************
C
      dimension KTHERM1(100),LC7PS(100),LSPEND(100),LDEFENSE(100),
     C          LGOVJOB(100),LGOVBLK(100),LWOMEN(100),KTHERM2(100)
      INTEGER*2 ITIM1,ITIM2,ITIM3,ITIM4,JTIM1,JTIM2,JTIM3,JTIM4
      CHARACTER*2 KSTATE
C
      OPEN(1,FILE='C:\ATIME2007_ANNENBERG\ELEC2004_CLASS_2007.DAT',
     C                                       STATUS='OLD')
      OPEN(2,FILE=
     C     'C:\ATIME2007_ANNENBERG\ANNENBERG2004_ALLTHERMS3.DAT',
     C                                       STATUS='OLD')
      OPEN(20,FILE='ELEC2004_ONLY_10.DAT')
      open(22,file='ANNENBERG_ONLY_10.DAT')
C 
  100 FORMAT(1X,2I4,14X,8I3,3X,2I3,77X,2I3,3X,I3,6X,I3,69X,I3)
C
C  200 FORMAT(1X,2I4,1X,I1,1X,A2,4I2,1X,14I3,1X,I2,5I1,1X,I1,1X,
C     C       I2,5I1,I2,5I1,I2,5I1,I2,5I1,I2,5I1,1X,I2,1X,I1,1X,
C     C       I2,1X,I2,1X,I1,1X,I1,1X,33I3)
C
C  150 FORMAT(I10,5I2,8X,4I2,8X,I2)
  150 FORMAT(I10,15I3)
  200 FORMAT(2X,2I4,1X,15I3)
  250 FORMAT(I10,1X,15I3)
  300 FORMAT(' NUMBER OF RECORDS READ NES      ',3I6)
  350 FORMAT(' NUMBER OF RECORDS READ ANNENBERG',3I6)
 1000 format(22x,4(i2.2,'.'))
 1001 format(' ELAPSED TIME OF JOB  ',4(i2.2,'.'))
      call gettim(itim1,itim2,itim3,itim4)
C
C ####################
C ***  NES FORMAT  ***
C ELEC2004_CLASS_2007.DAT
C    10    2    2   10    0    0
C     1    1    0    9    3
C    0.001  -0.020   2.000   2.000   1.500   0.000 100.000
C (9A1,14X,8F3.0,3X,2F3.0)
C 777888999
C BUSH      1   1
C KERRY     2   2
C NADER     3   5
C CHENEY    4   3
C EDWARDS   5   4
C LBUSH     6   7
C HCLINTON  7   9
C BCLINTON  8   8
C ASHCROFT  9   6
C MCCAIN   10  10
C
C #####################
C  ***  ANNENBERG FORMAT  ***
C
C (10A1,5F2.0,8X,4F2.0,8X,F2.0)
C 99
C BUSH  
C KERRY 
C CHENEY   
C EDWARDS
C NADER 
C ASHCROFT
C LBUSH
C BCLINTON
C HCLINTON
C MCCAIN
C
C
C  READ 2004 ICPSR DATA FILE AND WRITE OUT 10 THERMOMETERS
C     IN SAME ORDER AS ANNENBERG STUDY
C    
      I=0
  500 read(1,100,end=400)ID1,ID2,
     C              (KTHERM1(J),J=1,15)
      I=I+1
C
      WRITE(20,200)ID1,ID2,
     C              (KTHERM1(J),J=1,2),(KTHERM1(J),J=4,5),KTHERM1(3),
     C              KTHERM1(9),KTHERM1(6),KTHERM1(8),KTHERM1(7),
     C              KTHERM1(10),
     C              KTHERM1(14),KTHERM1(12),KTHERM1(11),KTHERM1(13),
     C              KTHERM1(15)
C
      GO TO 500
  400 WRITE(*,300)I
C
C  READ ANNENBERG THERMOMETERS, MULTIPLY BY 10, AND WRITE THEM TO DISK
C
      I=0
  550 READ(2,150,END=450)ID3,(KTHERM1(J),J=1,15)
      I=I+1
      DO 1 J=1,15
      IF(KTHERM1(J).NE.999)KTHERM1(J)=KTHERM1(J)*10
      IF(KTHERM1(J).EQ.999)KTHERM1(J)=888
  1   CONTINUE
      WRITE(22,250)ID3,(KTHERM1(J),J=1,15)
      GO TO 550
  450 WRITE(*,350)I
C
      call gettim(jtim1,jtim2,jtim3,jtim4)
      write(*,1000)itim1,itim2,itim3,itim4
      write(*,1001)jtim1,jtim2,jtim3,jtim4
      stop
      end
