:

case $MSTESTDB in
   "") 
	: DATABASE should not be null. It is an error if
	: this statement is executed.
	MSTESTDB="database" ;;
esac	 

: 'special setup for oldloans test (getarg vs igetarg)'

SCRIPT_FF=script.ff

case $MSSYS_PLATFORM in
 SYS_OS_UNIX_HPUX_32) 

	# If HP decided to support 64bit f77, we should have the same
	# problem for SYS_OS_UNIX_HPUX_64.

	SED_MOD="s;^C USE_IGETARG;;" ;;

 SYS_OS_UNIX_HPUX_64) 
	cat <<EOM
	In HPUX 11,

	HP F77 does not support 64bit. HP F90 does.
	*** Currently, we are using F90 to run F77 test. ***

	HP F77 support igetarg but not getarg.
	HP F90 support getarg but not igetarg. However, there is
	a bug in its getarg. According to its getarg man page,

	'A call to getarg will return the kth command line argument in
	character string arg. The 0th argument is the command name.'

	However, that does not work. The 0th argument is empty and
	the 1st argument is the command name. The whole argument
	list is shifted.
EOM
	SED_MOD="s;^C SYS_OS_UNIX_HPUX_64;;" ;;
 *)
	SED_MOD="s;^C USE_GETARG;;" ;;
esac

: 'mechanism to solve f77 number of character per line limit. '

MAXZSTR=50
LEN=`expr $MSTESTDB : '.*'`
NSTR=`expr $LEN / $MAXZSTR`
NSTR=`expr $NSTR + 1`
TMP=./temp$$

I=0
while expr $I != $NSTR > /dev/null
do
	START=`expr $I \* $MAXZSTR`
	START=`expr $START + 1`

:	
: ' 	The following statements can replace the awk statement  '
: ' 	if necessary. '
:
: ' 	END=`expr $I + 1` '
: ' 	END=`expr $END \* $MAXZSTR` '
: ' 	STRING=`expr substr $MSTESTDB $START $END` '
:

	if test $START -gt $LEN
	then
		break
	fi

	STRING=`echo "" | awk "{print substr(\"$MSTESTDB\", $START, $MAXZSTR)}"`

	STRING="\'$STRING\'  DATABASE"

	case $I in
	   0) sed -e "
s;INCLUDE;$EMPRESSPATH/include;
/DATABASE/s;'DATABASE';$STRING;
$SED_MOD
" < $SCRIPT_FF > script.f
		;;

	   *) sed -e "
/DATABASE/{
s;DATABASE;//;
a\\
\     &  $STRING
}
$SED_MOD
" < script.f > $TMP
		mv $TMP script.f
		;;
	esac
	I=`expr $I + 1`
done

if test -f sizelong.c
then
	case $MSSYS_PLATFORM in
	 SYS_OS_UNIX_IRIX_64)	
		# irix64 compiler prints warning when compiling a.c.
		SIZE_OF_C_LONG=8
		;;
	 *)
		$EMPRESSPATH/common/sys_bin/cc -o sizelong sizelong.c
		SIZE_OF_C_LONG=`./sizelong`
		;;
	esac

	sed -e "
s;SIZE_OF_C_LONG;$SIZE_OF_C_LONG;
/DATABASE/s;DATABASE;;
" < script.f > $TMP

else

	sed -e "
/DATABASE/s;DATABASE;;
" < script.f > $TMP

fi

mv $TMP script.f

echo "Compiling the F77 program"
empf77 -w script.f -o script
echo "Running the compiled program"
if test -r params
then
	PARAM="`cat params`"
else
	PARAM=
fi
if test -r input
then
	INPUT=input
else
	INPUT=/dev/null
fi
( eval ./script $PARAM ) < $INPUT > testout 2> errout
cat errout >> testout
rm -f script script.o errout

$MSTSRCMINOR/_strip testout
