      subroutine rdubvi
*
*  reads colour table 'UBVRI.xxx' and stores values in common 'ubvdata'
*  choice of Kurucz models (xxx=Kur) or LBC-corrected models (xxx=LBC)
*  (Lejeune, Cuisinier, Buser (1997) A&AS 125, 229)
*
      implicit real*8 (a-h,l,m,o-z)
      parameter (nzgr=9, ntgr = 61, nggr = 11)
      real*8 zgr(nzgr), tgr(ntgr), ggr(nggr), ubv(nzgr,ntgr,nggr,5)
      common /ubvdata/ zgr, tgr, ggr, ubv
*
      character*2 direc
      data direc /'./'/
*
      open(21, file=direc//'UBVRI.LBC',status='old')
      read(21,*)
      read(21,*) nz, nt, ng
      do k = 1, nzgr
         do i = 1, ntgr
            do j = 1, nggr
               read (21,*) zgr(k), tgr(i), ggr(j), (ubv(k,i,j,n), n=1,5)
            end do
            tgr(i) = log10(tgr(i))
         end do
*........convert [Fe/H] to log(Z/0.02)
         zgr(k) = -log10((3.0 + 37.425*10.0**(-zgr(k)))/38.0)
      end do
      close (21)
      end
*
      subroutine tgzubv (logt,logg,logz,bolc,uminb,bminv,vminr,vmini)
*
*  computes values of BC, U-B, B-V, V-R and V-I for given log T, log g
*  and log(Z/0.02)
*
      implicit real*8 (a-h,l,m,o-z)
      parameter (nzgr=9, ntgr = 61, nggr = 11)
      real*8 zgr(nzgr), tgr(ntgr), ggr(nggr), ubv(nzgr,ntgr,nggr,5)
      common /ubvdata/ zgr, tgr, ggr, ubv
      dimension cm(5)
*.....find indices of log Z, log g and log T to interpolate between.
*.....extrapolation in log Z and log T is allowed, but not extrapolation
*.....outside log g grid - use boundary values
      ig = indx(logg,ggr,nggr)
      it = indx(logt,tgr,ntgr)
      iz = indx(logz,zgr,nzgr)
      dg1 = (logg - ggr(ig-1))/(ggr(ig) - ggr(ig-1))
      dg1 = max(0.0, min(1.0, dg1))
      dg2 = 1.0 - dg1
      dt1 = (logt - tgr(it-1))/(tgr(it) - tgr(it-1))
      dt2 = 1.0 - dt1
      dz1 = (logz - zgr(iz-1))/(zgr(iz) - zgr(iz-1))
      dz2 = 1.0 - dz1
      do k = 1, 5
         cm(k) = ((ubv(iz,it,ig,k)*dg1 + ubv(iz,it,ig-1,k)*dg2)*dt1 +
     &        (ubv(iz,it-1,ig,k)*dg1 + ubv(iz,it-1,ig-1,k)*dg2)*dt2)*dz1
     &        + ((ubv(iz-1,it,ig,k)*dg1 + ubv(iz-1,it,ig-1,k)*dg2)*dt1 +
     &        (ubv(iz-1,it-1,ig,k)*dg1 + ubv(iz-1,it-1,ig-1,k)*dg2)*dt2)
     &        *dz2
      end do
      bolc = cm(1)
      uminb = cm(2)
      bminv = cm(3)
      vminr = cm(4)
      vmini = cm(4) + cm(5)
      end
