Skip to content

Commit

Permalink
cleanup set_atoms and move projector read to _read_special()
Browse files Browse the repository at this point in the history
(and allow projector definition to be skipped)
  • Loading branch information
Jerome Jackson committed Jan 15, 2025
1 parent 7028621 commit cb63df0
Show file tree
Hide file tree
Showing 6 changed files with 389 additions and 302 deletions.
2 changes: 1 addition & 1 deletion src/c_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ subroutine cinput_setopt(common_cptr, seedname, ierr, comm) bind(c)
call w90_get_fortran_stderr(istderr)
call w90_get_fortran_stdout(istdout)
call c_f_pointer(common_cptr, common_fptr)
call w90_input_setopt(common_fptr, seedname, comm, istdout, istderr, ierr)
call w90_input_setopt(common_fptr, seedname, istdout, istderr, ierr)
end subroutine cinput_setopt

subroutine cinput_reader(common_cptr, ierr) bind(c)
Expand Down
41 changes: 37 additions & 4 deletions src/library_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ module w90_library
module procedure w90_set_option_i2d
module procedure w90_set_option_r1d
module procedure w90_set_option_r2d
module procedure w90_set_option_c2d
module procedure w90_set_option_real
end interface w90_set_option

Expand Down Expand Up @@ -245,6 +246,8 @@ subroutine w90_input_setopt(common_data, seedname, istdout, istderr, ierr)
return
endif

! input_setopt() processes options stored in a container, common_data%settings
! meanwhile the .win file contents are stored in common_data%in_data, which should be empty here
if (allocated(common_data%settings%in_data)) then
call set_error_fatal(error, ' readinput and setopt clash at input_setopt call', common_data%comm)
call prterr(error, ierr, istdout, istderr, common_data%comm)
Expand Down Expand Up @@ -338,7 +341,7 @@ subroutine w90_input_setopt(common_data, seedname, istdout, istderr, ierr)
return
endif

! clear any settings (from settings interface not .win file)
! clear settings container (from settings interface not .win file)
deallocate (common_data%settings%entries, stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error in deallocating entries data in input_setopt() library call', common_data%comm)
Expand Down Expand Up @@ -437,6 +440,7 @@ subroutine w90_disentangle(common_data, istdout, istderr, ierr)

! local variables
type(w90_error_type), allocatable :: error
integer :: ioff

ierr = 0

Expand All @@ -463,8 +467,15 @@ subroutine w90_disentangle(common_data, istdout, istderr, ierr)
if (common_data%dis_manifold%win_min == -huge(0.0_dp)) common_data%dis_manifold%win_min = minval(common_data%eigval)
if (common_data%dis_manifold%win_max == huge(0.0_dp)) common_data%dis_manifold%win_max = maxval(common_data%eigval)
if (common_data%dis_manifold%frozen_states) then
if (common_data%dis_manifold%froz_min == -huge(0.0_dp)) &
common_data%dis_manifold%froz_min = common_data%dis_manifold%win_min
!write(*,*) shape(common_data%eigval)
!write(*,*) shape(common_data%dis_manifold%lwindow)
if (common_data%dis_manifold%froz_min == -huge(0.0_dp)) then
ioff = maxval(common_data%exclude_bands)
common_data%dis_manifold%froz_min = minval(common_data%eigval(ioff + 1, :))
endif
!common_data%dis_manifold%froz_min = minval(common_data%eigval, mask=common_data%dis_manifold%lwindow)
!write(*,*)common_data%dis_manifold%froz_min,allocated(common_data%dis_manifold%lwindow),&
! count(common_data%dis_manifold%lwindow)
endif

if (common_data%num_bands > common_data%num_wann) then
Expand Down Expand Up @@ -879,6 +890,24 @@ subroutine w90_set_option_r2d(common_data, keyword, arr)
if (common_data%settings%num_entries == common_data%settings%num_entries_max) call expand_settings(common_data%settings)
endsubroutine w90_set_option_r2d

subroutine w90_set_option_c2d(common_data, keyword, arr)
use w90_readwrite, only: init_settings, expand_settings

implicit none

character(*), intent(in) :: keyword
character(len=*), intent(in) :: arr(:)
type(lib_common_type), intent(inout) :: common_data
integer :: i

if (.not. allocated(common_data%settings%entries)) call init_settings(common_data%settings)
i = common_data%settings%num_entries + 1
common_data%settings%entries(i)%keyword = keyword
common_data%settings%entries(i)%c2d = arr
common_data%settings%num_entries = i + 1
if (common_data%settings%num_entries == common_data%settings%num_entries_max) call expand_settings(common_data%settings)
endsubroutine w90_set_option_c2d

subroutine w90_set_option_real(common_data, keyword, rval)
use w90_readwrite, only: init_settings, expand_settings

Expand Down Expand Up @@ -1009,7 +1038,7 @@ subroutine w90_get_proj(common_data, n, site, l, m, s, rad, x, z, sqa, istdout,
integer, intent(in) :: istdout, istderr

! probably the remaining variables find limited use, allow them to be absent
integer, intent(inout), optional :: rad(:)
integer, intent(inout) :: rad(:)
real(kind=dp), intent(inout) :: sqa(:, :), z(:, :), x(:, :) !, zona(:)

! local variables
Expand All @@ -1027,6 +1056,8 @@ subroutine w90_get_proj(common_data, n, site, l, m, s, rad, x, z, sqa, istdout,

n = size(common_data%proj_input)

write (*, *) "expecting: ", n

! check allocation of main output arrays
if (size(l) < n) then
call set_error_fatal(error, 'Array argument l in get_proj() call is insufficiently sized', common_data%comm)
Expand Down Expand Up @@ -1089,6 +1120,8 @@ subroutine w90_get_proj(common_data, n, site, l, m, s, rad, x, z, sqa, istdout,
z(:, ip) = proj%z(:)
x(:, ip) = proj%x(:)
rad(ip) = proj%radial

write (*, *) " projector : ", l(ip), m(ip), s(ip)
!if (present(zona)) zona(ip) = proj%zona
enddo
end subroutine w90_get_proj
Expand Down
6 changes: 3 additions & 3 deletions src/postw90/postw90_readwrite.F90
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ subroutine w90_postw90_readwrite_read(settings, ws_region, w90_system, exclude_b
if (allocated(error)) return
call w90_readwrite_read_exclude_bands(settings, exclude_bands, num_exclude_bands, error, comm)
if (allocated(error)) return
call w90_readwrite_read_num_bands(settings, effective_model, num_bands, num_wann, stdout, &
error, comm)
call w90_readwrite_read_num_bands(settings, effective_model, num_bands, num_wann, error, comm)
if (allocated(error)) return
disentanglement = (num_bands > num_wann)
call w90_readwrite_read_mp_grid(settings, effective_model, mp_grid, num_kpts, error, comm)
Expand Down Expand Up @@ -224,7 +223,8 @@ subroutine w90_postw90_readwrite_read(settings, ws_region, w90_system, exclude_b
dis_manifold%win_max = 0.0_dp
if (eig_found) dis_manifold%win_min = minval(eigval)
if (eig_found) dis_manifold%win_max = maxval(eigval)
call w90_readwrite_read_dis_manifold(settings, eig_found, dis_manifold, error, comm)
call w90_readwrite_read_dis_manifold(settings, dis_manifold, error, comm)

if (allocated(error)) return
call w90_wannier90_readwrite_read_geninterp(settings, pw90_geninterp, error, comm)
if (allocated(error)) return
Expand Down
Loading

0 comments on commit cb63df0

Please sign in to comment.