subroutine dump_semilocal_potentials(xf,ps)
use xmlf90_wxml
type(xmlf_t), intent(inout) :: xf
type(ps_t), intent(in), target :: ps
type(semilocal_t), pointer :: slp
type(slps_t), pointer :: slvp
type(Grid_t) :: parent_grid
integer :: i, j, set
slp => ps%semilocal
do while (associated(slp))
set = slp%set
call xml_NewElement(xf,"semilocal-potentials")
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 SemiLocalPotentials block")
endif
call dump_annotation(xf,slp%annotation)
if (initialized(slp%grid)) then
parent_grid = slp%grid
call dump_grid(xf,slp%grid)
else
parent_grid = ps%global_grid
endif
slvp => slp%pot
do while (associated(slvp))
call xml_NewElement(xf,"slps")
call my_add_attribute(xf,"n",str(slvp%n))
call my_add_attribute(xf,"l",slvp%l)
call my_add_attribute(xf,"rc",str(slvp%rc))
! If eref has a physical value, output it
if (slvp%eref < 0.1*huge(1.0_dp)) then
call my_add_attribute(xf,"eref",str(slvp%eref))
endif
call my_add_attribute(xf,"flavor",slvp%flavor)
if (set == SET_LJ) then
call my_add_attribute(xf,"j",str(slvp%j,format="(f3.1)"))
endif
call dump_radfunc(xf,slvp%V,parent_grid)
call xml_EndElement(xf,"slps")
slvp => slvp%next
enddo
call xml_EndElement(xf,"semilocal-potentials")
slp => slp%next
enddo
call delete(parent_grid)
end subroutine dump_semilocal_potentials