#!/usr/bin/env python
import re,subprocess
import os

blk_factor = []

param_file = open("param.lst", "r")
param_list = param_file.read()
param_file.close()

# read data from param.lst and store it in blk_factor #
Blocking_factor = re.findall(r"Blk_factor.*$", param_list,re.MULTILINE)
for x in Blocking_factor:
        blocking = re.split(r"=", x)
        blk_factor = re.split(r"\s", blocking[1])
        print blk_factor

for blocking in blk_factor:
	os.chdir("data/" + blocking)
	print os.path.abspath(".")
	plot = subprocess.Popen(['gnuplot'], stdin=subprocess.PIPE)
	proc.stdin.write('set xrange [0:10]; set yrange [-2:2]\n')
	proc.stdin.write('plot sin(x)\n')
	proc.stdin.write('quit\n')
#	plot= open("vector_perf.out")
#	plot = subprocess.Popen(['gnuplot'], stdin=subprocess.PIPE)
#	plot.communicate("plot '%s'u 1:3 with lines;" % (plot))


	os.chdir("../..")

#import subprocess
#plot = subprocess.Popen(['gnuplot'], stdin=subprocess.PIPE)
#plot.communicate("plot '%s' with lines, '%s' with lines;" % (eout,nout))

