#include "Intel_Compatibility.h"
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

void FirstPass(string outputFileName, string inputFileName)
{
	// On the first pass read in the reactions, and then
	// sort them based on sum-propensities.
	ofstream gnuplotScript(outputFileName.c_str());

	gnuplotScript << "# GNUPLOT SCRIPT FOR CHOOSING REACTION CUTOFF THRESHOLD" << std::endl;
	gnuplotScript << "plot \"" + inputFileName + "\" using 1:2 with linespoints" << std::endl;
	gnuplotScript << "pause -1" << std::endl;
	return;
}

void SecondPass(string outputFileName)
{
	cout << std::endl << "How many reactions should be reserved for super-caching?" << std::endl;
	cout << "NumToReserve: ";
	int numToReserve = -1;
	cin >> numToReserve;
	cout << std::endl;

	ofstream outputFile(outputFileName.c_str());

	outputFile << numToReserve << std::endl;

	return;
}

/* PARAMETERS ARE:
	1) FIRSTPASS ***or*** SECONDPASS
	2) Output File Name
	3) Input File Name
*/

int main(int argc, char* argv[])
{
	string firstArg(argv[1]);
	
	if(firstArg.compare("FIRSTPASS") == 0)
		FirstPass(string(argv[2]), string(argv[3]));
	else
		SecondPass(string(argv[2]));
		
	return 0;
}
