#!/bin/csh -f
# runs the GDMO program without the ASN-CMPL compiler 
# to produce C++ source for OSIMIS.

if (!($?OSIMISETCPATH)) then
    echo Set environment variable OSIMISETCPATH before use
    exit 1
endif

# check command line arguments
if ($#argv == 0 || $#argv == 2 || $#argv == 4 || $#argv >= 6 || \
    ($#argv == 3 && !("$2" == "-s" || "$2" == "-m")) || \
    ($#argv == 5 && !("$2" == "-s" && "$4" == "-m") \
		 && !("$2" == "-m" && "$4" == "-s"))) then
    echo "usage: gdmo-cmpl <GDMO-file> [-s <GDMO.syntax.dat-file>] [-m <GDMO.mo.dat-file>]"
    exit 1
endif

# set the values of GDMODIR and gdmo
setenv GDMODIR $OSIMISETCPATH/gdmodir
set gdmo = "$OSIMISETCPATH/../compilers/mocompiler/gdmo/gdmo"

echo ""
echo "generating C++ for OSIMIS from GDMO ..."
if (! { $gdmo $1 $2 $3 $4 $5 }) then
    echo ""
    echo "error trying to generate GDMO"
    exit 1
endif
echo ""
echo "generation of code completed."
echo ""

exit 0
