subroutine dump_pseudo_wavefunctions(xf,ps)
use xmlf90_wxml
type(xmlf_t), intent(inout) :: xf
type(ps_t), intent(in), target :: ps
type(wfns_t), pointer :: wfp
type(wf_t), pointer :: wfpp
type(Grid_t) :: parent_grid
integer :: set
wfp => ps%wavefunctions
do while (associated(wfp))
set = wfp%set
call xml_NewElement(xf,"pseudo-wave-functions")
if (set /= SET_NULL) then
! Group set was specified
call my_add_attribute(xf,"set",str_of_set(set))
else
call die("Set not specified in Wavefunctions block")
endif
! if (wfp%type /= "") then
! call my_add_attribute(xf,"type",wfp%type)
! endif
call dump_annotation(xf,wfp%annotation)
if (initialized(wfp%grid)) then
parent_grid = wfp%grid
call dump_grid(xf,wfp%grid)
else
parent_grid = ps%global_grid
endif
wfpp => wfp%wf
do while (associated(wfpp))
call xml_NewElement(xf,"pswf")
call my_add_attribute(xf,"n",str(wfpp%n))
call my_add_attribute(xf,"l",wfpp%l)
if (set == SET_LJ) then
call my_add_attribute(xf,"j",str(wfpp%j,format="(f3.1)"))
endif
! If energy_level has a physical value, output it
if (wfpp%energy_level < 0.1*huge(1.0_dp)) then
call my_add_attribute(xf,"energy_level",str(wfpp%energy_level))
endif
call dump_radfunc(xf,wfpp%Phi,parent_grid)
call xml_EndElement(xf,"pswf")
wfpp => wfpp%next
enddo
call xml_EndElement(xf,"pseudo-wave-functions")
wfp => wfp%next
enddo
call delete(parent_grid)
end subroutine dump_pseudo_wavefunctions