       SUBROUTINE readhamontable4(maxyear,ntyp,doffDA,doffDB,doffZD,
     *  myearmin,myearmax)

c    readhamontable2 reads dats from hamon table 2 for deep probes
c    deployed in low and high temperature waters

      parameter (icmax=10)
      character*80 text,filename
     
      dimension doffDA(maxyear,ntyp)
      dimension doffDB(maxyear,ntyp)
      dimension doffZD(maxyear,ntyp)

      dimension icomma(icmax,2)

      call extraname('sys.inf'//CHAR(0),
     * 'hamon_table4.txt'//CHAR(0),filename)
      open(9,file=filename,status='old')

c     reading headers
      read(9,'(a)') text
      read(9,'(a)') text
c     read in data
c     column 1: year
c     column 2: ADWP
c     column 3: BDWP
c     column 4: ZoffDWP
c     column 5: ASWP
c     column 6: BSWP
c     column 7: ZoffSWP

      myearmax=0
      myearmin=maxyear
      do 50 ny=1,maxyear

      call clearstring(text,80)
      read(9,'(a)', end=4) text
      call findlastchar(nsp,text,80)

      call commafindx(nsp,icmax,ncomma,icomma,text)
       if (ncomma .lt. 2) goto 50

       read(text(icomma(1,1):icomma(1,1)+icomma(1,2)-1),*)
     * nyear
      if (nyear .lt. myearmin ) myearmin=nyear
      if (nyear .gt. myearmax ) myearmax=nyear

       doffDA(nyear,5)=0.0
       call checkifallspace(text,icomma(2,1),icomma(2,2),notspace)
       if ( notspace .eq. 0 ) 
     *  read(text(icomma(2,1):icomma(2,1)+icomma(2,2)-1),*)
     *  doffDA(nyear,5)

       doffDB(nyear,5)=0.0
       call checkifallspace(text,icomma(3,1),icomma(3,2),notspace)
       if ( notspace .eq. 0 ) 
     *  read(text(icomma(3,1):icomma(3,1)+icomma(3,2)-1),*)
     *  doffDB(nyear,5)

       doffZD(nyear,5)=0.0
       call checkifallspace(text,icomma(4,1),icomma(4,2),notspace)
       if ( notspace .eq. 0 ) 
     *  read(text(icomma(4,1):icomma(4,1)+icomma(4,2)-1),*)
     *  doffZD(nyear,5)

       doffDA(nyear,6)=0.0
       call checkifallspace(text,icomma(5,1),icomma(5,2),notspace)
       if ( notspace .eq. 0 ) 
     *  read(text(icomma(5,1):icomma(5,1)+icomma(5,2)-1),*)
     *  doffDA(nyear,6)

       doffDB(nyear,6)=0.0
       call checkifallspace(text,icomma(6,1),icomma(6,2),notspace)
       if ( notspace .eq. 0 ) 
     *  read(text(icomma(6,1):icomma(6,1)+icomma(6,2)-1),*)
     *  doffDB(nyear,6)

       doffZD(nyear,6)=0.0
       call checkifallspace(text,icomma(7,1),icomma(7,2),notspace)
       if ( notspace .eq. 0 ) 
     *  read(text(icomma(7,1):icomma(7,1)+icomma(7,2)-1),*)
     *  doffZD(nyear,6)
c      write(6,*) nyear,doffDA(nyear,1),doffDB(nyear,1),doffZD(nyear,1)
c     * ,doffDA(nyear,2),doffDB(nyear,2),doffZD(nyear,2),doffDA(nyear,3),
c     * doffDB(nyear,3),doffZD(nyear,3),doffDA(nyear,4),doffDB(nyear,4),
c     * doffZD(nyear,4),doffDA(nyear,5),doffDB(nyear,5),doffZD(nyear,5)
c     * ,doffDA(nyear,6),doffDB(nyear,6),doffZD(nyear,6)




50     continue
4      continue
       close(9)

       return
       end

