subroutine generate_table_sl(ps)
type(ps_t), intent(inout), target :: ps
type(semilocal_t), pointer :: slp
type(slps_t), pointer :: slvp
integer :: npots
if (allocated(ps%sl_table)) then
deallocate(ps%sl_table)
endif
npots = 0
slp => ps%semilocal
do while (associated(slp))
slvp => slp%pot
do while (associated(slvp))
npots = npots + 1
slvp => slvp%next
enddo
slp => slp%next
enddo
allocate(ps%sl_table(npots))
npots = 0
slp => ps%semilocal
do while (associated(slp))
slvp => slp%pot
do while (associated(slvp))
npots = npots + 1
ps%sl_table(npots)%p => slvp
slvp => slvp%next
enddo
slp => slp%next
enddo
end subroutine generate_table_sl