*...:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
      subroutine g(ka,kawtau,kawz,ke,kewtau,kewz,V,Vwtau,Vwz)     
      implicit real*8 (a-h,o-z)
      implicit integer*4 (i-n)
      save

      include "../code/global.f"
      include "local.f"

      real*8 ka,kawtau,kawz
      real*8 ke,kewtau,kewz
      real*8 V,Vwtau,Vwz
      real*8 Cl,Clwtau,Clwz
      real*8 tmp
      real*8 cr,wt,gl

      integer*4 i

      dimension kawtau(mtau),kawz(mM)
      dimension kewtau(mtau),kewz(mM)
      dimension Vwtau(mtau),Vwz(mM)
      dimension Clwtau(mtau),Clwz(mM)

      if (M.ne.2) then
        write(3,3901)
        stop
      end if

      wt  = weight(index)
      gl  = glyco(index)
      tmp = creatn(index)
      if ((tmp.eq.0).or.(tmp.eq.1).or.(tmp.eq.2).or.
     &  (tmp.eq.4).or.(tmp.eq.7)) then
        cr = 1.d0
      else
        cr  = 0.0d0
      end if

      ka = dexp(tau(1))
      Cl = dexp(tau(2) + tau(4)*wt + tau(5)*gl + tau(6)*cr + z(1))
      V  = dexp(tau(3)+z(2))

      do i=1,ltau
        kawtau(i)=0.d0
        Clwtau(i)=0.d0 
        Vwtau(i)=0.d0
      end do

      do i=1,M
        kawz(i)=0.d0
        Clwz(i)=0.d0
        Vwz(i)=0.d0
      end do

      kawtau(1) = ka
      Clwtau(2) = Cl
      Vwtau(3)  = V
      Clwtau(4) = Cl*wt
      Clwtau(5) = Cl*gl
      Clwtau(6) = Cl*cr

      Clwz(1) = Cl
      Vwz(2)  = V

      ke = Cl/V
      do i=1,ltau
        kewtau(i) = Clwtau(i)/V - (ke/V)*Vwtau(i)
      end do
      do i=1,M
        kewz(i) = Clwz(i)/V - (ke/V)*Vwz(i)
      end do

      return
3901  format(1x,'error, g, this version is for M=2')
      end
