ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
	subroutine pithy(mxy,iu,pith,poff)
c
c argument declarations.
	integer iu,mxy,pith(mxy)
	logical poff
c local declarations
	integer p,j
	integer ifmt
	character junk*80,rfmt*40,infl*50,key*1
	logical fok
c
c begin
c
	write(*,'(//1x,''Is there a pith offset file ?'')')
	write(*,'(1x,''[t]rue-[f]alse  : '',$)')
	read(*,*)poff
	if(poff)then
10	  write(*,'(/1x,''Enter the name of the pith offset file.'')')
	  write(*,'(1x,''NOTE: the order of pith offset information must follow'')')
	  write(*,'(1x,''the order of the records in the raw ring width file > '')')
	  write(*,'(//1x,''Enter pith offset file name : '',$)')
	  read(*,'(a)')infl
	  inquire(file=infl,exist=fok)
	  if(.not.fok)then
	      write(*,'(//1x,''File > '',a,'' < not found'')')infl
	      write(*,'(1x,''Please enter a new file name or terminate the program'')')
	      write(*,'(1x,''by entering [\]  : '',$)')
	      read(*,*)key
	      if(key.ne.char(92))then
	         goto 10
	      else
	         goto 1000
	      endif
	  endif
20	  write(*,'(//1x,''Select method to read the offset information.'')')
	  write(*,'(1x,''Single column offset ie. <i4> [1]'')')
	  write(*,'(1x,''User defined fortran format   [2]'')')
	  write(*,'(1x,''Enter option number  : '',$)')
	  read(*,*)ifmt
	  write(*,'(/1x,''Enter number of title/header lines'')')
	  write(*,'(1x,''to skip  [if none enter 0] : '',$,)')
	  read(*,*)p
	  select case(ifmt)
	    case(1)
	       rfmt='(i4)'
	    case(2)
		write(*,'(/1x,''Enter format to read just the '')')
		write(*,'(1x,''offset values (within parentheses)'')')
		write(*,'(1x,''[e.g.,(2x,i3)]  : '',$)')
		read(*,'(a)')rfmt
	    case default
		write(*,'(/1x,''Please enter a value between 1 and 2 '')')
              pause' Hit RETURN and try again.'
		goto 20
	  end select
	  open(unit=iu,file=infl,status='old')
	  write(*,'(/1x,''Reading offset file: '',a)')infl
	  do j=1,p
	     read(iu,'(a)')junk
	     write(*,'(1x,i2,''Title Line: '',a)')j,junk
	  enddo
	  poff=.true.
	  j=1	     
30	  read(iu,rfmt,end=40,err=900)pith(j)   
	     j=j+1
	     if(j.gt.mxy)goto 901
	  goto 30
	else  !no pith offset information, set pith offsets all to 0
	  do j=1,mxy
	     pith(j)=0
	  end do
	  write(*,'(/1x,''With no pith offset information all records will be  '')')
	  write(*,'(1x,''aligned together, comperable to a pith offset = 0'',/)')
	  poff=.false.
	  return
c
	endif
c
40	close(iu)
c
	return
c
c error msgs
900	write(*,'(/1x,''There was an error reading the pith offset '')')
	write(*,'(1x,''values in file  : '',a)')infl
	write(*,'(1x,''Do you want to try again? or quit?'')')
	write(*,'(1x,''enter [\] to quit  : '',$)')
	read(*,*)key
	close(iu)
	if(key.ne.char(92))then
	   goto 20
	else
	   goto 1000
	endif
	goto 999
901	write(*,'(/1x,''The number of pith offset values read exceeds the'')')
	write(*,'(1x,''the dimensions of the array in which they are stored'')')

999	write(*,'(/1x,''This is a fatal error, there is no recovery '')')
1000	write(*,'(1x,''Program Terminating '')')
	stop
	end

