Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: calling w90 as a lib twice does not reinitialize Hamiltonian #224

Merged
merged 3 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/hamiltonian.F90
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ subroutine hamiltonian_dealloc()
if (ierr /= 0) call io_error('Error in deallocating wannier_centres_translated in param_dealloc')
end if

ham_have_setup = .false.
have_translated = .false.
use_translation = .false.
have_ham_r = .false.
have_ham_k = .false.
hr_written = .false.
tb_written = .false.

return
end subroutine hamiltonian_dealloc

Expand Down
16 changes: 14 additions & 2 deletions src/wannierise.F90
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,17 @@ subroutine wann_main
if (ierr /= 0) call io_error('Error in allocating cdq in wann_main')

! for MPI
allocate (counts(0:num_nodes - 1), displs(0:num_nodes - 1), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating counts and displs in wann_main')
if (allocated(counts)) deallocate (counts)
allocate (counts(0:num_nodes - 1), stat=ierr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to also add a if (allocated(counts)) deallocate(counts) as you do below for displs?

if (ierr /= 0) then
call io_error('Error in allocating counts in wann_main')
end if

if (allocated(displs)) deallocate (displs)
allocate (displs(0:num_nodes - 1), stat=ierr)
if (ierr /= 0) then
call io_error('Error in allocating displs in wann_main')
end if
call comms_array_split(num_kpts, counts, displs)
allocate (rnkb_loc(num_wann, nntot, max(1, counts(my_node_id))), stat=ierr)
if (ierr /= 0) call io_error('Error in allocating rnkb_loc in wann_main')
Expand Down Expand Up @@ -801,6 +810,9 @@ subroutine wann_main
if (ierr /= 0) call io_error('Error in deallocating m0_loc in wann_main')
end if

if (allocated(counts)) deallocate (counts)
if (allocated(displs)) deallocate (displs)

deallocate (history, stat=ierr)
if (ierr /= 0) call io_error('Error deallocating history in wann_main')

Expand Down