Skip to content

Commit

Permalink
Merge pull request #224 from mjv500/develop
Browse files Browse the repository at this point in the history
bugfix: calling w90 as a lib twice does not reinitialize Hamiltonian
  • Loading branch information
giovannipizzi authored Dec 21, 2018
2 parents 4555d4b + f5d9ea6 commit d4a2455
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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)
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

0 comments on commit d4a2455

Please sign in to comment.