1c     Check density
2c
3      logical function chk_dens(rtdb, g_dens)
4c
5      implicit none
6c
7#include "errquit.fh"
8#include "rtdb.fh"
9#include "mafdecls.fh"
10#include "stdio.fh"
11c
12      integer rtdb
13      integer g_dens(2)
14c
15      double precision denmax,denmax1,denmax2
16      double precision tol_rho
17c
18c     get user defined tol_rho
19      tol_rho=1.D-10
20      if (.not. rtdb_get(rtdb, 'dft:tol_rho', mt_dbl, 1, tol_rho))
21     &   tol_rho=1.D-10
22
23      denmax1 = 0.0d0
24      denmax2 = 0.0d0
25      denmax=0.0d0
26      call ga_maxelt(g_dens(1), denmax1)
27      call ga_maxelt(g_dens(2), denmax2)
28      denmax=max(denmax1,denmax2)
29c
30      chk_dens = .true.
31      if (denmax.lt.tol_rho) chk_dens = .false.
32c
33      return
34      end
35c $Id$
36