      subroutine rang0s(nat,ial)
c---------------------------------------------------------------------
c     nat = nb d'orb actives
c     ial = nb d'electrons alpha (ou beta)
c---------------------------------------------------------------------
      PARAMETER (maxorbcas=16)
      IMPLICIT INTEGER(A-H,O-x,z),logical*1(y)
      common /zs/ izs(maxorbcas+4,maxorbcas+4,maxorbcas+4,maxorbcas+4)
c     common/gen/nfr,natof(4),natom,matof(4),
c    *nalf(jrangmax),ndetf(nfrmax),ial0
      common /combs/ C(0:maxorbcas+4,-1:maxorbcas+4)
      yw=.false.
      IF(ial.EQ.0) RETURN
      DO 4 L=1,nat
      IFIN=MIN0(ial-1,L)
      DO 3 K=1,IFIN
      IZZ=0
      DO 5 M=nat-L+1,nat-K
 5    IZZ=IZZ+C(M,ial-K)-C(M-1,ial-K-1)
      izs(K,L,ial,nat)=IZZ
      if(yw)write(6,'(''   k,L,ial,i,izs'',5i5)')
     *k,L,ial,nat,izs(k,L,ial,nat)
 3    CONTINUE
      izs(ial,L,ial,nat)=L-ial
      if(yw)write(6,'('' ial,L,ial,i,izs'',5i5)')
     *ial,L,ial,nat,izs(ial,L,ial,nat)
 4    CONTINUE
      RETURN
      END
