#!/bin/sh

if test "x$UGROOT" = "x"
then
        echo "$0: to use $0 set shell environment variable UGROOT!";
        exit 1;
fi

# if no parameter is specified make in current directory
if test $# -eq 0 
then
        echo "UG demonstration";
        echo "usage: ugdemo XXX";   
if test -x $UGROOT/../ns/appl2d/ns2d
then
        echo "dc2d: Navier Stokes driven cavity 2d";
fi
if test -x $UGROOT/../ns/appl3d/ns3d
then
        echo "dc3d: Navier Stokes driven cavity 3d";
fi
if test -x $UGROOT/../df/gen/appl/df2d
then
        echo "df2d: Density driven flow 2d";
fi
if test -x $UGROOT/../sc/appl2d/sc2d
then
        echo "pm2d: Poros media equation 2d";   
        echo "tu2d: Scalar tutorial script 2d";   
fi
if test -x $UGROOT/../fe/appl/fe2d
then
        echo "ep3d: Elasto-plasticity 3d";
fi
if test -x $UGROOT/../fe/appl/fe2d
then
        echo "ep2d: Elasto-plasticity 2d";
        echo "ew2d: Eigenvalues of the Wolfgangssee";
        echo "ball: Local refinement of a ball";
        echo "disc: Demonstration of discretization 2d";
        echo "diff: Diffusion equation 2d";
        echo "er2d: Error bounds for the Emden equation 2d";
fi
fi

if test $# -eq 1
then
	PROC=1
fi
if test $# -ge 2
then
	PROC=$2
fi



if test $# -ge 1 
then
        # check whether first  option is ug module 
        case $1 in
        dc2d)
			cd $UGROOT/../ns/appl2d
			ugrun ns2d $PROC ugdemo.scr -noquit
			;;
        dc3d)
			cd $UGROOT/../ns/appl3d
			ugrun ns3d $PROC ugdemo.scr -noquit
			;;
        pm2d)
			cd $UGROOT/../sc/appl2d
			ugrun sc2d $PROC ugdemo.scr -noquit
			;;
        df2d)
			cd $UGROOT/../df/gen/appl
			ugrun df2d $PROC ugdemo.scr -noquit
			;;
        ep2d)
			cd $UGROOT/../fe/appl
			ugrun fe2d $PROC ep2d.scr -noquit
			;;
        ep3d)
			cd $UGROOT/../fe/appl
			ugrun fe3d $PROC ep3d.scr -noquit
			;;
        ball)
			cd $UGROOT/../fe/appl
			ugrun fe3d $PROC ugdemo3d.scr -noquit
			;;
        diff)
			cd $UGROOT/../fe/appl
			ugrun fe2d $PROC diff.scr -noquit
			;;
        disc)
			cd $UGROOT/../fe/appl
			ugrun fe2d $PROC ugdemo2d.scr -noquit
			;;
        ew2d)
			cd $UGROOT/../fe/appl
			ugrun fe2d $PROC ew2d.scr -noquit
			;;
        er2d)
			cd $UGROOT/../fe/appl
			ugrun fe2d $PROC er2d.scr -noquit
			;;
        tu2d)
			cd $UGROOT/../sc/appl2d
			ugrun sc2d $PROC tutorial.scr -noquit
			;;
        *)
                echo "target $1 not found";
                exit 1;
                ;;
        esac;
fi

exit 0;
