1      Subroutine matchNxyz(lambda,ic,Nxyz)
2c $Id$
3      implicit none
4
5      integer lambda, ic, Nxyz(3)
6
7#include "sh_order.fh"
8#include "errquit.fh"
9
10      integer l, l3, nc
11
12c
13c Given the angular momentum exponents for the "ic" component of a shell of
14c Cartesian GTFs of angular momentum "lambda" return ic. Hard error if no
15c match is found.
16c
17c
18
19      if( lambda.le.linit )then
20
21       l = lambda - 1
22cedo       l3 = ((l+1)*(l+2)*(l+3))/6
23       l3 = ((l+2)*(l+3))/2
24       nc =l3*(l+1)/3
25       do ic = 1, l3
26          nc = nc +1
27          if (
28     $         Nxyz(1) .eq. Ixyz(1,nc) .and.
29     $         Nxyz(2) .eq. Ixyz(2,nc) .and.
30     $         Nxyz(3) .eq. Ixyz(3,nc))
31     $         return
32       enddo
33       call errquit('matchNxyz: invalid shell indices',
34     $      1000*lambda+100*nxyz(1)+10*nxyz(2)+nxyz(3), BASIS_ERR)
35      else
36       write(*,*)
37       write(*,*) 'MATCHNXYZ:  Shell component ordering was defined for'
38       write(*,*) '            shells up through L = ',linit,'.'
39       write(*,*) '            Initialization (defNxyz) should include '
40       write(*,*) '            shells up through L = ',lambda,'.'
41       stop
42
43      end if
44
45      end
46