      PROGRAM IGOR
C        1         2         3         4         5         6         7
C23456789012345678901234567890123456789012345678901234567890123456789012
C
C     TWEEDE VERSIE
C
C     INTRO VAN HET PROGRAMMA
C
C
C       LAST EDIT 21 Oct 98
C
     
      CHARACTER*80 FNAMEOUT 

      WRITE(6,*) 'Supply name of output file: '
      write (6,*) 'Type "exit" if you wanna leaf.'
      READ(5,9000) FNAMEOUT
      IF (FNAMEOUT .EQ. 'exit') then
        write(6,*) 'I say hello and wave goodbye.'
        stop
      endif
      OPEN(10,STATUS='UNKNOWN',FILE=FNAMEOUT)



      CALL HISTOGRAM(FNAMEOUT)
      CALL REFLECTION(FNAMEOUT)

      CLOSE (10)

 9000 format (a80)

      END

      SUBROUTINE HISTOGRAM(FNAMEOUT)
      CHARACTER*80 FNAMEIN,FNAMEOUT
      character*80 card,card1,card2
      character*2  err
      character*6  recnr	
      character*10 xax
      character*12 iobs,icalc
      integer      j,recno
      real         step,posout,posnew,factor
C
C     OPENEN VAN FILES
C



      OPEN(9,STATUS='OLD',FILE='export.hst')
C
C     INLEZEN JOE BASTARD
C
24    READ (9,9000,END=100) card
      J=(INDEX(card,'RecNo'))
      if (J .ne. 2) goto 24

25    READ (9,9000,END=100) card1
      READ (9,9000,END=100) card
      card2=card1
      card1=card


30    READ (9,9000,END=100) card
      J=(INDEX(card,'RecNo'))
      if (J .ne. 2) then
         read (card2,9001) recnr, err, xax,iobs,icalc
         if (xax .ne. '********') then
           read(xax,9002) posnew
           posold = posnew
         else
            if (step .eq. 0) then
	     write (6,*) 'Give stepsize, this value should be something'
             write (6,*) 'like 0.0001, or a multiple of this.'
             read (5,*) step
             factor=1+step
	    endif
            posnew=posold*factor
            posold=posnew        
         endif
         WRITE (10,8999)  posnew,iobs,icalc
         card2=card1
         card1=card
         GOTO 30
      else
         goto 25
      endif

 100   CONTINUE


C
C
C     EXTRO VAN HET PROGRAMMA
C
      CLOSE (9)
      

C
C     SCHRIJF EN LEES FORMATS
C
 8999 format (f9.5,1X,A12,1X,A12)
 9000 format (a80)
 9001 FORMAT (A6,A2,A10,A12,A12)
 9002 format (f7.5)
 9003 format (a7)
      END


      SUBROUTINE REFLECTION(FNAMEOUT)

      CHARACTER*80 FNAMEIN,FNAMEOUT
      character*80 card,card1,card2,rest
      integer      j,three1,three2,three3,four,five1,five2
      real         eight
C
C     OPENEN VAN FILES
C

      OPEN(9,STATUS='OLD',FILE='export.ref')
C
C     INLEZEN JOE BASTARD
C
24    READ (9,9000,END=100) card
      J=(INDEX(card,'Iref'))
      if (J .ne. 3) goto 24

25    READ (9,9000,END=100) card1
      READ (9,9000,END=100) card
      card2=card1
      card1=card


30    READ (9,9000,END=100) card
      J=(INDEX(card,'Iref'))
      if (J .ne. 3) then
      read (card2,9001) five1,three1,three2,three3,four,
     1five2,eight,rest
      write (10,9002) five2,eight
      card2=card1
      card1=card
      GOTO 30
      else
      goto 25
      endif

 100   CONTINUE


C
C
C     EXTRO VAN HET PROGRAMMA
C
      CLOSE (9)
      

      write(6,*)'See you later'
C
C     SCHRIJF EN LEES FORMATS
C
 9000 format (a80)
 9001 format (i6,3I3,i4,i5,f8.5,a48)
 9002 format (i5,1x,f8.5)
      END


