function setcode_of_string(str) result(code)
character(len=*), intent(in) :: str
integer :: code
select case (trim(str))
case ("non_relativistic")
code = SET_NONREL
case ("scalar_relativistic")
code = SET_SREL
case ("spin_orbit")
code = SET_SO
case ("lj")
code = SET_LJ
case ("spin_up")
code = SET_UP
case ("spin_down")
code = SET_DOWN
case ("spin_average")
code = SET_SPINAVE
case ("spin_difference")
code = SET_SPINDIFF
case ("user_extension1")
code = SET_USER1
case ("user_extension2")
code = SET_USER2
case ("all","any")
code = SET_ALL
case ("invalid","INVALID")
code = SET_NULL
case default
call die("Wrong set string: "//trim(str))
end select
end function setcode_of_string