subroutine dump_config_val(xf,p)
use xmlf90_wxml
type(xmlf_t), intent(inout) :: xf
type(config_val_t), intent(in) :: p
integer :: i
call xml_NewElement(xf,"valence-configuration")
call my_add_attribute(xf,"total-valence-charge",str(p%total_charge))
call dump_annotation(xf,p%annotation)
do i = 1, p%nshells
call xml_NewElement(xf,"shell")
call my_add_attribute(xf,"n",str(p%n(i)))
call my_add_attribute(xf,"l",p%l(i))
call my_add_attribute(xf,"occupation",str(p%occ(i)))
if ((p%occ_up(i) + p%occ_down(i)) /= 0.0_dp) then
call my_add_attribute(xf,"occupation-down",str(p%occ_down(i)))
call my_add_attribute(xf,"occupation-up",str(p%occ_up(i)))
endif
call xml_EndElement(xf,"shell")
enddo
call xml_EndElement(xf,"valence-configuration")
end subroutine dump_config_val