#!/bin/sh
# so_simulator called by IFe_so_simulator

building=$1
	
# Test to determine if esp directory path has been
# set up in .cshrc file.

if [ "X$comf_dir" = "X" ]; then
  echo "Please place 'setenv comf_dir /tmp/def_prb' in .cshrc file."
  exit
fi

# Summer overheating script: version 1.1 of November 1994
# if no $comf_dir/tmp directory create...
if test ! -d $comf_dir/tmp ; then
  mkdir $comf_dir/tmp
fi

echo " Start of summer overheating script."
echo
echo "***** SUMMER_OVERHEATING SCRIPT COMMENCES" >$comf_dir/tmp/comfort_trace

# Set up defaults and process command line options.
# Resultant temperature or "air"for air temperature.
comfort_index="res"
oh_tmp=24

comfort_lock=$comf_dir/tmp/comfort_lock
comfort_results=$comf_dir/tmp/comfort_results
climate="/usr/esru/esp-r/climate/clm67"
start="17 7"
finish="17 7"
timesteps=1
information=0
echo
echo "           Problem: $building"
echo "           Climate: $climate"
echo "           Analysis period from ${start} to ${finish}"
echo "           Comfort index is ${comfort_index} at ${oh_tmp}"
echo


echo " Simulation commencing, please wait ....."
echo

rm -f ${comfort_results} 			# Might be user-defined file.
rm -f ${comfort_lock}

						# Simulate using parameters,
						# saving output for analysis.

echo "***** comfort: run bps" >>$comf_dir/tmp/comfort_trace

bps -mode script -file $building >>$comf_dir/tmp/comfort_trace    <<~
n
3
${climate}
2
a
${comfort_results}
${start}
${finish}
${timesteps}
*
s
n
y
y
-
f
y
~

echo
echo
echo
echo " Simulation complete; analysis commencing, output"
echo "                      directed to separate windows."


# move the token
echo "token_move	t5"

if [ $comfort_index = res ]; then
  comfort_index="d"
  graphpic="f"
fi
						# Export required data.
export comfort_results comfort_lock oh_tmp comfort_index graphpic

echo " ATTENTION......."
echo " Type return to continue to the next part of the summer_overheating analysis."
read xb						# hang around.
exit 0
