#!/bin/bash
INPUT_FILE_HEADER="JobE"
PRIMARY_INPUT="$INPUT_FILE_HEADER"_Pre


NUM_ITERATIONS_FOR_GEMINI="100000"
NUM_ITERATIONS_FOR_TURBOENCABULATOR="400000000"
NUM_ITERATIONS_FOR_NBOS="100000000"
NUM_ITERATIONS_FOR_ODM="100000000"

MAX_SIM_TIME_FOR_TURBOENCABULATOR="100000"

CHEMICAL_TO_OUTPUT="8322"

clear

echo "--------------------------------------------------------------------------------"
echo "-------------------------------- MAKE PROCESS ----------------------------------"
echo "--------------------------------------------------------------------------------"
cd PreSource
#make clean
#make all
cd ..

######## MERCURY ########
PRIMARY_INPUT_DATA_FILENAME="$PRIMARY_INPUT".xml
INTERM_FILE_REACTIONS="Data/$INPUT_FILE_HEADER/$PRIMARY_INPUT"_Reactions_Interm_File.dat
INTERM_FILE_SPECIES="Data/$INPUT_FILE_HEADER/$PRIMARY_INPUT"_Species_Interm_File.dat
echo "IntermFileReactions = $INTERM_FILE_REACTIONS"
#cat $INTERM_FILE_REACTIONS
echo "IntermFileSpecies = $INTERM_FILE_SPECIES"
#cat $INTERM_FILE_SPECIES
echo
echo
echo "--------------------------------------------------------------------------------"
echo "------------------------------- MERCURY LAUNCH! --------------------------------"
echo "--------------------------------------------------------------------------------"
#./PreSource/MERCURY $PRIMARY_INPUT_DATA_FILENAME $INTERM_FILE_REACTIONS $INTERM_FILE_SPECIES

######## GEMINI #########
SUM_PROP_DATA_FROM_GEMINI="$PRIMARY_INPUT"_SumProp_GEMINI.dat
SORTED_OUTPUT_FROM_GEMINI="$PRIMARY_INPUT"_Sorted_GEMINI.dat
END_CHEM_CONC_FROM_GEMINI="$PRIMARY_INPUT"_ChemConc_After_"$NUM_ITERATIONS_FOR_GEMINI"_Iterations_GEMINI.dat
SECONDARY_INTERM_FILE_SPECIES="$INPUT_FILE_HEADER"_Pre_Species_Interm_File_FROM_TE.dat
echo
echo
echo "--------------------------------------------------------------------------------"
echo "------------------------------- GEMINI LAUNCH! ---------------------------------"
echo "--------------------------------------------------------------------------------"
./PreSource/GEMINI $INTERM_FILE_REACTIONS $INTERM_FILE_SPECIES $NUM_ITERATIONS_FOR_GEMINI $SORTED_OUTPUT_FROM_GEMINI $SUM_PROP_DATA_FROM_GEMINI $END_CHEM_CONC_FROM_GEMINI

#### RETRO-ENCABULATOR ####
TE_DEPENDENCY_GRAPH_FILE_NAME="$PRIMARY_INPUT"_FOR_TURBOENCABULATOR_SDG.dat
SUM_PROP_DATA_FROM_TE="$PRIMARY_INPUT"_SumProp_TE.dat
SORTED_OUTPUT_FROM_TE="$PRIMARY_INPUT"_Sorted_TE.dat
END_CHEM_CONC_FROM_TE="$PRIMARY_INPUT"_ChemConc_After_"$NUM_ITERATIONS_FOR_GEMINI"_Iterations_TE.dat
INTERM_FILE_SPECIES_FROM_TE="$PRIMARY_INPUT"_Species_Interm_File_FROM_TE.dat
CHEMICAL_OUTPUT_FILE_NAME_FROM_TE="$PRIMARY_INPUT"_Chemical_Output_FROM_TE.dat
cd ODM
#make clean
#make all
cd ..
echo
echo
echo "--------------------------------------------------------------------------------"
echo "------------------------------ RETRO-ENCABULATOR -------------------------------"
echo "--------------------------------------------------------------------------------"
echo
echo "*** Parsing... ***"
./ODM/TOYOTA $SORTED_OUTPUT_FROM_GEMINI $INTERM_FILE_SPECIES $TE_DEPENDENCY_GRAPH_FILE_NAME
echo "OUTPUT FILE IS"
echo "$TE_DEPENDENCY_GRAPH_FILE_NAME"
echo "*** DONE Parsing ***"
./ODM/RETROENCABULATOR $NUM_ITERATIONS_FOR_TURBOENCABULATOR $CHEMICAL_TO_OUTPUT $SORTED_OUTPUT_FROM_GEMINI $INTERM_FILE_SPECIES $TE_DEPENDENCY_GRAPH_FILE_NAME $SORTED_OUTPUT_FROM_TE $SUM_PROP_DATA_FROM_TE $INTERM_FILE_SPECIES_FROM_TE $CHEMICAL_OUTPUT_FILE_NAME_FROM_TE $MAX_SIM_TIME_FOR_TURBOENCABULATOR

exit
