function str_of_set(code) result(str)
integer, intent(in) :: code
character(len=40) :: str
character(len=100) :: msg
select case (code)
case (SET_NONREL)
str ="non_relativistic"
case (SET_SREL)
str ="scalar_relativistic"
case (SET_SO)
str ="spin_orbit"
case (SET_LJ)
str ="lj"
case (SET_UP)
str ="spin_up"
case (SET_DOWN)
str ="spin_down"
case (SET_SPINAVE)
str ="spin_average"
case (SET_SPINDIFF)
str ="spin_difference"
case (SET_USER1)
str ="user_extension1"
case (SET_USER2)
str ="user_extension2"
case (SET_ALL)
str ="all"
case (SET_NULL)
str ="invalid"
case default
write(msg,"(a,i4)") "Wrong set code: ", code
call die(msg)
end select
end function str_of_set