#!/bin/sh

   if test -x /vmunix
       then
       sys="sun"
       print_cmd=lpr
       echo_cmd='echo -e'
   elif test -x /hp-ux
       then
       sys="hp"
       print_cmd=lp
       echo_cmd='echo'
   elif test `uname -s | grep -i -e LINUX`
       then
       sys="linux"
       print_cmd=lpr
       echo_cmd='echo -e'
   elif test `uname -s | grep -i -e CYGWIN`
       then
       sys="cygwin"
       print_cmd=lpr
       echo_cmd='echo -e'
   else
       sys="none"
       echo_cmd='echo'
   fi

   export SIMO_RUNDIR=`dirname $0`"/.."

   echo
   echo '*********************************************************'
   echo '*   WELCOME TO                                          *'
   echo '*                                                       *'
   echo '*    SSSSSSSSSS    III   MMMMM    MMMM     OOOOOOOO     *'
   echo '*   SSSSSSSSSSSS   III   MMMMM   MMMMM    OOOOOOOOOO    *'
   echo '*   SSS            III   MMMMMM MMMMMM   OOO      OOO   *'
   echo '*   SSS            III   MMM MMMMM MMM   OOO      OOO   *'
   echo '*   SSSSSSSSSS     III   MMM  MMM  MMM   OOO      OOO   *'
   echo '*   SSSSSSSSSSS    III   MMM   M   MMM   OOO      OOO   *'
   echo '*           SSS    III   MMM       MMM   OOO      OOO   *'
   echo '*           SSS    III   MMM       MMM   OOO      OOO   *'
   echo '*   SSSSSSSSSSS    III   MMM       MMM    OOOOOOOOOO    *'
   echo '*    SSSSSSSSS     III   MMM       MMM     OOOOOOOO     *'
   echo '*                                                       *'
   echo '*   SIMULATION OF COMPLEX MARINE OPERATIONS             *'
   echo '*********************************************************'
   echo

   if test ! "$1" 
       then
       $echo_cmd "Enter system identifier > \c"
       read chsys
   fi

   if test ! "$2"
       then
       $echo_cmd "Enter initial condition identifier > \c"
       read chini
   fi

   if test ! "$chsys"
       then
       sysfil=""
   else
       sysfil=-$chsys
   fi

   if test ! "$chini"
       then
       inifil=""
   else
       inifil=-$chini
   fi

   trap continue 1 2 3 15

   input=""
   while test "$input" != "term" -a "$input" != "TERM"
     do
        echo
        echo 'I-> SELECTION OF PROGRAM MODULE'
        echo 'I'
        echo 'I      INP  - SIMO INPMOD'
        echo 'I      STA  - SIMO STAMOD'
        echo 'I      DYN  - SIMO DYNMOD'
        echo 'I      OUT  - SIMO OUTMOD'
        echo 'I      PLO  - SIMO/RIFLEX PLOMOD'
        echo 'I      S2X  - SIMO S2XMOD'
        echo 'I'
        echo 'I      PINP - Print postscript inpmod/stamod/outmod file (simo.plt)'
        echo 'I      PPLO - Print postscript plomod file (pscr-meta.dat)'
        echo 'I'
        echo 'I      DEF  - Redefine identifiers (for default file names)'
        echo 'I      LIS  - List identifiers (for default file names)'
        echo 'I'
        echo 'I      TERM - Terminate'
        echo 'I'

	$echo_cmd "Select option > \c"
        read input

        if test "$input" = "inp" -o "$input" = "INP"
	    then
	    module=inpmod
	    input=run
        elif test "$input" = "sta" -o "$input" = "STA"
	    then
	    module=stamod
	    input=run
        elif test "$input" = "dyn" -o "$input" = "DYN"
	    then
	    module=dynmod
	    input=run
        elif test "$input" = "out" -o "$input" = "OUT"
	    then
	    module=outmod
	    input=run
        elif test "$input" = "plo" -o "$input" = "PLO"
	    then
	    module=plomod
	    input=run
        elif test "$input" = "s2x" -o "$input" = "S2X"
	    then
	    module=s2xmod
	    input=run
        elif test "$input" = "exp" -o "$input" = "EXP"
	    then
	    module=express
	    input=run
        elif test "$input" = "tab" -o "$input" = "TAB"
	    then
	    module=table
	    input=run
        else
	    module=""
        fi

        if test "$input" = "run"
	    then
	    if test ! "$chsys"
		then
		chsys=dummy
	    fi

	    if test ! "$chini"
		then
		chini=dummy
	    fi

	    ${SIMO_RUNDIR}/etc/rsimo.sh $chsys $chini $module interactive

        elif test "$input" = "pinp" -o "$input" = "PINP"
	    then
	    $print_cmd simo.plt

        elif test "$input" = "pplo" -o "$input" = "PPLO"
	    then
	    $print_cmd pscr-meta.dat

        elif test "$input" = "ptab" -o "$input" = "PTAB"
	    then
	    $print_cmd -olandscape -ofp12 pro$sysfil$inifil.tab

        elif test "$input" = "def" -o "$input" = "DEF"
	    then
	    $echo_cmd "Enter system identifier > \c"
	    read chsys

	    $echo_cmd "Enter initial condition identifier > \c"
	    read chini

        elif test "$input" = "lis" -o "$input" = "LIS"
	    then
	    echo " "
	    echo "System identifier            : $chsys"
	    echo "Initial condition identifier : $chini"
        fi
   done

   echo
   echo '*********************************************************'
   echo '*   WELCOME BACK TO                                     *'
   echo '*                                                       *'
   echo '*    SSSSSSSSSS    III   MMMMM    MMMM     OOOOOOOO     *'
   echo '*   SSSSSSSSSSSS   III   MMMMM   MMMMM    OOOOOOOOOO    *'
   echo '*   SSS            III   MMMMMM MMMMMM   OOO      OOO   *'
   echo '*   SSS            III   MMM MMMMM MMM   OOO      OOO   *'
   echo '*   SSSSSSSSSS     III   MMM  MMM  MMM   OOO      OOO   *'
   echo '*   SSSSSSSSSSS    III   MMM   M   MMM   OOO      OOO   *'
   echo '*           SSS    III   MMM       MMM   OOO      OOO   *'
   echo '*           SSS    III   MMM       MMM   OOO      OOO   *'
   echo '*   SSSSSSSSSSS    III   MMM       MMM    OOOOOOOOOO    *'
   echo '*    SSSSSSSSS     III   MMM       MMM     OOOOOOOO     *'
   echo '*                                                       *'
   echo '*   SIMULATION OF COMPLEX MARINE OPERATIONS             *'
   echo '*********************************************************'
   echo

   exit



