Line data Source code
1 : !--------------------------------------------------------------------------------
2 : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
3 : ! This file is part of FLEUR and available as free software under the conditions
4 : ! of the MIT license as expressed in the LICENSE file in more detail.
5 : !--------------------------------------------------------------------------------
6 :
7 : module m_io_hybrid
8 : use m_io_matrix
9 : use m_judft
10 : use m_types
11 : use m_unify_zmat
12 : implicit none
13 : !private
14 : integer, save :: id_olap, id_z, id_v_x
15 : !public:: open_hybinp_io,read_cmt,write_cmt
16 : contains
17 460 : subroutine read_z(atoms, cell, hybdat, kpts, sym, noco,nococonv, input, ik,&
18 460 : jsp, z_out, parent_z, c_phase, list)
19 : USE m_eig66_io
20 : use m_types
21 : use m_trafo
22 : implicit none
23 : type(t_atoms), intent(in) :: atoms
24 : type(t_cell), intent(in) :: cell
25 : type(t_hybdat), intent(in) :: hybdat
26 : type(t_kpts), intent(in) :: kpts
27 : type(t_sym), intent(in) :: sym
28 : type(t_noco), intent(in) :: noco
29 : TYPE(t_nococonv),INTENT(IN) :: nococonv
30 : type(t_input), intent(in) :: input
31 : integer, intent(in) :: ik, jsp
32 : TYPE(t_mat), INTENT(INOUT) :: z_out
33 :
34 : type(t_mat), intent(inout), target, optional :: parent_z
35 : complex, intent(inout), optional :: c_phase(:)
36 : integer, intent(in), optional :: list(:)
37 :
38 : INTEGER :: ikp, iop, i
39 : type(t_mat), pointer :: ptr_mat
40 460 : type(t_mat), target :: tmp_mat
41 460 : type(t_lapw) :: lapw_ik, lapw_ikp
42 460 : integer, allocatable :: p_list(:)
43 : logical, parameter :: unify_z = .False.
44 :
45 460 : REAL :: eig(input%neig)
46 :
47 460 : call timestart("read_z")
48 :
49 460 : if(present(list)) then
50 10724 : p_list = list
51 : else
52 0 : p_list = [(i, i=1,hybdat%nbands(ik,jsp))]
53 : endif
54 :
55 460 : if(ik <= kpts%nkpt) then
56 432 : call read_eig(hybdat%eig_id,ik,jsp,zmat=z_out, list=p_list, eig=eig)
57 : if(unify_z) then
58 : call check_p_list(p_list, eig)
59 : call unify_zmat(eig, z_out)
60 : endif
61 :
62 432 : if(size(p_list) /= z_out%matsize2) then
63 0 : write (*,*) size(p_list), z_out%matsize1, z_out%matsize2
64 0 : call judft_error("this doesn't match")
65 : endif
66 432 : if(present(parent_z)) then
67 60 : call parent_z%copy(z_out,1,1)
68 : endif
69 : else
70 28 : if(present(parent_z)) then
71 : ptr_mat => parent_z
72 : else
73 0 : call tmp_mat%init(z_out)
74 0 : ptr_mat => tmp_mat
75 : endif
76 :
77 28 : ikp = kpts%bkp(ik) ! parrent k-point
78 28 : iop = kpts%bksym(ik) ! connecting symm
79 :
80 28 : call read_eig(hybdat%eig_id,ikp, jsp,zmat=ptr_mat, list=p_list, eig=eig)
81 : if(unify_z) then
82 : call check_p_list(p_list, eig)
83 : call unify_zmat(eig, ptr_mat)
84 : endif
85 :
86 28 : if(size(p_list) /= ptr_mat%matsize2) then
87 0 : write (*,*) "list:", size(p_list)
88 0 : write (*,*) "ptr_mat", ptr_mat%matsize1, ptr_mat%matsize2
89 0 : write (*,*) "z_out", z_out%matsize1, z_out%matsize2
90 0 : call judft_error("this doesn't match ptr mat")
91 : endif
92 :
93 28 : CALL lapw_ik%init(input, noco, nococonv, kpts, atoms, sym, ik, cell)
94 28 : CALL lapw_ikp%init(input, noco, nococonv, kpts, atoms, sym, ikp, cell)
95 : call waveftrafo_gen_zmat(ptr_mat, ikp, iop, kpts, sym, jsp, &
96 : size(p_list), lapw_ikp, lapw_ik, z_out, &
97 28 : c_phase)
98 : endif
99 460 : call timestop("read_z")
100 460 : END subroutine read_z
101 :
102 0 : subroutine check_p_list(p_list, eig)
103 : implicit none
104 : integer, intent(in) :: p_list(:)
105 : real, intent(in) :: eig(:)
106 :
107 0 : integer, allocatable :: groups(:)
108 : logical :: succ
109 : integer :: n_g, end_group
110 :
111 0 : groups = make_groups(eig)
112 0 : succ = .false.
113 :
114 0 : do n_g = 1, size(groups)
115 0 : end_group = sum(groups(1:n_g))
116 0 : if(end_group == maxval(p_list)) then
117 0 : succ = .True.
118 : endif
119 : enddo
120 0 : if(.not. succ) call judft_error("You can't cut in the middle of deg eigenvals")
121 0 : end subroutine check_p_list
122 : end module m_io_hybrid
|