Commit af20c5cc authored by giannozz's avatar giannozz

CP can now read PW data in the DFT+U case without crashing. It's a hack

because the way ns occupancies are written to file is very questionable
and should be reconsidered. Cleanup: set_hubbard_l merged and moved to flib/

There are still incompatibilities between PW and CP data (e.g. wfcs 
in LSDA case cannot be read), and there will ever be until all I/O 
routines are completely merged (and not partially as they are now) 


git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/[email protected] c92efa57-630b-4861-b058-cf58834340f0
parent b1d2efa3
......@@ -69,6 +69,7 @@ MODULE cp_restart
USE ions_base, ONLY : nsp, nat, na, atm, zv, &
amass, iforce, ind_bck
USE funct, ONLY : get_dft_name, get_inlc
USE ldaU_cp, ONLY : lda_plus_U, ns, ldmx
USE energies, ONLY : enthal, ekin, eht, esr, eself, &
epseu, enl, exc, vave
USE mp, ONLY : mp_sum
......@@ -453,6 +454,27 @@ MODULE cp_restart
END IF ! write_charge_density
!
!-------------------------------------------------------------------------------
! ... LDA+U OCCUPATIONS (compatibility with PWscf)
!-------------------------------------------------------------------------------
!
IF ( lda_plus_u ) THEN
!
IF ( ionode ) THEN
i = LEN_TRIM( dirname )
! ugly hack to remove .save from dirname
filename = dirname (1:i-4) // 'occup'
OPEN (UNIT=iunout,FILE=filename,FORM ='formatted',STATUS='unknown')
WRITE( iunout, * , iostat = ierr) &
((( (ns(ia,is,i,j), i=1,ldmx), j=1,ldmx), is=1,nspin), ia=1,nat)
END IF
CALL mp_bcast( ierr, ionode_id, intra_image_comm )
IF ( ierr/=0 ) CALL errore('cp_writefile', 'Writing ldaU ns', 1)
IF ( ionode ) THEN
CLOSE( UNIT = iunout, STATUS = 'KEEP' )
ENDIF
!
END IF
!-------------------------------------------------------------------------------
! ... TIMESTEPS
!-------------------------------------------------------------------------------
!
......
......@@ -113,7 +113,7 @@ end module ldaU_cp
!
implicit none
integer is, nb, l
integer, external :: set_Hubbard_l
integer, external :: set_hubbard_l
IF ( .NOT.lda_plus_u ) RETURN
! allocate vupsi
......@@ -132,7 +132,7 @@ end module ldaU_cp
Hubbard_lmax = -1
do is=1,nsp
if (Hubbard_U(is).ne.0.d0) then
Hubbard_l(is) = set_Hubbard_l( atm(is) )
Hubbard_l(is) = set_hubbard_l( upf(is)%psd )
Hubbard_lmax = max(Hubbard_lmax,Hubbard_l(is))
write (6,*) ' HUBBARD L FOR TYPE ',atm(is),' IS ', Hubbard_l(is)
end if
......@@ -147,38 +147,6 @@ end module ldaU_cp
return
end subroutine ldaU_init
!
!-----------------------------------------------------------------------
integer function set_Hubbard_l(psd) result (hubbard_l)
!-----------------------------------------------------------------------
!
implicit none
character*3 :: psd
!
! TRANSITION METALS
!
if (psd.eq.'V' .or. psd.eq.'Cr' .or. psd .eq.'Mn' .or. psd.eq.'Fe' .or. &
psd.eq.'Co' .or. psd.eq.'Ni' .or. psd .eq.'Cu'.or. psd .eq.'Fe1'.or. &
psd .eq.'Fe2' ) then
hubbard_l = 2
!
! RARE EARTHS
!
elseif (psd .eq.'Ce') then
hubbard_l = 3
!
! OTHER ELEMENTS
!
elseif (psd .eq.'H') then
hubbard_l = 0
elseif (psd .eq.'O') then
hubbard_l = 1
else
hubbard_l = -1
call errore ('set_Hubbard_l','pseudopotential not yet inserted', 1)
endif
return
end function set_Hubbard_l
!
!-----------------------------------------------------------------------
subroutine new_ns( c, eigr, betae, hpsi, forceh )
!-----------------------------------------------------------------------
......
......@@ -170,7 +170,6 @@ save_in_electrons.o \
save_in_ions.o \
scale_h.o \
scf_mod.o \
set_hubbard_l.o \
set_kplusq.o \
set_kup_and_kdw.o \
set_rhoc.o \
......
......@@ -1366,7 +1366,6 @@ scf_mod.o : ../../Modules/uspp.o
scf_mod.o : ../../Modules/wavefunctions.o
scf_mod.o : paw_onecenter.o
scf_mod.o : pwcom.o
set_hubbard_l.o : ../../Modules/io_global.o
set_kplusq.o : ../../Modules/kind.o
set_kup_and_kdw.o : ../../Modules/kind.o
set_rhoc.o : ../../Modules/atom.o
......
......@@ -2890,13 +2890,12 @@ MODULE pw_restart
USE control_flags, ONLY : twfcollect, lkpoint_dir
USE cell_base, ONLY : tpiba2
USE lsda_mod, ONLY : nspin, isk
USE klist, ONLY : nkstot, wk, nelec, nks, xk, ngk
USE klist, ONLY : nkstot, wk, nks, xk, ngk
USE wvfct, ONLY : npw, npwx, g2kin, et, wg, nbnd, ecutwfc
USE wavefunctions_module, ONLY : evc
USE gvect, ONLY : ig_l2g
USE io_files, ONLY : nwordwfc, iunwfc
USE buffers, ONLY : save_buffer
USE gvect, ONLY : ngm, ngm_g, g
USE gvect, ONLY : ngm, ngm_g, g, ig_l2g
USE noncollin_module, ONLY : noncolin, npol
USE mp_global, ONLY : kunit, nproc, nproc_pool, me_pool, me_bgrp, &
root_pool, intra_pool_comm, inter_pool_comm, intra_image_comm, &
......@@ -2911,7 +2910,7 @@ MODULE pw_restart
INTEGER :: ik, ipol, ik_eff, num_k_points
INTEGER, ALLOCATABLE :: kisort(:)
INTEGER :: npool, nkbl, nkl, nkr, npwx_g, nbgrp
INTEGER :: ike, iks, npw_g, ispin
INTEGER :: nupdwn(2), ike, iks, npw_g, ispin
INTEGER, ALLOCATABLE :: ngk_g(:)
INTEGER, ALLOCATABLE :: igk_l2g(:,:), igk_l2g_kdip(:,:)
LOGICAL :: opnd
......
......@@ -34,6 +34,7 @@ radial_gradients.o \
rgen.o \
recips.o \
remove_tot_torque.o \
set_hubbard_l.o \
simpsn.o \
sort.o \
sph_bes.o \
......
......@@ -26,6 +26,7 @@ radial_gradients.o : ../Modules/kind.o
recips.o : ../Modules/kind.o
remove_tot_torque.o : ../Modules/kind.o
rgen.o : ../Modules/kind.o
set_hubbard_l.o : ../Modules/io_global.o
simpsn.o : ../Modules/kind.o
sort.o : ../Modules/kind.o
sph_bes.o : ../Modules/constants.o
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment