1C $Id$
2************************************************************************
3*                                                                      *
4      subroutine ecp_ind_var (l_c,n_blk,n_co1,n_co2,i_co1,i_co2,
5     &    i_ze1,i_ze2,n_x,n_co_tot,n_co_max,i_off,n_pass,i_cont_c,
6     &    n_cont_c,skip)
7*                                                                      *
8*   Define various index and length parameters for the selected set of *
9*   integrals for a given ECP projector. These depend on the existence *
10*   of the ECP parameters and the relationships between spin-free and  *
11*   spin-orbit potentials.                                             *
12*                                                                      *
13*   Argument (status) - description                                    *
14*                                                                      *
15*   l_c (inp) - angular momentum of ECP projector                      *
16*   n_blk (inp) - number of blocks, 1 for SF, 3 for SO, 4 for both     *
17*   n_co1 (inp) - number of SF ECP coefficients                        *
18*   n_co2 (inp) - number of SO ECP coefficients                        *
19*   i_co1 (inp) - index of first SF ECP coefficient                    *
20*   i_co2 (inp) - index of first SO ECP coefficient                    *
21*   i_ze1 (inp) - index of first SF ECP exponent                       *
22*   i_ze2 (inp) - index of first SO ECP exponent                       *
23*   n_x (out) - actual number of blocks which can be calculated        *
24*   n_co_tot (out) - total number of coefficients for one pass of the  *
25*                    radial integrals                                  *
26*   n_co_max (out) - maximum length of ECP contraction                 *
27*   i_off (out) - offset of actual data in the final index of the ECP  *
28*                 integral array                                       *
29*   n_pass (out) - number of passes of the radial integrals            *
30*   i_cont_c (out) - address of first ECP contraction                  *
31*   n_cont_c (out) - number of ECP contractions                        *
32*   skip (out) - logical to skip if no integrals would be generated    *
33*                                                                      *
34*   Written by K. G. Dyall                                             *
35*                                                                      *
36************************************************************************
37      implicit none
38      integer l_c,n_blk,n_co1,n_co2,i_co1,i_co2,i_ze1,i_ze2,
39     &    n_x,n_co_tot,n_co_max,i_off,n_pass,i_cont_c,n_cont_c
40      logical skip
41*
42*   Define parameters for the different integral class cases
43*
44      n_co_tot = n_co1
45      n_co_max = n_co1
46      i_cont_c = 1
47      n_cont_c = 1
48      i_off = 0
49      n_pass = 1
50      if (n_blk .eq. 4) then
51*
52*     Both spin-free and spin-orbit integrals requested.
53*
54        if ((i_co1 .eq. 0) .or. (n_co1 .eq. 0)) then
55*
56*       There is no spin-free ECP: if there is also no spin-orbit ECP
57*       then exit loop, otherwise set parameters for spin-orbit only.
58*
59          skip = (i_co2 .eq. 0) .or. (n_co2 .eq. 0)
60          n_x = 3
61          i_cont_c = 2
62          i_off = 1
63        else if ((i_co2 .eq. 0) .or. (n_co2 .eq. 0)) then
64*
65*       There is a spin-free ECP but there is no spin-orbit ECP:
66*       set parameters for spin-free only.
67*
68          n_x = 1
69        else
70*
71*       There are both spin-free and spin-orbit ECPs
72*
73          n_x = 4
74          if ((i_ze2 .eq. i_ze1) .and. (n_co2 .eq. n_co1)) then
75*
76*         SF and SO ECPs have the same exponents: do together
77*
78            n_cont_c = 2
79            n_co_tot = n_co1*2
80          else
81*
82*         SF and SO ECPs have different exponents: do two passes
83*
84            n_co_tot = max(n_co1,n_co2)
85            n_co_max = n_co_tot
86            n_pass = 2
87          end if
88        end if
89      else
90*
91*     Either spin-free or spin-orbit integrals requested.
92*
93        if (n_blk .eq. 3) then
94          skip = (l_c .eq. 0) .or.
95     &        (i_co2 .eq. 0) .or. (n_co2 .eq. 0)
96          i_cont_c = 2
97          n_co_tot = n_co2
98          n_co_max = n_co2
99        else
100          skip = (i_co1 .eq. 0) .or. (n_co1 .eq. 0)
101        end if
102        n_x = n_blk
103      end if
104*
105      return
106      end
107