; which_atom spin
;
; returns the atom id of spin 

set s = $_
set s = $spin<$s>
set nam = (head(tail($s)))
set res = (head($sys<head(tail(tail($s)))>))	a verif
if ($res s= "unk" ) print "Not assigned spin"  exit

set ha = (100*$res)
while (exist("struct<" // $ha // ">")
	set s = $struct<$ha>
	if (index($s,$nam) != 0) then
		set returned := $ha
		goto done
	endif
	set ha = (%+1)
endwhile
error ("Spin"; $a; "not found in structure")
=done
set returned := $ha
