#! /bin/csh
#
set N = 10
if ($#argv > 0) then
    if ("$1" == "-help") then
	echo "$0 [ nn [ other-args] ] run tests of the solvers"
	echo "nn is the size of the problem; 10 is the default."
	echo "All other arguments are passed to each call to the example"
	echo "program.  This can be used, for example, to specify a directory"
	echo "to hold the results using the SVDB format.  The arguments for"
	echo "this are -fdb directory -fdb string -fdbres [file | directory]"
	exit 0;
    endif
    set N = $1
    shift
endif
#
example3 -n $N -sv lu -ordering nd $*
foreach ordering ( rcm qmd 1wd )
    example3 -n $N -sv lu -noheader -ordering $ordering $*
end
foreach svmethod ( jacobi ssor ilu icc iccjp bdd osm nopre )
    # -itmethod lsqr only works for nopre for now
    foreach itmethod ( richardson chebychev cg gmres tcqmr bcgs cgs tfqmr )
	# A switch for the special cases:
	switch ($svmethod)
	case ilu:
	foreach fill ( 0 1 2 3 )
            example3 -n $N -sv $svmethod -noheader -itmethod $itmethod \
	             -ilufill $fill -title "$svmethod $itmethod fill=$fill" $*
	end
        foreach drop ( 1.e-5 1.e-3 1.e-1 )
            example3 -n $N -sv $svmethod -noheader -itmethod $itmethod \
	             -iludrop $drop -title "$svmethod $itmethod drop=$drop" \
		     fill=10 $*
        end
	breaksw

	case bdd:
	case osm:
	foreach decomp ( "" -2d )
  	    # lu (nd) inner method
            example3 -n $N -sv $svmethod -noheader -itmethod $itmethod \
	             $decomp -title "$svmethod $itmethod $decomp" $*
#	    # Inner iterations are not working yet...
#	    # Use -1 for iterate to convergence
#	    foreach maxit (1 2 3)
#	        foreach svinner ( jacobi ssor ilu bdd osm nopre )
#		    foreach itinner ( richardson gmres tcqmr bcgs cgs tfqmr )
#	               example3 -n $N -sv $svmethod -noheader \
#                               -itmethod $itmethod \
#			        -maxit $maxit -sv $svinner -itmethod $itinner \
#        -title "$svmethod $itmethod inner $svinner $itinner $maxit $decomp" $*
#                   end
#   		end
#	    end
	end

	breaksw

	default:
	example3 -n $N -sv $svmethod -noheader -itmethod $itmethod $*
	endsw

    end
end
