Write the Mmn and Amn from files
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(kmesh_info_type), | intent(in) | :: | kmesh_info | |||
| complex(kind=dp), | intent(in) | :: | au_matrix(:,:,:) | |||
| complex(kind=dp), | intent(in) | :: | m_matrix(:,:,:,:) | |||
| real(kind=dp), | intent(in), | pointer | :: | eval(:,:) | ||
| integer, | intent(in) | :: | num_bands | |||
| integer, | intent(in) | :: | num_kpts | |||
| integer, | intent(in) | :: | num_proj | |||
| integer, | intent(in) | :: | dist_k(:) | |||
| character(len=50), | intent(in) | :: | seedname | |||
| type(w90_error_type), | intent(inout), | allocatable | :: | error | ||
| type(w90_comm_type), | intent(in) | :: | comm |
subroutine overlap_write(kmesh_info, au_matrix, m_matrix, eval, num_bands, num_kpts, & num_proj, dist_k, seedname, error, comm) !================================================! !! Write the Mmn and Amn from files ! !================================================! use w90_types, only: kmesh_info_type use w90_error implicit none ! arguments type(kmesh_info_type), intent(in) :: kmesh_info type(w90_comm_type), intent(in) :: comm type(w90_error_type), allocatable, intent(inout) :: error integer, intent(in) :: num_bands, num_kpts, num_proj complex(kind=dp), intent(in) :: au_matrix(:, :, :) complex(kind=dp), intent(in) :: m_matrix(:, :, :, :) real(kind=dp), pointer, intent(in) :: eval(:, :) integer, intent(in) :: dist_k(:) character(len=50), intent(in) :: seedname complex(kind=dp), allocatable, dimension(:, :, :, :) :: m_mat_global ! local variables integer :: fu, ik, in, ip, n, m, ierr, ikp_loc allocate (m_mat_global(num_bands, num_bands, kmesh_info%nntot, num_kpts), stat=ierr) if (ierr /= 0) then call set_error_alloc(error, 'Error in allocating m_mat_global in overlap_write', comm) return end if m_mat_global = cmplx(0.0_dp, 0.0_dp, kind=dp) ikp_loc = 1 do ik = 1, num_kpts if (dist_k(ik) == mpirank(comm)) then m_mat_global(:, :, :, ik) = m_matrix(1:num_bands, 1:num_bands, 1:kmesh_info%nntot, ikp_loc) ikp_loc = ikp_loc + 1 end if end do call comms_allreduce(m_mat_global(1, 1, 1, 1), num_bands*num_bands*kmesh_info%nntot*num_kpts, 'SUM', error, comm) if (allocated(error)) return if (mpirank(comm) == 0) then ! dump overlap ("M") matrix open (newunit=fu, file=trim(seedname)//'.mmn_dump', err=201) write (fu, '(a)') "header" !header='Created on '//cdate//' at '//ctime write (fu, '(3i5)') num_bands, num_kpts, kmesh_info%nntot do ik = 1, num_kpts do in = 1, kmesh_info%nntot write (fu, *) ik, kmesh_info%nnlist(ik, in), kmesh_info%nncell(:, ik, in) do n = 1, num_bands do m = 1, num_bands write (fu, '(2f18.12)') m_mat_global(m, n, in, ik) end do end do end do end do close (fu) ! dump projections open (newunit=fu, file=trim(seedname)//'.amn_dump', err=202) write (fu, '(a)') "header" !header='Created on '//cdate//' at '//ctime write (fu, '(3i5)') num_bands, num_kpts, num_proj ! number of projections (select_proj ignored here) do ik = 1, num_kpts do ip = 1, num_proj do m = 1, num_bands write (fu, '(3i5,2f18.12)') m, ip, ik, au_matrix(m, ip, ik) end do end do end do close (fu) ! dump evals; eigenvalues are optional input (not required for wannierisation), ! only write the file when the caller has supplied them if (associated(eval)) then open (newunit=fu, file=trim(seedname)//'.eig_dump', err=203) do ik = 1, num_kpts do m = 1, num_bands write (fu, '(2i5,f18.12)') m, ik, eval(m, ik) end do end do close (fu) end if end if ! on root if (allocated(m_mat_global)) then deallocate (m_mat_global, stat=ierr) if (ierr /= 0) then call set_error_dealloc(error, 'Error in deallocating m_mat_global in overlap_write', comm) return end if end if return 201 call set_error_file(error, 'Error: Problem opening output file '//trim(seedname)//'.mmn_dump', comm) return 202 call set_error_file(error, 'Error: Problem opening output file '//trim(seedname)//'.amn_dump', comm) return 203 call set_error_file(error, 'Error: Problem opening output file '//trim(seedname)//'.eig_dump', comm) return end subroutine overlap_write