#!/bin/sh

# Checks validity of the base ModelPath for the model Project data/executable, 
# and creates & exports that path if needed.
# This can be used as either as a stand-alone or as a call from other scripts such as "Run".

# Calls the following ELM scripts:
# PathELM_HOME

# As with all ELM scripts, stay with Bourne shell (/bin/sh) for universal application.


# *******************
# take care of environment variables and paths
# *******************

####
#### ELM_HOME Path
# determines if the (fundamental) ELM_HOME environment variable appears valid
PathELM_HOME


####
#### Model Path
# In the simple (distribution) version, the "ModelPath" is determined from ELM_HOME
# For testing different code sets with one single data (base ModelPath) location, we can
# set the ModelPath as a system environment variable.
if [ ! "$ModelPath" ];
then
  ModelPath=$ELM_HOME/SME/Projects/
  export ModelPath
  echo "Setting ModelPath= $ModelPath in absense of environment variable."
fi

if test -d $ModelPath
  then
	echo "ModelPath= $ModelPath"
  else
	echo "ModelPath= $ModelPath"
    echo "###### Error: Your base ModelPath directory does not exist."
    echo "Check the ELM documentation for directions on simple project setup."
    exit
fi
