tlmplm_store.F90 4.17 KB
Newer Older
1 2 3 4 5 6
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

7 8 9 10 11
MODULE m_tlmplm_store
! Instead of storing data to tmat&tmas files this module stores into module variables
! used to transfer the results from tlmplm&density matrix in case of lda+u from eigen
! into force_a21
!      D.W 2014
12
    USE m_types_tlmplm
13 14 15 16
    IMPLICIT NONE
    PRIVATE
    TYPE(t_tlmplm)            :: td_stored
    COMPLEX,ALLOCATABLE       :: vs_mmp_stored(:,:,:,:)
Daniel Wortmann's avatar
Daniel Wortmann committed
17
    PUBLIC write_tlmplm, read_tlmplm, read_tlmplm_vs_mmp
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
CONTAINS
    SUBROUTINE write_tlmplm(td,vs_mmp,ldau,ispin,jspin,jspins)
        TYPE(t_tlmplm),INTENT(IN) :: td
        COMPLEX,INTENT(IN)        :: vs_mmp(:,:,:,:)
        LOGICAL,INTENT(IN)        :: ldau
        INTEGER,INTENT(IN)        :: ispin,jspin,jspins

        INTEGER:: llod,lmplmd,ntypd,lmd,mlot_d,mlolot_d

        IF (.NOT.allocated(td_stored%tuu)) THEN
            lmplmd=size(td%tuu,1)-1
            ntypd=size(td%tuu,2)
            ALLOCATE(td_stored%tuu(0:lmplmd,ntypd,jspins))
            ALLOCATE(td_stored%tud(0:lmplmd,ntypd,jspins))
            ALLOCATE(td_stored%tdd(0:lmplmd,ntypd,jspins))
            ALLOCATE(td_stored%tdu(0:lmplmd,ntypd,jspins))
            lmd=size(td%tdulo,1)-1
            llod=size(td%tdulo,2)!not actual llod but -llod:llod
            mlot_d = size(td%tdulo,3)
            mlolot_d = size(td%tuloulo,3)
            ALLOCATE(td_stored%tdulo(0:lmd,llod,mlot_d,jspins))
            ALLOCATE(td_stored%tuulo(0:lmd,llod,mlot_d,jspins))
            ALLOCATE(td_stored%tuloulo(llod,llod,mlolot_d,jspins))
            ALLOCATE(td_stored%ind(0:lmd,0:lmd,ntypd,jspins))
            IF (ldau) &
                ALLOCATE(vs_mmp_stored(  &
                size(vs_mmp,1),size(vs_mmp,2),size(vs_mmp,3),jspins))
        ENDIF

        td_stored%tuu(:,:,jspin) = td%tuu(:,:,ispin)
48 49
        td_stored%tud(:,:,jspin) = td%tud(:,:,ispin)
        td_stored%tdu(:,:,jspin) = td%tdu(:,:,ispin)
50 51 52 53 54 55 56 57 58 59 60
        td_stored%tdd(:,:,jspin) = td%tdd(:,:,ispin)

        td_stored%tdulo(:,:,:,jspin)   = td%tdulo(:,:,:,ispin)
        td_stored%tuulo(:,:,:,jspin)   = td%tuulo(:,:,:,ispin)
        td_stored%tuloulo(:,:,:,jspin) = td%tuloulo(:,:,:,ispin)
        td_stored%ind(:,:,:,jspin)     = td%ind(:,:,:,ispin)
        IF (ldau) vs_mmp_stored(:,:,:,jspin)=vs_mmp(:,:,:,ispin)


    END SUBROUTINE write_tlmplm

Daniel Wortmann's avatar
Daniel Wortmann committed
61
    SUBROUTINE read_tlmplm(n,jspin,nlo,tuu,tud,tdu,tdd,ind,tuulo,tuloulo,tdulo)
62 63 64 65 66
        COMPLEX,INTENT(OUT)::tuu(:),tdd(:),tud(:),tdu(:)
        INTEGER,INTENT(OUT)::ind(:,:)
        COMPLEX,INTENT(OUT)::tuulo(:,:,:),tdulo(:,:,:),tuloulo(:,:,:)
        INTEGER,INTENT(IN) :: n,jspin,nlo(:)

Daniel Wortmann's avatar
Daniel Wortmann committed
67 68 69 70 71 72
        INTEGER:: mlo,mlolo
        tuu(1:size(tuu,1))=td_stored%tuu(0:size(tuu,1)-1,n,jspin)
        tud(1:size(tuu,1))=td_stored%tud(0:size(tuu,1)-1,n,jspin)
        tdu(1:size(tuu,1))=td_stored%tdu(0:size(tuu,1)-1,n,jspin)
        tdd(1:size(tuu,1))=td_stored%tdd(0:size(tuu,1)-1,n,jspin)
        ind(1:size(ind,1),1:size(ind,2))=td_stored%ind(0:size(ind,1)-1,0:size(ind,2)-1,n,jspin)
73 74 75

        IF (nlo(n)>0) THEN
            mlo=sum(nlo(:n-1))+1
76
            mlolo=dot_product(nlo(:n-1),nlo(:n-1)+1)/2+1
Daniel Wortmann's avatar
Daniel Wortmann committed
77 78 79 80
            tuulo(1:size(tuulo,1),:,mlo:(mlo+nlo(n)-1))=&
               td_stored%tuulo(0:size(tuulo,1)-1,:size(tuulo,2),mlo:mlo+nlo(n)-1,jspin)
            tdulo(1:size(tuulo,1),:,mlo:(mlo+nlo(n)-1))=&
               td_stored%tdulo(0:size(tuulo,1)-1,:size(tuulo,2),mlo:mlo+nlo(n)-1,jspin)
81 82
            tuloulo(:,:,mlolo:mlolo+nlo(n)*(nlo(n)+1)/2-1)=&
               td_stored%tuloulo(:size(tuloulo,1),:size(tuloulo,2),mlolo:mlolo+nlo(n)*(nlo(n)+1)/2-1,jspin)
83 84 85
        ENDIF
    
    END SUBROUTINE read_tlmplm
Daniel Wortmann's avatar
Daniel Wortmann committed
86 87 88 89 90 91 92 93 94 95 96 97

    SUBROUTINE read_tlmplm_vs_mmp(jspin,n_u,vs_mmp)

       INTEGER, INTENT(IN)  :: jspin, n_u
       COMPLEX, INTENT(OUT) :: vs_mmp(:,:,:)

       IF(n_u.GT.0) THEN
          vs_mmp(:,:,:) = vs_mmp_stored(:,:,:,jspin)
       END IF

    END SUBROUTINE read_tlmplm_vs_mmp

98
END MODULE m_tlmplm_store