io_hybrid.F90 6.57 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.
!--------------------------------------------------------------------------------

Daniel Wortmann's avatar
Daniel Wortmann committed
7 8 9 10 11 12
module m_io_hybrid
  use m_io_matrix
  use m_judft
  use m_types
  implicit none
  !private
Daniel Wortmann's avatar
Daniel Wortmann committed
13
  integer,save :: id_olap,id_z,id_v_x,id_coulomb,id_coulomb_spm
Daniel Wortmann's avatar
Daniel Wortmann committed
14 15 16
  !public:: open_hybrid_io,read_cmt,write_cmt
contains

17
  SUBROUTINE open_hybrid_io1(DIMENSION,l_real)
Daniel Wortmann's avatar
Daniel Wortmann committed
18 19 20
    implicit none
    TYPE(t_dimension),INTENT(IN):: dimension
    LOGICAL,INTENT(IN)          :: l_real
21
    LOGICAL :: opened=.false.
Daniel Wortmann's avatar
Daniel Wortmann committed
22 23

    
24 25 26 27

    if (opened) return
    opened=.true.

Daniel Wortmann's avatar
Daniel Wortmann committed
28 29 30 31 32 33
    print *,"Open olap.mat"
    id_olap=OPEN_MATRIX(l_real,dimension%nbasfcn,1,"olap.mat")
    print *,"Open z.mat"
    id_z=OPEN_MATRIX(l_real,dimension%nbasfcn,1,"z.mat")
    print *,"Open v_x.mat"
    id_v_x=OPEN_MATRIX(l_real,dimension%nbasfcn,1,"v_x.mat")
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
  END SUBROUTINE open_hybrid_io1
  SUBROUTINE open_hybrid_io2(hybrid,DIMENSION,atoms,l_real)
    IMPLICIT NONE
    TYPE(t_hybrid),INTENT(IN)   :: hybrid
    TYPE(t_dimension),INTENT(IN):: dimension
    TYPE(t_atoms),INTENT(IN)    :: atoms
    LOGICAL,INTENT(IN)          :: l_real
    INTEGER:: irecl_coulomb
    LOGICAL :: opened=.FALSE.

    

    if (opened) return
    opened=.true.
    OPEN(unit=777,file='cmt',form='unformatted',access='direct',&
         &     recl=dimension%neigd*hybrid%maxlmindx*atoms%nat*16)
  
Daniel Wortmann's avatar
Daniel Wortmann committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#ifdef CPP_NOSPMVEC
    irecl_coulomb = hybrid%maxbasm1 * (hybrid%maxbasm1+1) * 8 / 2
    if (.not.l_real) irecl_coulomb =irecl_coulomb *2
    OPEN(unit=778,file='coulomb',form='unformatted',access='direct', recl=irecl_coulomb)
    id_coulomb=778
#else
    ! if the sparse matrix technique is used, several entries of the
    ! matrix vanish so that the size of each entry is smaller
    irecl_coulomb = ( atoms%ntype*(hybrid%maxlcutm1+1)*(hybrid%maxindxm1-1)**2&
         +   atoms%nat *(hybrid%maxlcutm1+2)*(2*hybrid%maxlcutm1+1)*(hybrid%maxindxm1-1)&
         +   (hybrid%maxindxm1-1)*atoms%nat**2&
         +   ((hybrid%maxlcutm1+1)**2*atoms%nat+hybrid%maxgptm)&
         *((hybrid%maxlcutm1+1)**2*atoms%nat+hybrid%maxgptm+1)/2 )*8
    if (.not.l_real) irecl_coulomb =irecl_coulomb *2
    OPEN(unit=778,file='coulomb1',form='unformatted',access='direct', recl=irecl_coulomb)
    id_coulomb_spm=778
#endif
68
  END SUBROUTINE open_hybrid_io2
Daniel Wortmann's avatar
Daniel Wortmann committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
  
  subroutine write_cmt(cmt,nk)
    implicit none
    complex,INTENT(IN):: cmt(:,:,:)
    integer,INTENT(IN):: nk

    write(777,rec=nk) cmt
  end subroutine write_cmt

  subroutine read_cmt(cmt,nk)
    implicit none
    complex,INTENT(OUT):: cmt(:,:,:)
    integer,INTENT(IN):: nk

    read(777,rec=nk) cmt
  end subroutine read_cmt

Daniel Wortmann's avatar
Daniel Wortmann committed
86 87 88
  subroutine write_coulomb(nk,l_real,coulomb)
    implicit none
    complex,intent(in) :: coulomb(:)
89 90
    integer,intent(in) :: nk
    logical,intent(in) :: l_real
Daniel Wortmann's avatar
Daniel Wortmann committed
91 92 93 94 95 96 97 98 99 100

    if (l_real) THEN
       write(id_coulomb,rec=nk) real(coulomb)
    else
       write(id_coulomb,rec=nk) coulomb
    end if
  end subroutine write_coulomb

   subroutine write_coulomb_spm_r(nk,coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir)
    implicit none
Daniel Wortmann's avatar
Daniel Wortmann committed
101 102 103
    real,intent(in)    :: coulomb_mt1(:,:,:,:)
    real,intent(in) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    real,intent(in) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
104 105
    integer,intent(in) :: nk
    
Daniel Wortmann's avatar
Daniel Wortmann committed
106
    print *, "write coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
Daniel Wortmann's avatar
Daniel Wortmann committed
107 108 109 110 111
    write(id_coulomb_spm,rec=nk) coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir
  end subroutine write_coulomb_spm_r

   subroutine write_coulomb_spm_c(nk,coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir)
    implicit none
Daniel Wortmann's avatar
Daniel Wortmann committed
112 113 114
    real,intent(in)    :: coulomb_mt1(:,:,:,:)
    complex,intent(in) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    complex,intent(in) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
115 116 117 118 119 120 121
    integer,intent(in) :: nk
    
    write(id_coulomb_spm,rec=nk) coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir
  end subroutine write_coulomb_spm_c

     subroutine read_coulomb_spm_r(nk,coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir)
    implicit none
Daniel Wortmann's avatar
Daniel Wortmann committed
122 123 124
    real,intent(out)    :: coulomb_mt1(:,:,:,:)
    real,intent(out) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    real,intent(out) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
125 126
    integer,intent(in) :: nk
    
Daniel Wortmann's avatar
Daniel Wortmann committed
127
    print *, "read coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
Daniel Wortmann's avatar
Daniel Wortmann committed
128 129 130 131 132
    read(id_coulomb_spm,rec=nk) coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir
  end subroutine read_coulomb_spm_r

   subroutine read_coulomb_spm_c(nk,coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir)
    implicit none
Daniel Wortmann's avatar
Daniel Wortmann committed
133 134 135
    real,intent(out)    :: coulomb_mt1(:,:,:,:)
    complex,intent(out) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    complex,intent(out) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
136 137 138 139 140 141 142
    integer,intent(in) :: nk
    read(id_coulomb_spm,rec=nk) coulomb_mt1,coulomb_mt2,coulomb_mt3,coulomb_mtir
  end subroutine read_coulomb_spm_c

  subroutine read_coulomb_r(nk,coulomb)
    implicit none
    real   ,intent(out) :: coulomb(:)
143
    integer,intent(in) :: nk
Daniel Wortmann's avatar
Daniel Wortmann committed
144 145 146 147 148 149 150

    read(id_coulomb,rec=nk) coulomb
  end subroutine read_coulomb_r
  
  subroutine read_coulomb_c(nk,coulomb)
    implicit none
    complex,intent(out) :: coulomb(:)
151
    integer,intent(in) :: nk
Daniel Wortmann's avatar
Daniel Wortmann committed
152 153 154
    
    read(id_coulomb,rec=nk) coulomb
  end subroutine read_coulomb_c
Daniel Wortmann's avatar
Daniel Wortmann committed
155

Daniel Wortmann's avatar
Daniel Wortmann committed
156 157

  
Daniel Wortmann's avatar
Daniel Wortmann committed
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
  subroutine read_olap(mat,rec)
    implicit none
    TYPE(t_mat),INTENT(INOUT):: mat
    INTEGER,INTENT(IN)           :: rec
    
    CALL read_matrix(mat,rec,id_olap)
  END subroutine read_olap

    subroutine write_olap(mat,rec)
    implicit none
    TYPE(t_mat),INTENT(IN)   :: mat
    INTEGER,INTENT(IN)           :: rec
    
    CALL write_matrix(mat,rec,id_olap)
  END subroutine write_olap

  subroutine read_z(mat,rec)
    implicit none
    TYPE(t_mat),INTENT(INOUT):: mat
    INTEGER,INTENT(IN)           :: rec
Daniel Wortmann's avatar
Daniel Wortmann committed
178
    print *,"read z:",rec
Daniel Wortmann's avatar
Daniel Wortmann committed
179 180 181 182 183 184 185 186
    
    CALL read_matrix(mat,rec,id_z)
  END subroutine read_z

    subroutine write_z(mat,rec)
    implicit none
    TYPE(t_mat),INTENT(IN)   :: mat
    INTEGER,INTENT(IN)           :: rec
Daniel Wortmann's avatar
Daniel Wortmann committed
187 188
     print *,"write z:",rec
   CALL write_matrix(mat,rec,id_z)
Daniel Wortmann's avatar
Daniel Wortmann committed
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
  END subroutine write_z

  subroutine read_v_x(mat,rec)
    implicit none
    TYPE(t_mat),INTENT(INOUT):: mat
    INTEGER,INTENT(IN)           :: rec
    
    CALL read_matrix(mat,rec,id_v_x)
  END subroutine read_v_x

  subroutine write_v_x(mat,rec)
    implicit none
    TYPE(t_mat),INTENT(IN)   :: mat
    INTEGER,INTENT(IN)           :: rec
    
    CALL write_matrix(mat,rec,id_v_x)
  END subroutine write_v_x

  
 

end module m_io_hybrid