InitSymmArrays Subroutine

public subroutine InitSymmArrays()

Uses

Arguments

None

Contents

Source Code


Source Code

    subroutine InitSymmArrays()

! This routine creates indexing arrays for the cases with symmetry on/off, and either mixing all orbitals or
! separating the occupied and virtuals.
! The arrays used specific to the orbital rotation are named with a 2.

! The arrays produced are as follows...
! SymLabelList2_rot(NoOrbs) contains the spatial orbitals, ordered in groups of increasing symmetry label.
! - when the orbitals are being separated, the first NoOcc of SymLabelList2_rot are the occupied, and the rest are virtual.
! - essentially this array relates the orbital labelling used in the orbital rotation (1, 2, 3 according to the order
! - in SymLabelList2_rot) to the labels used in arrays being fed in/out of this routine (UMAT etc).

! SymLabelCounts2_rot(1:Sym) is the index in SymLabelList where the symmetry block S starts
! SymLabelCounts2_rot(2:Sym) is the number of orbitals in symmetry block S.
! E.g. if symmetry S starts at index 2 and has 3 orbitals.
! SymLabelList2_rot(2)->SymLabelList2_rot(4) will give the indexes of these orbitals.

        use sym_mod, only: GenSymStatePairs
        integer :: j, i, ierr
        character(len=*), parameter :: this_routine = 'InitSymmArrays'

        if (.not. tSeparateOccVirt) then
            SymLabelCounts(:, :) = 0
            SymLabelList(:) = 0
            if (tStoreSpinOrbs) call Stop_All(this_routine, &
                                              "There may be a problem with GENSymStatePairs when using spin orbitals.")
            call GENSymStatePairs(SpatOrbs, .false.)
        end if
! Sets up the SymLabelList and SymLabelCounts arrays used in the spawing etc. (When the rotate
! orbs routine is called, this has not been done yet).
! If the symmetry is on, and all orbitals are being mixed, this will end up being the same as SymLabelList2_rot.

        if (tSeparateOccVirt) then
            MinOccVirt = 1
            MaxOccVirt = 2
            if (tRotateOccOnly) then
                MaxOccVirt = 1
            else if (tRotateVirtOnly) then
                MinOccVirt = 2
            end if
            call InitOrbitalSeparation()
            ! rewrite all the symmetry lists to account for the separation and have simple option if
            ! symmetry is off.
        else
            MinOccVirt = 1
            MaxOccVirt = 1
            allocate(SymLabelCounts2_rot(2, 8), stat=ierr)
            call LogMemAlloc('SymLabelCounts2_rot', 2 * 8, 4, this_routine, SymLabelCounts2_rotTag, ierr)
            SymLabelCounts2_rot(:, :) = 0
            do i = 1, SpatOrbs
                if (tStoreSpinOrbs) then
                    SymLabelList2_rot(2 * i) = 2 * SymLabelList(i)
                    SymLabelList2_rot(2 * i - 1) = (2 * SymLabelList(i)) - 1
                else
                    SymLabelList2_rot(i) = SymLabelList(i)
                end if
            end do
            if (lNoSymmetry) then
                SymLabelCounts2_rot(1, 1) = 1
                SymLabelCounts2_rot(2, 1) = NoOrbs
            else
                do j = 1, 8
                    if (tStoreSpinOrbs) then
                        SymLabelCounts2_rot(1, j) = (2 * SymLabelCounts(1, j)) - 1
                        SymLabelCounts2_rot(2, j) = 2 * SymLabelCounts(2, j)
                    else
                        do i = 1, 2
                            SymLabelCounts2_rot(i, j) = SymLabelCounts(i, j)
                        end do
                    end if
                end do
            end if
        end if

        do i = 1, NoOrbs
            SymLabelListInv_rot(SymLabelList2_rot(i)) = i
        end do

    end subroutine InitSymmArrays