#!/bin/ksh
#------------------------------------------------------------------------------#
# Current revisions:
# -----------------
#
# Former revisions:
# -----------------
# $Id: nc2vdf 1046 2012-11-09 14:38:45Z maronga $
#
# Description:
# ------------
# Starting script for nc2vdf
#------------------------------------------------------------------------------#

    check_muk=false
    check_hlrn=false
    sys="unknown"


    echo "*** checking hostname..."
    if [ $(expr "$HOSTNAME" : ".*muk.uni-hannover.de") -gt 0 ]
    then
       check_muk=true
    fi

    if [ $(expr "$HOSTNAME" : ".*hicegate2") -gt 0 ]
    then
       check_hlrn=true
    fi
    if [ $(expr "$HOSTNAME" : ".*bicegate2") -gt 0 ]
    then
       check_hlrn=true
    fi
    if [ $(expr "$HOSTNAME" : ".*huv") -gt 0 ]
    then
       check_hlrn=true
    fi
    if [ $(expr "$HOSTNAME" : ".*buv") -gt 0 ]
    then
       check_hlrn=true
    fi


    if [ $check_muk == "true" ]
    then
       sys="IMUK"
       . /muksoft/packages/vapor/2.1.0/bin/vapor-setup.sh
    fi

    if [ $check_hlrn == "true" ]
    then
       sys="HLRN"
       . /usr/share/modules/init/ksh
       module load vapor
       module load ncl
    fi

    if [ $sys == "unknown" ]
    then
       echo "+++ unknown system. Exiting..."
       exit 0
    else
       echo "*** nc2vdf will execute at $sys"
    fi

    if which nc2vdf.ncl >/dev/null; then
       ncl $PALM_BIN/nc2vdf.ncl "inputfile= \"$1\""
    else
       echo "  +++ nc2vdf.ncl not found."
    fi