## Imported Packages and/or classes

#import hec
from hec.script import Plot, MessageBox, Constants
from hec.script import ClientAppWrapper, ResSim
from hec. hecmath import  DSS, TimeSeriesMath
from hec.io import TimeSeriesContainer
from hec.heclib.util import HecTime
from hec.heclib.dss import HecDss, DSSPathname, HecDSSUtilities

import java
import javax
from java.awt import  *
from java.awt.event import  *
from javax.swing import *

#----------------------------------------------------------------------------------
def getResSimTimewindow() :
	runTimeWindow = simulation.getRunTimeWindow()
	sTime = runTimeWindow.getStartTimeString()
	eTime = runTimeWindow.getEndTimeString()
	return sTime, eTime

#----------------------------------------------------------------------------------
def getResSimTimeStep(rssRun) :
	alt = rssRun.getRssAlt()
	timeStepString = alt.getTimeStepString()
	return timeStepString

#----------------------------------------------------------------------------------
def verifyState() :
	'''
	Verify that ResSim is in the correct module and has simulation open
	'''
	global simulation
	module = ClientAppWrapper.getCurrentModule()
	if module.getName() != "Simulation" : 
		raise AssertionError, "ResSim is %s module, Simulation module is required" % `module`
	simulation = module.getSimulation()
	if not simulation :
		raise AssertionError, "Must have a simulation open."

#----------------------------------------------------------------------------------
def getFPart() :
	module = ResSim.getCurrentModule()
	if `module` != "Simulation" :
		msg = "ResSim is not in Simulation Module, exiting."
		logOutput(msg)
		MessageBox.showError(msg, scriptName)
		return -1
	simulation = module.getSimulation()        
	rssRun = module.getActiveRun()
	Fpart = rssRun.getKey()
	if Fpart.find(":"[:]) != -1 :
		Fpart = Fpart[0:Fpart.find(":"[:])]
	return Fpart , rssRun

#----------------------------------------------------------------------------------
def getSimulationDSSFilename() :
	'''
	Return the fully-qualified name of the simulation DSS file
	'''
	verifyState()
	filename = simulation.getOutputDSSFilePath()
	sTime, eTime = getResSimTimewindow()
	Fpart, rssRun = getFPart()
	Epart = getResSimTimeStep(rssRun)
	return filename, sTime, eTime, Epart, Fpart, rssRun

#----------------------------------------------------------------------------------
def readPathnames(filename, Epart, Fpart, sTime, eTime) :
	DssFile = DSS.open(filename, sTime, eTime)

	# Read time series pathnames

	AdamStor = DssFile.read("//ADAM-POOL/STOR/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	#AdamTD = 307000.
	AdamFC = DssFile.read("//ADAM-FLOOD CONTROL/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	AdamCon = DssFile.read("//ADAM-CONSERVATION/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	AdamIna = DssFile.read("//ADAM-INACTIVE/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")


	AdamRGStor = DssFile.read("//ADAM RG-POOL/STOR/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	#AdamRGTD = 307000.
	AdamRGFC = DssFile.read("//ADAM RG-FLOOD CONTROL/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	AdamRGCon = DssFile.read("//ADAM RG-CONSERVATION/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	AdamRGIna = DssFile.read("//ADAM RG-INACTIVE/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")

	AndrewStor = DssFile.read("//ANDREW-POOL/STOR/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	#AndrewTD = 80400.
	AndrewFC = DssFile.read("//ANDREW-FLOOD CONTROL/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	AndrewCon = DssFile.read("//ANDREW-CONSERVATION/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")
	AndrewIna = DssFile.read("//ANDREW-INACTIVE/STOR-ZONE/25Nov1993 - 03Dec1993/" + Epart + "/" + Fpart + "/")


#	AdamStorList = [AdamIna, AdamCon, AdamFC, AdamTD, AdamStor]
#	AdamRGStorList = [AdamRGIna, AdamRGCon, AdamRGFC, AdamRGTD, AdamRGStor]
#	AndrewStorList = [AndrewIna, AndrewCon, AndrewFC, AndrewTD, AndrewStor]

	AdamStorList = [AdamIna, AdamCon, AdamFC, AdamStor]
	AdamRGStorList = [AdamRGIna, AdamRGCon, AdamRGFC, AdamRGStor]
	AndrewStorList = [AndrewIna, AndrewCon, AndrewFC, AndrewStor]

	return 	DssFile, AdamStorList, AdamRGStorList, AndrewStorList


#----------------------------------------------------------------------------------

def implicit(AdamStorList, AdamRGStorList, AndrewStorList, DssFile, sTime, eTime, Epart, Fpart) :

	if Fpart[:3] == "NoS" :
		print
		print "NoS"
		print
		resStorList = [AdamStorList, AdamRGStorList, AndrewStorList]
		# Compute system storages levels
		sysFC_Stor = resStorList[0][2].add(resStorList[1][2]).add(resStorList[2][2])
		sysFC_Stor.setLocation("SYSTEM FLOOD CONTROL")
		sysCon_Stor = resStorList[0][1].add(resStorList[1][1]).add(resStorList[2][1])
		sysCon_Stor.setLocation("SYSTEM CONSERVATION")
		sysIna_Stor = resStorList[0][0].add(resStorList[1][0]).add(resStorList[2][0])
		sysIna_Stor.setLocation("SYSTEM INACTIVE")
		sys_Stor = resStorList[0][3].add(resStorList[1][3]).add(resStorList[2][3])
		sys_Stor.setLocation("SYSTEM STORAGE")
	
	if Fpart[:3] == "Par" :
		print
		print "Par"
		print
		resStorList = [AdamRGStorList, AndrewStorList]
		# Compute system storages levels
		sysFC_Stor = resStorList[0][2].add(resStorList[1][2])
		sysFC_Stor.setLocation("SYSTEM FLOOD CONTROL")
		sysCon_Stor = resStorList[0][1].add(resStorList[1][1])
		sysCon_Stor.setLocation("SYSTEM CONSERVATION")
		sysIna_Stor = resStorList[0][0].add(resStorList[1][0])
		sysIna_Stor.setLocation("SYSTEM INACTIVE")
		sys_Stor = resStorList[0][3].add(resStorList[1][3])
		sys_Stor.setLocation("SYSTEM STORAGE")
	
	if Fpart[:3] == "Tan" :
		print
		print "Tan"
		print
		resStorList = [AdamStorList, AdamRGStorList]
		# Compute system storages levels
		sysFC_Stor = resStorList[0][2].add(resStorList[1][2])
		sysFC_Stor.setLocation("SYSTEM FLOOD CONTROL")
		sysCon_Stor = resStorList[0][1].add(resStorList[1][1])
		sysCon_Stor.setLocation("SYSTEM CONSERVATION")
		sysIna_Stor = resStorList[0][0].add(resStorList[1][0])
		sysIna_Stor.setLocation("SYSTEM INACTIVE")
		sys_Stor = resStorList[0][3].add(resStorList[1][3])
		sys_Stor.setLocation("SYSTEM STORAGE")

	if Fpart[:3] == "Exp" :
		print
		print "Exp"
		print
		resStorList = [AdamStorList, AdamRGStorList]
		# Compute system storages levels

		############### Sys Levels plus Inflections Points
		
		sysFC_Stor = resStorList[0][2].add(resStorList[1][2])
		sysFC_Stor.setLocation("SYSTEM FLOOD CONTROL")

		sysCon_Stor = resStorList[0][1].add(resStorList[1][1])
		sysCon_Stor.setLocation("SYSTEM CONSERVATION")

		sysIna_Stor = resStorList[0][0].add(resStorList[1][0])
		sysIna_Stor.setLocation("SYSTEM INACTIVE")

		sys_Stor = resStorList[0][3].add(resStorList[1][3])
		sys_Stor.setLocation("SYSTEM STORAGE")
	
	if Fpart[:3] == "All" :
		print
		print "All"
		print
		resStorList = [AdamStorList, AdamRGStorList, AndrewStorList]
		# Compute system storages levels
		#sysTD_Stor = resStorList[0][3].add(resStorList[1][3]).add(resStorList[2][3])
		sysFC_Stor = resStorList[0][2].add(resStorList[1][2]).add(resStorList[2][2])
		sysFC_Stor.setLocation("SYSTEM FLOOD CONTROL")
		sysCon_Stor = resStorList[0][1].add(resStorList[1][1]).add(resStorList[2][1])
		sysCon_Stor.setLocation("SYSTEM CONSERVATION")
		sysIna_Stor = resStorList[0][0].add(resStorList[1][0]).add(resStorList[2][0])
		sysIna_Stor.setLocation("SYSTEM INACTIVE")
		sys_Stor = resStorList[0][3].add(resStorList[1][3]).add(resStorList[2][3])
		sys_Stor.setLocation("SYSTEM STORAGE")


	# Write to dss computed time series
	#DssFile.write(sysTD_Stor)
	DssFile.write(sysFC_Stor)
	DssFile.write(sysCon_Stor)
	DssFile.write(sysIna_Stor)
	DssFile.write(sys_Stor)


	# _resStorList
	_resStorList = [AdamStorList, AdamRGStorList, AndrewStorList]


	# Compute common index level for the end-of-period storage level at each reservoir 
	# Adam storage levels
	AdamStor_dcv = _resStorList[0][3].getData().values
	AdamFC_dcv = _resStorList[0][2].getData().values
	AdamCon_dcv = _resStorList[0][1].getData().values
	AdamIna_dcv = _resStorList[0][0].getData().values

	# Adam RG storage levels
	AdamRGStor_dcv = _resStorList[1][3].getData().values
	AdamRGFC_dcv = _resStorList[1][2].getData().values
	AdamRGCon_dcv = _resStorList[1][1].getData().values
	AdamRGIna_dcv = _resStorList[1][0].getData().values

	# Andrew storage levels
	AndrewStor_dcv = _resStorList[2][3].getData().values
	AndrewFC_dcv = _resStorList[2][2].getData().values
	AndrewCon_dcv = _resStorList[2][1].getData().values
	AndrewIna_dcv = _resStorList[2][0].getData().values

	# system storage levels
	sys_Stor_dcv = sys_Stor.getData().values
	sysFC_dcv = sysFC_Stor.getData().values
	sysCon_dcv = sysCon_Stor.getData().values
	sysIna_dcv = sysIna_Stor.getData().values




	# Compute Zone Storages
	Adam_Con_Stor = _resStorList[0][1].subtract(_resStorList[0][0])
	Adam_FC_Stor = _resStorList[0][2].subtract(_resStorList[0][1])
	Adam_Con_Stor_dcv = Adam_Con_Stor.getData().values
	Adam_FC_Stor_dcv = Adam_FC_Stor.getData().values
	
	AdamRG_Con_Stor = _resStorList[1][1].subtract(_resStorList[1][0])
	AdamRG_FC_Stor = _resStorList[1][2].subtract(_resStorList[1][1])
	AdamRG_Con_Stor_dcv = AdamRG_Con_Stor.getData().values
	AdamRG_FC_Stor_dcv = AdamRG_FC_Stor.getData().values

	Andrew_Con_Stor = _resStorList[2][1].subtract(_resStorList[2][0])
	Andrew_FC_Stor = _resStorList[2][2].subtract(_resStorList[2][1])
	Andrew_Con_Stor_dcv = Andrew_Con_Stor.getData().values
	Andrew_FC_Stor_dcv = Andrew_FC_Stor.getData().values

	sys_Con_Stor = sysCon_Stor.subtract(sysIna_Stor)
	sys_FC_Stor = sysFC_Stor.subtract(sysCon_Stor)
	sys_Con_Stor_dcv = sys_Con_Stor.getData().values
	sys_FC_Stor_dcv = sys_FC_Stor.getData().values


	# Define Common Index Levels
#	CIL_3 = 3 # Common Index Level @ Top of Dam
	CIL_2 = 2 # Common Index Level @ Top of FC
	CIL_1 = 1 # Common Index Level @ Top of GC
	CIL_0 = 0 # Common Index Level @ Top of Ina

	Adam_CIL_values = []
	AdamRG_CIL_values = []
	Andrew_CIL_values = []
	sys_CIL_values = []

	for i in range(len(sys_Stor_dcv)) :

		if AdamStor_dcv[i] <= AdamCon_dcv[i] :
			# System Conservation Level (between level CIL_0 and CIL_1)
			Adam_CIL = (AdamStor_dcv[i] - AdamIna_dcv[i]) / Adam_Con_Stor_dcv[i] + CIL_0
		else:
			# System Flood Control Level (between level CIL_1 and CIL_2) 
			Adam_CIL = (AdamStor_dcv[i] - AdamCon_dcv[i]) / Adam_FC_Stor_dcv[i] + CIL_1

		if AdamRGStor_dcv[i] <= AdamRGCon_dcv[i] :
			# System Conservation Level (between level CIL_0 and CIL_1)
			AdamRG_CIL = (AdamRGStor_dcv[i] - AdamRGIna_dcv[i]) / AdamRG_Con_Stor_dcv[i] + CIL_0
		else:
			# System Flood Control Level (between level CIL_1 and CIL_2) 
			AdamRG_CIL = (AdamRGStor_dcv[i] - AdamRGCon_dcv[i]) / AdamRG_FC_Stor_dcv[i] + CIL_1

		if AndrewStor_dcv[i] <= AndrewCon_dcv[i] :
			# System Conservation Level (between level CIL_0 and CIL_1)
			Andrew_CIL = (AndrewStor_dcv[i] - AndrewIna_dcv[i]) / Andrew_Con_Stor_dcv[i] + CIL_0
		else:
			# System Flood Control Level (between level CIL_1 and CIL_2) 
			Andrew_CIL = (AndrewStor_dcv[i] - AndrewCon_dcv[i]) / Andrew_FC_Stor_dcv[i] + CIL_1

		if sys_Stor_dcv[i] <= sysCon_dcv[i] :
			# System Conservation Level (between level CIL_0 and CIL_1)
			sys_CIL = (sys_Stor_dcv[i] - sysIna_dcv[i]) / sys_Con_Stor_dcv[i] + CIL_0

		else:
			# System Flood Control Level (between level CIL_1 and CIL_2) 
			sys_CIL = (sys_Stor_dcv[i] - sysCon_dcv[i]) / sys_FC_Stor_dcv[i] + CIL_1

		
		Adam_CIL_values.append(Adam_CIL)
		AdamRG_CIL_values.append(AdamRG_CIL)
		Andrew_CIL_values.append(Andrew_CIL)
		sys_CIL_values.append(sys_CIL)
		

	tsc_watershed = ""
	if Fpart[:3] == "NoS" :
		tsc_location = ["SYS CIL", "ANDREW CIL", "ADAM CIL", "ADAM RG CIL"]
		CIL_Values = [sys_CIL_values, Andrew_CIL_values, Adam_CIL_values, AdamRG_CIL_values]
	if Fpart[:3] == "Par" :
		tsc_location = ["SYS CIL", "ANDREW CIL", "ADAM RG CIL"]
		CIL_Values = [sys_CIL_values, Andrew_CIL_values, AdamRG_CIL_values]
	if Fpart[:3] == "Tan" or Fpart[:3] == "Exp" :
		tsc_location = ["SYS CIL", "ADAM CIL", "ADAM RG CIL"]
		CIL_Values = [sys_CIL_values, Adam_CIL_values, AdamRG_CIL_values]
	if Fpart[:3] == "All" :
		tsc_location = ["SYS CIL", "ANDREW CIL", "ADAM CIL", "ADAM RG CIL"]
		CIL_Values = [sys_CIL_values, Andrew_CIL_values, Adam_CIL_values, AdamRG_CIL_values]
	tsc_parameter = "Common Index Level"
	tsc_version = Fpart
	tsc_type = "INST-VAL"
	tsc_units = "CIL"
	
	tsc_list = []
	for i in range(len(tsc_location)) :
		_tsc = writeToDss(DssFile, sTime, eTime, Epart, CIL_Values[i], tsc_watershed, tsc_location[i], tsc_parameter, tsc_version, tsc_type, tsc_units)
		tsc_list.append(_tsc)
	
	
	return CIL_0, CIL_1, CIL_2, tsc_list


#----------------------------------------------------------------------------------

def explicit() :

	return 


#----------------------------------------------------------------------------------

def writeToDss(DssFile, sTime, eTime, Epart, values_list, tsc_watershed, tsc_location, tsc_parameter, tsc_version, tsc_type, tsc_units) :

	startTimeStr = sTime
	endTimeStr = eTime

	ts_minutes_dict = {	"5MIN": 5,		"10MIN": 10,	"15MIN": 15,	"30MIN":30, 
						"1HOUR":60,		"2HOUR": 120 ,	"3HOUR": 180,	"4HOUR": 240,
						"6HOUR": 360,	"12HOUR": 720,	"1DAY": 1440					}

	ts_minutes = ts_minutes_dict["1HOUR"]
		
	t = hec.heclib.util.HecTime()
	t.set(startTimeStr)
	startTime = t.value()
	t.set(endTimeStr)
	endTime = t.value()
	
	times = []
	t = startTime
	while t <= endTime :
		times.append(t)
		t += ts_minutes
	

	values = values_list

	tsc = hec.io.TimeSeriesContainer()
	#tsc.fullName = pathname
	tsc.watershed = tsc_watershed
	tsc.location = tsc_location
	tsc.parameter = tsc_parameter
	tsc.version = tsc_version
	tsc.interval = ts_minutes

	tsc.fullName = "/%s/%s/%s//%s/%s/" % (tsc_watershed, tsc_location, tsc_parameter, "1HOUR", tsc_version)

	tsc.type = tsc_type
	tsc.units = tsc_units
	
	tsc.startTime = times[0]
	tsc.endTime = times[-1]
	tsc.numberValues = len(times)
	tsc.times = times
	tsc.values = values
	
	DssFile.write(tsc)

	return tsc


#----------------------------------------------------------------------------------
def plot_outputCurves(curve_list, F_PART) :

	plotTitle = "System Storage Common Index Level Plot" + "(" + F_PART[:-3] + ")"
	thePlot = Plot.newPlot()
	layout = Plot.newPlotLayout()

	CIL_View = layout.addViewport()
	for i in range(len(curve_list)) : 
		CIL_View.addCurve("Y1", curve_list[i])
	CIL_View.setAxisName("Y1" , "Common Index Level (CIL)")


	thePlot.configurePlotLayout(layout)

	thePlot.setPlotTitleVisible(Constants.TRUE)
	thePlot.setPlotTitleText("System Storage Common Index Level Plot")
	#thePlot.getPlotTitle().setFont("Arial Black")
	thePlot.getPlotTitle().setFontSize(18)

	thePlot.showPlot()

	thePlot.getViewport(0).getAxis("Y1").setScaleLimits(0., 2.)
	thePlot.getViewport(0).getAxis("Y1").setMajorTicInterval(1.0)		
	thePlot.getViewport(0).getAxis("Y1").setMinorTicInterval(1.0)		


	if len(curve_list) == 3 :

		curveProperties = {
								#	key						Curve					LineColor			LineStyle		LineWeight	FillColor		FillPattern		FillType		SymbolVisible		SymbolType		SymbolSize				SymbolLineColor		SymbolFillColor		SymbolInterval		SymbolSkipCount		FirstSymbolOffset
								#	----------------		----------------		----------------	------------	----------	--------------	--------------	--------------	-----------------	------------	---------------------	----------------	----------------	----------------	----------------	-----------------
									'Sys_CIL'				: [ curve_list[0],		'yellow'			, 'Solid'		, 10		, 'yellow'		, 'Solid'		, 'None'		, Constants.FALSE	, 'Square'		, 1						, 'yellow'			, 'yellow'			, 0					, 0					, 0				] ,
																																																																																					
									'ResA_CIL'				: [ curve_list[1],		'blue'				, 'Solid'		, 1			, 'blue'		, 'Solid'		, 'None'		, Constants.TRUE	, 'Open Circle'	, 4						, 'blue'			, 'blue'			, 0					, 0					, 0				] ,
									'ResB_CIL'				: [ curve_list[2],		'red'				, 'Solid'		, 1			, 'green'		, 'Solid'		, 'None'		, Constants.FALSE	, 'Square'		, 1						, 'red'				, 'red'				, 0					, 0					, 0				] ,
							}

	if len(curve_list) == 4 :

		curveProperties = {
								#	key						Curve					LineColor			LineStyle		LineWeight	FillColor		FillPattern		FillType		SymbolVisible		SymbolType		SymbolSize				SymbolLineColor		SymbolFillColor		SymbolInterval		SymbolSkipCount		FirstSymbolOffset
								#	----------------		----------------		----------------	------------	----------	--------------	--------------	--------------	-----------------	------------	---------------------	----------------	----------------	----------------	----------------	-----------------
									'Sys_CIL'				: [ curve_list[0],		'yellow'			, 'Solid'		, 10		, 'yellow'		, 'Solid'		, 'None'		, Constants.FALSE	, 'Square'		, 1						, 'yellow'			, 'yellow'			, 0					, 0					, 0				] ,
																																																																																					
									'ResA_CIL'				: [ curve_list[1],		'blue'				, 'Solid'		, 1			, 'blue'		, 'Solid'		, 'None'		, Constants.TRUE	, 'Open Circle'	, 4						, 'blue'			, 'blue'			, 0					, 0					, 0				] ,
									'ResB_CIL'				: [ curve_list[2],		'red'				, 'Solid'		, 1			, 'red'			, 'Solid'		, 'None'		, Constants.FALSE	, 'Square'		, 1						, 'red'				, 'red'				, 0					, 0					, 0				] ,
									'ResC_CIL'				: [ curve_list[3],		'darkgreen'			, 'Solid'		, 1			, 'darkgreen'	, 'Solid'		, 'None'		, Constants.TRUE	, 'Square'		, 3						, 'darkgreen'		, 'darkgreen'		, 0					, 0					, 0				] ,
							}


	propKeys = curveProperties.keys()
	propKeys.sort()
	for key in propKeys :

		curve = thePlot.getCurve(curveProperties[key][0])
		LineColor = curveProperties[key][1]
		LineStyle = curveProperties[key][2]
		LineWeight = curveProperties[key][3]
		FillColor = curveProperties[key][4]
		FillPattern = curveProperties[key][5]
		FillType = curveProperties[key][6]
		SymbolsVisible = curveProperties[key][7]
		SymbolType = curveProperties[key][8]
		SymbolSize = curveProperties[key][9]
		SymbolLineColor = curveProperties[key][10]
		SymbolFillColor = curveProperties[key][11]
		SymbolInterval = curveProperties[key][12]
		SymbolSkipCount = curveProperties[key][13]
		FirstSymbolOffset = curveProperties[key][14]

		curve.setLineColor(LineColor)
		curve.setLineStyle(LineStyle)
		curve.setLineWidth(LineWeight)
		curve.setFillColor(FillColor)
		curve.setFillPattern(FillPattern)
		curve.setFillType(FillType)
		curve.setSymbolsVisible(SymbolsVisible)
		curve.setSymbolType(SymbolType)
		curve.setSymbolSize(SymbolSize)
		curve.setSymbolLineColor(SymbolLineColor)
		curve.setSymbolFillColor(SymbolFillColor)
		curve.setSymbolInterval(SymbolInterval)
		curve.setSymbolSkipCount(SymbolSkipCount)
		curve.setFirstSymbolOffset(FirstSymbolOffset)


#----------------------------------------------------------------------------------

def main() :
	
	filename, sTime, eTime, Epart, Fpart, rssRun = getSimulationDSSFilename()
	DssFile, AdamStorList, AdamRGStorList, AndrewStorList = readPathnames(filename, Epart, Fpart, sTime, eTime)
		
	CIL_0, CIL_1, CIL_2, tsc_list = implicit(AdamStorList, AdamRGStorList, AndrewStorList, DssFile, sTime, eTime, Epart, Fpart)
	
	plot_outputCurves(tsc_list, Fpart)
	
	DssFile.done()
	print
	print "The script is done!"

#----------------------------------------------------------------------------------
	
main()