Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/cdft_data_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ module cdft_data
end type atom_list
type(atom_list), dimension(:), allocatable :: cDFT_AtomList

character(len=80) :: cDFT_AtomIndexFile
character(len=80) :: cDFT_block_line
integer :: io_cDFT
integer :: cDFT_current_atom_idx
integer :: cDFT_k
integer :: cDFT_dash_pos, cDFT_num_start, cDFT_num_end

!!***


Expand Down
26 changes: 23 additions & 3 deletions src/cdft_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ subroutine init_cdft
implicit none

integer :: i, j, stat, spin
character(len=10) :: k_str
character(len=10) :: ni_in_cell_str
logical, dimension(:), allocatable :: cDFT_AtomMask

if (cDFT_NumberAtomGroups > 2) then
call cq_abort("Maximum of two groups permitted for cDFT (for &
Expand All @@ -98,15 +101,32 @@ subroutine init_cdft
ni_in_cell)
flag_cdft_atom = 0
allocate(bwgrid(maxngrid, cDFT_NumberAtomGroups), STAT=stat)
allocate(cDFT_AtomMask(ni_in_cell))
cDFT_AtomMask = .false.
do i = 1, cDFT_NumberAtomGroups
if (inode == ionode .AND. iprint_SC >= 0) &
write (io_lun, fmt='(6x,"cDFT Atom Group ",i4," Target: ",f12.5)') &
i, cDFT_Target(i)
do j = 1, cDFT_NAtoms(i)
flag_cdft_atom(cDFT_AtomList(i)%Numbers(j)) = i
if (inode == ionode .AND. iprint_SC > 1) &
write (io_lun, fmt='(4x,"Atom ",2i8)') &
j, cDFT_AtomList(i)%Numbers(j)
if (inode == ionode .AND. iprint_SC > 1) then
cDFT_k = cDFT_AtomList(i)%Numbers(j)
write (io_lun, fmt='(4x,"Atom ",2i8)') j, cDFT_k
if (cDFT_k > ni_in_cell) then
write (unit=k_str, fmt='(I10)') cDFT_k
write (unit=ni_in_cell_str, fmt='(I10)') ni_in_cell
call cq_abort('Atom index ' // trim(adjustl(k_str)) // &
' has exceeded total atoms (' // &
trim(adjustl(ni_in_cell_str)) // ').')
end if
if (cDFT_AtomMask(cDFT_k)) then
write (io_lun, fmt='(2x, "Duplicate atom index found:", i6)') &
cDFT_k
call cq_abort('Duplicate atom index detected.')
else
cDFT_AtomMask(cDFT_k) = .true.
end if
end if
enddo
end do
allocate(matHzero(nspin), STAT=stat)
Expand Down
76 changes: 68 additions & 8 deletions src/initial_read_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -940,11 +940,13 @@ subroutine read_input(start, start_L, titles, vary_mu,&
TimersWriteOut, BackTraceOn
use input_module, only: load_input, input_array, block_start, &
block_end, fdf_boolean, fdf_integer, fdf_double, fdf_string, &
fdf_block, fdf_defined, leqi, io_assign, fdf_endblock
fdf_block, fdf_defined, leqi, io_assign, fdf_endblock, io_close
use cdft_data, only: cDFT_Type, cDFT_MaxIterations, cDFT_NAtoms, &
cDFT_Target, cDFT_Tolerance, &
cDFT_NumberAtomGroups, cDFT_AtomList, &
cDFT_BlockLabel
cDFT_BlockLabel, cDFT_AtomIndexFile, cDFT_block_line, &
cDFT_dash_pos, cDFT_num_start, cDFT_num_end, &
cDFT_current_atom_idx, cDFT_k, io_cDFT
use sfc_partitions_module, only: n_parts_user, average_atomic_diameter, gap_threshold
use XLBOMD_module, only: XLInitFreq,kappa
use mult_module, only: maxiter_Dissipation, InitAtomicDistance_max, &
Expand Down Expand Up @@ -1838,9 +1840,38 @@ subroutine read_input(start, start_L, titles, vary_mu,&
do i=1,cDFT_NumberAtomGroups
if(fdf_block(cDFT_BlockLabel(i))) then
allocate(cDFT_AtomList(i)%Numbers(cDFT_NAtoms(i)))
do j=1,cDFT_NAtoms(i)
read(unit=input_array(block_start+j-1),fmt=*) cDFT_AtomList(i)%Numbers(j)
enddo
cDFT_AtomIndexFile=fdf_string(80,'cDFT.AtomIndexFile',def)
if(leqi(def,cDFT_AtomIndexFile)) &
call cq_abort("Must define cDFT.AtomIndexFile.")
call io_assign(io_cDFT)
open(unit=io_cDFT,file=cDFT_AtomIndexFile,iostat=stat,status='old')
if(stat/=0) &
call cq_abort("Failed to open cDFT.AtomIndexFile: " // &
trim(cDFT_AtomIndexFile), stat)
cDFT_current_atom_idx=0
do
read(unit=io_cDFT,fmt='(A)',iostat=stat) cDFT_block_line
if(stat<0) exit
if(stat>0) cycle
if (trim(cDFT_block_line)=='' .or. cDFT_block_line(1:1)=='#') cycle
cDFT_dash_pos=index(cDFT_block_line,'-')
if(cDFT_dash_pos==0) then
read(unit=cDFT_block_line,fmt=*) cDFT_num_start
cDFT_num_end=cDFT_num_start
else
read(unit=cDFT_block_line(:cDFT_dash_pos-1),fmt=*) cDFT_num_start
read(unit=cDFT_block_line(cDFT_dash_pos+1:),fmt=*) cDFT_num_end
end if
do cDFT_k=cDFT_num_start, cDFT_num_end
cDFT_current_atom_idx=cDFT_current_atom_idx+1
if (cDFT_current_atom_idx>cDFT_NAtoms(i)) &
call cq_abort('The defined atom indexes are too much.')
cDFT_AtomList(i)%Numbers(cDFT_current_atom_idx)=cDFT_k
end do
end do
call io_close(io_cDFT)
if (cDFT_current_atom_idx<cDFT_NAtoms(i)) &
call cq_abort('The defined atom indexes are not enough.')
else
call cq_abort('cDFT block not defined: '//cDFT_BlockLabel(i))
end if
Expand Down Expand Up @@ -1890,9 +1921,38 @@ subroutine read_input(start, start_L, titles, vary_mu,&
do i=1,cDFT_NumberAtomGroups
if(fdf_block(cDFT_BlockLabel(i))) then
allocate(cDFT_AtomList(i)%Numbers(cDFT_NAtoms(i)))
do j=1,cDFT_NAtoms(i)
read(unit=input_array(block_start+j-1),fmt=*) cDFT_AtomList(i)%Numbers(j)
enddo
cDFT_AtomIndexFile=fdf_string(80,'cDFT.AtomIndexFile',def)
if(leqi(def,cDFT_AtomIndexFile)) &
call cq_abort("Must define cDFT.AtomIndexFile.")
call io_assign(io_cDFT)
open(unit=io_cDFT,file=cDFT_AtomIndexFile,iostat=stat,status='old')
if(stat/=0) &
call cq_abort("Failed to open cDFT.AtomIndexFile: " // &
trim(cDFT_AtomIndexFile), stat)
cDFT_current_atom_idx=0
do
read(unit=io_cDFT,fmt='(A)',iostat=stat) cDFT_block_line
if(stat<0) exit
if(stat>0) cycle
if (trim(cDFT_block_line)=='' .or. cDFT_block_line(1:1)=='#') cycle
cDFT_dash_pos=index(cDFT_block_line,'-')
if(cDFT_dash_pos==0) then
read(unit=cDFT_block_line,fmt=*) cDFT_num_start
cDFT_num_end=cDFT_num_start
else
read(unit=cDFT_block_line(:cDFT_dash_pos-1),fmt=*) cDFT_num_start
read(unit=cDFT_block_line(cDFT_dash_pos+1:),fmt=*) cDFT_num_end
end if
do cDFT_k=cDFT_num_start,cDFT_num_end
cDFT_current_atom_idx=cDFT_current_atom_idx+1
if (cDFT_current_atom_idx>cDFT_NAtoms(i)) &
call cq_abort('The defined atom indexes are too much.')
cDFT_AtomList(i)%Numbers(cDFT_current_atom_idx)=cDFT_k
end do
end do
call io_close(io_cDFT)
if (cDFT_current_atom_idx<cDFT_NAtoms(i)) &
call cq_abort('The defined atom indexes are not enough.')
else
call cq_abort('cDFT block not defined: '//cDFT_BlockLabel(i))
end if
Expand Down