      SUBROUTINE XBTBIASwil(itsprobe,ixprobe,depth,temp,maxlevel,
     * maxcalc,numsec,numlevels,iyearx,monthx,isippeq,ifix,iplat)

C     XBTBIASwil CORRECTS XBT BIAS BASED ON INFORMATION FROM
C     WIJFFELS et al.  TABLE 2 (WILLIS CORRECTIONS)
C     THE CORRECTIONS ARE MADE BEFORE INTERPOLATION TO STANDARD LEVELS

      parameter (maxyear=3000,ntypemax=8)
      parameter (n4=4,n7=4,ndb=4)

      character*7 firsttime
      character*80 filename
      dimension depth(maxlevel),temp(maxlevel,maxcalc)
      dimension xcorr(maxyear,ntypemax,0:12)
      dimension itype4(n4),itype7(n7),itypedb(ndb)
      dimension iyearmin(ntypemax),iyearmax(ntypemax)

      data itype4 /202,208,215,223/
      data itype7 /201,207,217,227/
      data itypedb /214,232,235,228/

      save firsttime
      save xcorr,iyearmin,iyearmax

      if ( firsttime .ne. 'xbtbias' ) then
       firsttime = 'xbtbias'
       filename='wijffels_2_t4_h95.txt'//CHAR(0)
       call readwillistables(ntypemax,maxyear,xcorr,
     *  filename,1,iyearmin,iyearmax)
       filename='wijffels_2_t4_orig.txt'//CHAR(0)
       call readwillistables(ntypemax,maxyear,xcorr,
     *  filename,2,iyearmin,iyearmax)
       filename='wijffels_2_t7_h95.txt'//CHAR(0)
       call readwillistables(ntypemax,maxyear,xcorr,
     *  filename,3,iyearmin,iyearmax)
       filename='wijffels_2_t7_orig.txt'//CHAR(0)
       call readwillistables(ntypemax,maxyear,xcorr,
     *  filename,4,iyearmin,iyearmax)
       filename='wijffels_2_tdb_h95.txt'//CHAR(0)
       call readwillistables(ntypemax,maxyear,xcorr,
     *  filename,5,iyearmin,iyearmax)
       filename='wijffels_2_tdb_orig.txt'//CHAR(0)
       call readwillistables(ntypemax,maxyear,xcorr,
     *  filename,6,iyearmin,iyearmax)
       filename='wijffels_2_unk_deep.txt'//CHAR(0)
       call readwillistables(ntypemax,maxyear,xcorr,
     *  filename,7,iyearmin,iyearmax)
       filename='wijffels_2_unk_shallow.txt'//CHAR(0)
       call readwillistables(ntypemax,maxyear,xcorr,
     *  filename,8,iyearmin,iyearmax)
      endif

      ifix=0
      if ( itsprobe .eq. 2 ) then

       ntyp=0
       do 150 nn=1,n4
150     if ( ixprobe .eq. itype4(nn) ) ntyp=2-isippeq
       do 155 nn=1,n7
155     if ( ixprobe .eq. itype7(nn) ) ntyp=4-isippeq
       do 160 nn=1,ndb
160     if ( ixprobe .eq. itypedb(nn) ) ntyp=6-isippeq
 
       if ( ntyp .eq. 0 ) then

        if ( numlevels .le. maxlevel ) then
         dpt=depth(numlevels)
        else
         call overmax(maxlevel,numsec,numlevels,0,ic,np)
         dpt=temp(ic,np)
        endif

        call xbtshallowdeep(ishallow,ixprobe,dpt,550.,iplat)
        if ( ishallow .lt. 0 ) return

        if ( ishallow .eq. 1 ) then
         ntyp=8
        else
         ntyp=7
        endif
       endif
        
       iyear=iyearx
c      write(6,*) 'ntyp',ntyp,iyearmin(ntyp)
       if ( iyearx .lt. iyearmin(ntyp) ) return
       if ( iyearx .gt. iyearmax(ntyp) ) iyear=iyearmax(ntyp)

       xbias=xcorr(iyear,ntyp,monthx)
       ifix=1

c      write(6,*) 'xb',iyear,ntyp,monthx,xcorr(iyear,ntyp,monthx)
       do 80 n=1,numlevels

        if ( n .le. maxlevel ) then
         if ( iyear .eq. 1986 .and. monthx .eq. 8 )
     *    write(98,*) depth(n),depth(n)*(1.-xbias),xbias
         depth(n)=depth(n)*(1.-xbias) 
        else
         call overmax(maxlevel,numsec,n,0,ic,np)
         temp(ic,np)=temp(ic,np)*(1-xbias)
        endif

80     continue

      endif

      return
      end
