ReadInUMatCache Subroutine

private subroutine ReadInUMatCache()




Source Code

Source Code

    subroutine ReadInUMatCache()
        ! Read in cache file from CacheDump.
        integer i, j, k, l, iCache1, iCache2, A, B, readerr, iType, iunit
        HElement_t(dp) UMatEl(0:nTypes - 1), DummyUMatEl(0:nTypes - 1)
        logical tDummy, testfile
        inquire(file="CacheDump", exist=testfile)
        if (.not. testfile) then
            write(stdout, *) 'CacheDump does not exist.'
        end if
        iunit = get_free_unit()
        open(iunit, file="CacheDump", status="old", iostat=readerr)
        if (readerr /= 0) then
            write(stdout, *) 'Error reading CacheDump.'
        end if
        read(iunit, *) nStatesDump
        readerr = 0
        do while (readerr == 0)
            read(iunit, *, iostat=readerr) i, j, k, l, UMatEl
            DummyUMatEl = UMatEl
            if (TTRANSFINDX) then
                i = TransTable(i)
                j = TransTable(j)
                k = TransTable(k)
                l = TransTable(l)
            end if
            if (min(i, j, k, l) > 0 .and. max(i, j, k, l) <= nStates) then
                ! Need to get cache indices before we cache the integral:
                ! a dummy call to GetCachedUMatEl returns the needed indices and
                ! integral type information.
                tDummy = GetCachedUMatEl(i, j, k, l, DummyUmatEl(0), iCache1, iCache2, A, B, iType)
                call CacheUMatEl(B, UMatEl, iCache1, iCache2, iType)
            end if
        end do
    end subroutine ReadInUMatCache