# rc6j.f

          SUBROUTINE RC6J (L2, L3, L4, L5, L6, L1MIN, L1MAX, SIXCOF, NDIM,
         +   IER)
    C***BEGIN PROLOGUE  RC6J
    C***PURPOSE  Evaluate the 6j symbol h(L1) = {L1 L2 L3}
    C                                           {L4 L5 L6}
    C            for all allowed values of L1, the other parameters
    C            being held fixed.
    C***LIBRARY   SLATEC
    C***CATEGORY  C19
    C***TYPE      SINGLE PRECISION (RC6J-S, DRC6J-D)
    C***KEYWORDS  6J COEFFICIENTS, 6J SYMBOLS, CLEBSCH-GORDAN COEFFICIENTS,
    C             RACAH COEFFICIENTS, VECTOR ADDITION COEFFICIENTS,
    C             WIGNER COEFFICIENTS
    C***AUTHOR  Gordon, R. G., Harvard University
    C           Schulten, K., Max Planck Institute
    C***DESCRIPTION
    C
    C *Usage:
    C
    C        REAL L2, L3, L4, L5, L6, L1MIN, L1MAX, SIXCOF(NDIM)
    C        INTEGER NDIM, IER
    C
    C        CALL RC6J(L2, L3, L4, L5, L6, L1MIN, L1MAX, SIXCOF, NDIM, IER)
    C
    C *Arguments:
    C
    C     L2 :IN      Parameter in 6j symbol.
    C
    C     L3 :IN      Parameter in 6j symbol.
    C
    C     L4 :IN      Parameter in 6j symbol.
    C
    C     L5 :IN      Parameter in 6j symbol.
    C
    C     L6 :IN      Parameter in 6j symbol.
    C
    C     L1MIN :OUT  Smallest allowable L1 in 6j symbol.
    C
    C     L1MAX :OUT  Largest allowable L1 in 6j symbol.
    C
    C     SIXCOF :OUT Set of 6j coefficients generated by evaluating the
    C                 6j symbol for all allowed values of L1.  SIXCOF(I)
    C                 will contain h(L1MIN+I-1), I=1,2,...,L1MAX-L1MIN+1.
    C
    C     NDIM :IN    Declared length of SIXCOF in calling program.
    C
    C     IER :OUT    Error flag.
    C                 IER=0 No errors.
    C                 IER=1 L2+L3+L5+L6 or L4+L2+L6 not an integer.
    C                 IER=2 L4, L2, L6 triangular condition not satisfied.
    C                 IER=3 L4, L5, L3 triangular condition not satisfied.
    C                 IER=4 L1MAX-L1MIN not an integer.
    C                 IER=5 L1MAX less than L1MIN.
    C                 IER=6 NDIM less than L1MAX-L1MIN+1.
    C
    C *Description:
    C
    C     The definition and properties of 6j symbols can be found, for
    C  example, in Appendix C of Volume II of A. Messiah. Although the
    C  parameters of the vector addition coefficients satisfy certain
    C  conventional restrictions, the restriction that they be non-negative
    C  integers or non-negative integers plus 1/2 is not imposed on input
    C  to this subroutine. The restrictions imposed are
    C       1. L2+L3+L5+L6 and L2+L4+L6 must be integers;
    C       2. ABS(L2-L4).LE.L6.LE.L2+L4 must be satisfied;
    C       3. ABS(L4-L5).LE.L3.LE.L4+L5 must be satisfied;
    C       4. L1MAX-L1MIN must be a non-negative integer, where
    C          L1MAX=MIN(L2+L3,L5+L6) and L1MIN=MAX(ABS(L2-L3),ABS(L5-L6)).
    C  If all the conventional restrictions are satisfied, then these
    C  restrictions are met. Conversely, if input to this subroutine meets
    C  all of these restrictions and the conventional restriction stated
    C  above, then all the conventional restrictions are satisfied.
    C
    C     The user should be cautious in using input parameters that do
    C  not satisfy the conventional restrictions. For example, the
    C  the subroutine produces values of
    C       h(L1) = { L1 2/3  1 }
    C               {2/3 2/3 2/3}
    C  for L1=1/3 and 4/3 but none of the symmetry properties of the 6j
    C  symbol, set forth on pages 1063 and 1064 of Messiah, is satisfied.
    C
    C     The subroutine generates h(L1MIN), h(L1MIN+1), ..., h(L1MAX)
    C  where L1MIN and L1MAX are defined above. The sequence h(L1) is
    C  generated by a three-term recurrence algorithm with scaling to
    C  control overflow. Both backward and forward recurrence are used to
    C  maintain numerical stability. The two recurrence sequences are
    C  matched at an interior point and are normalized from the unitary
    C  property of 6j coefficients and Wigner's phase convention.
    C
    C    The algorithm is suited to applications in which large quantum
    C  numbers arise, such as in molecular dynamics.
    C
    C***REFERENCES  1. Messiah, Albert., Quantum Mechanics, Volume II,
    C                  North-Holland Publishing Company, 1963.
    C               2. Schulten, Klaus and Gordon, Roy G., Exact recursive
    C                  evaluation of 3j and 6j coefficients for quantum-
    C                  mechanical coupling of angular momenta, J Math
    C                  Phys, v 16, no. 10, October 1975, pp. 1961-1970.
    C               3. Schulten, Klaus and Gordon, Roy G., Semiclassical
    C                  approximations to 3j and 6j coefficients for
    C                  quantum-mechanical coupling of angular momenta,
    C                  J Math Phys, v 16, no. 10, October 1975,
    C                  pp. 1971-1988.
    C               4. Schulten, Klaus and Gordon, Roy G., Recursive
    C                  evaluation of 3j and 6j coefficients, Computer
    C                  Phys Comm, v 11, 1976, pp. 269-278.
    C***ROUTINES CALLED  R1MACH, XERMSG
    C***REVISION HISTORY  (YYMMDD)
    C   750101  DATE WRITTEN
    C   880515  SLATEC prologue added by G. C. Nielson, NBS; parameters
    C           HUGE and TINY revised to depend on R1MACH.
    C   891229  Prologue description rewritten; other prologue sections
    C           revised; LMATCH (location of match point for recurrences)
    C           removed from argument list; argument IER changed to serve
    C           only as an error flag (previously, in cases without error,
    C           it returned the number of scalings); number of error codes
    C           increased to provide more precise error information;
    C           program comments revised; SLATEC error handler calls
    C           introduced to enable printing of error messages to meet
    C           SLATEC standards. These changes were done by D. W. Lozier,
    C           M. A. McClain and J. M. Smith of the National Institute
    C           of Standards and Technology, formerly NBS.
    C   910415  Mixed type expressions eliminated; variable C1 initialized;
    C           description of SIXCOF expanded. These changes were done by
    C           D. W. Lozier.
    C***END PROLOGUE  RC6J