io_hybrid.F90 5.85 KB
Newer Older
Daniel Wortmann's avatar
Daniel Wortmann committed
1 2 3 4 5 6
module m_io_hybrid
  use m_io_matrix
  use m_judft
  use m_types
  implicit none
  !private
Daniel Wortmann's avatar
Daniel Wortmann committed
7
  integer,save :: id_olap,id_z,id_v_x,id_coulomb,id_coulomb_spm
Daniel Wortmann's avatar
Daniel Wortmann committed
8 9 10 11 12 13 14 15 16 17
  !public:: open_hybrid_io,read_cmt,write_cmt
contains

  subroutine open_hybrid_io(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

Daniel Wortmann's avatar
Daniel Wortmann committed
18
    INTEGER:: irecl_coulomb
Daniel Wortmann's avatar
Daniel Wortmann committed
19 20 21 22 23 24 25 26 27
    
    OPEN(unit=777,file='cmt',form='unformatted',access='direct',&
         &     recl=dimension%neigd*hybrid%maxlmindx*atoms%nat*16)
    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")
Daniel Wortmann's avatar
Daniel Wortmann committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#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
Daniel Wortmann's avatar
Daniel Wortmann committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
  end subroutine open_hybrid_io
  
  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
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
  subroutine write_coulomb(nk,l_real,coulomb)
    implicit none
    complex,intent(in) :: coulomb(:)
    integer,intent(in) :: l_real
    logical,intent(in) :: nk

    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
78 79 80
    real,intent(in)    :: coulomb_mt1(:,:,:,:)
    real,intent(in) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    real,intent(in) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
81 82
    integer,intent(in) :: nk
    
Daniel Wortmann's avatar
Daniel Wortmann committed
83
    print *, "write coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
Daniel Wortmann's avatar
Daniel Wortmann committed
84 85 86 87 88
    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
89 90 91
    real,intent(in)    :: coulomb_mt1(:,:,:,:)
    complex,intent(in) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    complex,intent(in) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
92 93 94 95 96 97 98
    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
99 100 101
    real,intent(out)    :: coulomb_mt1(:,:,:,:)
    real,intent(out) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    real,intent(out) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
102 103
    integer,intent(in) :: nk
    
Daniel Wortmann's avatar
Daniel Wortmann committed
104
    print *, "read coulomb",nk,size(coulomb_mt1),size(coulomb_mt2),size(coulomb_mt3),size(coulomb_mtir)
Daniel Wortmann's avatar
Daniel Wortmann committed
105 106 107 108 109
    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
110 111 112
    real,intent(out)    :: coulomb_mt1(:,:,:,:)
    complex,intent(out) :: coulomb_mt2(:,:,:,:), coulomb_mt3(:,:,:)
    complex,intent(out) :: coulomb_mtir(:)
Daniel Wortmann's avatar
Daniel Wortmann committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
    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(:)
    logical,intent(in) :: nk

    read(id_coulomb,rec=nk) coulomb
  end subroutine read_coulomb_r
  
  subroutine read_coulomb_c(nk,coulomb)
    implicit none
    complex,intent(out) :: coulomb(:)
    logical,intent(in) :: nk
    
    read(id_coulomb,rec=nk) coulomb
  end subroutine read_coulomb_c
Daniel Wortmann's avatar
Daniel Wortmann committed
132

Daniel Wortmann's avatar
Daniel Wortmann committed
133 134

  
Daniel Wortmann's avatar
Daniel Wortmann committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
  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
155
    print *,"read z:",rec
Daniel Wortmann's avatar
Daniel Wortmann committed
156 157 158 159 160 161 162 163
    
    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
164 165
     print *,"write z:",rec
   CALL write_matrix(mat,rec,id_z)
Daniel Wortmann's avatar
Daniel Wortmann committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
  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