      subroutine GA_DGEMM(transa, transb, m, n, k, alpha, g_a, 
     $     g_b, beta, g_c)
      implicit none
      Character*1        transa, transb
      Integer            m, n, k
      Double precision   alpha, beta
      Integer            g_a, g_b, g_c
#include "mafdecls.fh"
#include "global.fh"
#include "tcgmsg.fh"
c     
#ifdef DRATA_SERVER
      ichunk = 256
      jchunk = 256
      kchunk = 256
#else
      ichunk = 128
      jchunk = 128
      kchunk = 128
#endif
C
      me = ga_nodeid()
      nproc = ga_nnodes()

      do jlo = 1, n, jchunk
         jhi = min(n, jlo+jchunk-1)
         jdim = jhi - jlo + 1
         do klo = 1, k, kchunk
            khi = min(k, klo+kchunk-1)
            kdim = khi - klo + 1
C
C           Each pass through the outer two loops means we need a
C           different patch of B.
C
            Get_New_B = .TRUE.
C
            do ilo = 1, m, ichunk
               if (mod(ijk,nproc) .eq. me) then
                  ihi = min(m, ilo+ichunk-1)
                  idim = ihi - ilo + 1
                  cdim = idim
                     adim = idim
                     call ga_get(g_a, ilo, ihi, klo, khi,
     $                  dbl_mb(k_a), adim)
                        bdim = kdim
                        call ga_get(g_b, klo, khi, jlo, jhi, 
     $                     dbl_mb(k_b), bdim)
C
                  call xx_dgemm(transa, transb, idim, jdim, kdim,
     $                 alpha, dbl_mb(k_a), adim, dbl_mb(k_b), bdim,
     $                 1.0d0, dbl_mb(k_c), cdim)
                  call ga_acc(g_c, ilo, ihi, jlo, jhi, dbl_mb(k_c), 
     $                 cdim, 1.0d0)
               endif
               ijk = ijk + 1
            enddo
         enddo
      enddo
      status = .true.
      status = status .and. ma_pop_stack(l_c)
      status = status .and. ma_pop_stack(l_b)
      status = status .and. ma_pop_stack(l_a)
      if (.not. status)
     $   CALL ga_error('ga_dgemm: pop of stack failed', 0)
      call ga_sync()
c
      end
