#!/bin/sh

# Checks validity of ELM_ARCHIVE_PATH for model archiving and exports it if needed.
# This can be used as either as a stand-alone or as a call from other scripts such as "ArchiveRun".

# 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


####
#### Archive Path
# at SFWMD, the ELM output is **always** archived to one area on a network file system
# this can be set to an environment variable if desired (used in ArchiveRun script)
if [ ! "$ELM_ARCHIVE_PATH" ];
then
  echo "Setting ELM_ARCHIVE_PATH in absense of environment variable."
  ELM_ARCHIVE_PATH=/e_evg/eb_elmmod/arc_out/
  export ELM_ARCHIVE_PATH
fi

if test -d "$ELM_ARCHIVE_PATH"
  then
	echo "ELM_ARCHIVE_PATH= $ELM_ARCHIVE_PATH"
  else
    echo "###### Error:  $ELM_ARCHIVE_PATH "
    echo "does not exist on your network."
    echo "In order to archive model output, determine a valid directory,"
    echo "then EITHER setenv ELM_ARCHIVE_PATH as an environment variable"
    echo "OR define it in the PathArchive script."
    exit
fi

