io_hybrid.F90 6.82 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
    if (opened) return
    opened=.true.

Daniel Wortmann's avatar
Daniel Wortmann committed
26 27 28 29
    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")
30 31 32 33 34 35 36 37 38 39 40 41
  END SUBROUTINE open_hybrid_io1


  SUBROUTINE open_hybrid_io1b(DIMENSION,l_real)
    implicit none
    TYPE(t_dimension),INTENT(IN):: dimension
    LOGICAL,INTENT(IN)          :: l_real
    LOGICAL :: opened=.false.

    if (opened) return
    opened=.true.

Daniel Wortmann's avatar
Daniel Wortmann committed
42 43
    print *,"Open v_x.mat"
    id_v_x=OPEN_MATRIX(l_real,dimension%nbasfcn,1,"v_x.mat")
44 45 46
  END SUBROUTINE open_hybrid_io1b


47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
  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
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
#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
80
  END SUBROUTINE open_hybrid_io2
Daniel Wortmann's avatar
Daniel Wortmann committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
  
  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
98 99 100
  subroutine write_coulomb(nk,l_real,coulomb)
    implicit none
    complex,intent(in) :: coulomb(:)
101 102
    integer,intent(in) :: nk
    logical,intent(in) :: l_real
Daniel Wortmann's avatar
Daniel Wortmann committed
103 104 105 106 107 108 109 110 111 112

    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
113 114 115
    real,intent(in)    :: coulomb_mt1(:,:,:,:)
    real,intent(in) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    real,intent(in) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
116 117
    integer,intent(in) :: nk
    
Daniel Wortmann's avatar
Daniel Wortmann committed
118
    print *, "write coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
Daniel Wortmann's avatar
Daniel Wortmann committed
119 120 121 122 123
    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
124 125 126
    real,intent(in)    :: coulomb_mt1(:,:,:,:)
    complex,intent(in) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    complex,intent(in) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
127 128 129 130 131 132 133
    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
134 135 136
    real,intent(out)    :: coulomb_mt1(:,:,:,:)
    real,intent(out) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    real,intent(out) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
137 138
    integer,intent(in) :: nk
    
Daniel Wortmann's avatar
Daniel Wortmann committed
139
    print *, "read coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
Daniel Wortmann's avatar
Daniel Wortmann committed
140 141 142 143 144
    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
145 146 147
    real,intent(out)    :: coulomb_mt1(:,:,:,:)
    complex,intent(out) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    complex,intent(out) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
148 149 150 151 152 153 154
    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(:)
155
    integer,intent(in) :: nk
Daniel Wortmann's avatar
Daniel Wortmann committed
156 157 158 159 160 161 162

    read(id_coulomb,rec=nk) coulomb
  end subroutine read_coulomb_r
  
  subroutine read_coulomb_c(nk,coulomb)
    implicit none
    complex,intent(out) :: coulomb(:)
163
    integer,intent(in) :: nk
Daniel Wortmann's avatar
Daniel Wortmann committed
164 165 166
    
    read(id_coulomb,rec=nk) coulomb
  end subroutine read_coulomb_c
Daniel Wortmann's avatar
Daniel Wortmann committed
167

Daniel Wortmann's avatar
Daniel Wortmann committed
168 169

  
Daniel Wortmann's avatar
Daniel Wortmann committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
  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
190
    print *,"read z:",rec
Daniel Wortmann's avatar
Daniel Wortmann committed
191 192 193 194 195 196 197 198
    
    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
199 200
     print *,"write z:",rec
   CALL write_matrix(mat,rec,id_z)
Daniel Wortmann's avatar
Daniel Wortmann committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
  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