; list_assign
;
; list all assign entries to a file
set tmp = ('tmp' // int(1000000*$random))
sh ('pwd >'; $tmp)
open $tmp
set pwd = <$tmp
close $tmp
open assign_list
set prim = "db/primary"    open $prim
set aa = 0
fprint assign_list ("# Project :"; $pwd)
set laa = <$prim   set aa = ($aa+1)
while (!eof($prim))
  find sys 1 $aa
  if (($pk_fnd_dst < 0.1) ) then     ; this one is assigned
	if ($pk_fnd s! "LARGEST") then
	   set ss = $sys[$pk_fnd]
	else
	   set ss = $sys[$pk_fnd]
	endif
	fprint assign_list ($aa; $laa; "assigned to :"; $ss)
	set ss = (tail(tail($ss)))    ; keep only the spin part
	while ($ss s! ' ')
	   set sp = $spin[head($ss)]      set ss = (tail($ss))
	   fprint assign_list ("------";$sp)
	endwhile
  else
	fprint assign_list ($aa; $laa; "- not assigned -")
  endif
  set laa = <$prim   set aa = ($aa+1)
endwhile
close assign_list
formbox "List of Spin-Systems" DO_NOTHING 'File is assign_list' message assign_list text *
