GRID_MESH/IRREGULAR_POLYGON_LGCP/IRREGPOLLGCP_OUTPUT/IRREGPOLLGCP_OUTPUT_ERROR DIRECTORY.

THIS DIRECTORY CONTAINS THE OUTPUTS FROM THE IRREGULAR POLYGON LGCP SBC IMPLEMENTATION THAT RESULTED IN ERRORS IN SEVERAL WAYS, WITH CODE USED HERE TO EITHER REMOVE INCORRECTLY PLACED ERRORS (DESCRIBED BELOW) OR PLACE TIME ERRORS IN THE REQUIRED PROCESSES. THE .rda OUTPUTS IN THIS SECTION ARE LABELLED WITH A SUFFIXED *_*ERROR.rda IF THEY ARE NOT THE FINAL OUTPUTS POST ERROR ADDITION/REMOVAL AND SOME HAD ERRORS PLACED MULTIPLE TIMES, AND SO THERE ARE SOME OUTPUT FILES THAT ARE AFTER THE ADDITION OF AN ERROR BUT LATER NEEDED ANOTHER ERROR INCLUDED. THE FINAL PRE-BALENA RUNS HAVE NO SUFFIX. THE R CODE ALLOWS US TO REMOVE/ADD ERRORS AS NEEDED IN ORDER FOR THE SIMULATIONS TO CONTINUE RUNNING AS NEEDED ON BALENA.

INITIALLY, DUE TO TEMPORARY DIRECTORY ISSUES, THERE WERE JOBS THAT FAILED WITH A MESSAGE ABOUT THERE NOT BEING ENOUGH MEMORY LEFT, OFTEN THIS PRODUCED ERRORS IN BOTH OF THE RUNS FOR THAT NODE, WHILE RARELY IT PRODUCED AN ERROR IN JUST ONE RUN. IF THERE WAS AN ERROR IN BOTH RUNS, THEN IN ORDER TO DEDUCE WHICH HAD CAUSED THIS ODD ERROR, THE ERRORS (LABELLED SPACEERROR(2)) WERE REMOVED (RE-SET) WITH IrregSBCErrReSetProcs.R AND RE-RUN. IF THE SPACE ERROR RE-OCCURRED (WHICH WAS NOT ALWAYS THE CASE) THEN COMPARING THE SIMULATION-GRID-MESH COMBINATIONS INDICATED WHICH RUN WAS `TO BLAME' FOR THE ERROR AS IT WOULD HAVE BEEN THE SAME AS THE PREVIOUS ERROR. THEREFORE, THE ERRORS IN THE OTHER RUNS WERE REMOVED WITH IrregSBCErrRemovalProcs.R WHILE THE ERRORS IN THE OTHERS WERE RETAINED. AFTER THE ISSUE WITH THE TEMPORARY DIRECTORY WAS SOLVED, THESE ERROR-RUNS WERE AGAIN RE-RUN (FROM *_SPACEERRORFINAL.rda) AND THE ERRORS REMOVED WHEN COMPLETED.

FOR EACH OF THE FUNCTION WE DISCUSS THE APPLICATION AS WELL AS THEIR INPUTS AND OUTPUTS, HOWEVER THE DETAILS FOR THE DATA INPUTS/OUTPUTS, IN PARTICULAR THE .rda DATA WILL BE DISCUSSED IN MORE DETAIL BELOW.

- IrregSBCErrReSetProcs_final.R: this code is to re-set the errors to NA in order to re-run and see which run caused the initial error. In some cases, both runs passed the original error position for simulation-grid-mesh and so were left to continue running. We would expect that this should not be required if the simulation study has no issue with the temporary directory.
	-- Input:
		--- GridMeshIrregPolLGCPSBCSSk_SPACEERROR.rda and GridMeshIrregPolLGCPSBCSSk_SPACEERROR2.rda, where k denotes the process.
	-- Output:
		--- GridMeshIrregPolLGCPSBCSSk.rda and backed up as GridMeshIrregPolLGCPSBCSSk_PostErrResetj.rda, where k denotes the process
		--- Text Files: 			
			---- "ReSettingErrorForNodethis.nodeProck.txt" and "ReSettingErrorForNodethis.nodeProck_1006.txt", where "this.node" and "k" vary depending on the node index for the run and the index for the process
			---- "DoubleCheckingAllRe-Sets.txt", "DoubleCheckingProc8Re-Sets.txt" and "DoubleCheckingProc11Re-Sets.txt"
			---- "CheckingStartingPositionsOldandNew070621.txt", "CheckingStartingPositionsOldandNewProc8070621.txt" and "CheckingStartingPositionsOldandNewProc11100621.txt"

- IrregSBCErrRemovalProcs_final.R: this code is to remove the errors (replace with NAs) for the runs that surpassed the previous simulation-grid-mesh settings when the original space errors occurred and therefore were not the cause of the errors. By removing these errors they can continue without errors that only occurred as the job failed due to the other run.
	-- Input:
		--- GridMeshIrregPolLGCPSBCSSk_REMERROR.rda and backed up as GridMeshIrregPolLGCPSBCSSk_PostRemErr.rda, where k denotes the process
	-- Output:
		--- GridMeshIrregPolLGCPSBCSSk.rda, where k denotes the process
		--- Text Files:
			---- "RemovingErrorForNodethis.nodeProck.txt", where "this.node" and "k" vary depending on the node index for the run and the index for the process
			---- "DoubleCheckingProcErrorRem.txt"
			---- "CheckingStartingPositionsOldandNewProc090621.txt"

- IrregSBCTimeErrInsertProcs_final.R: this code adds time errors to the next grid and mesh (so just after the previous completed run) which can then be placed back onto Balena to continue running and skip the grid-mesh combination with the error. (Additionally, a error in naming the time error in process 5 and 14 - was labelled time error 4, but should have been time error 5 and so we have code that allowed us to fix this typo.)
	-- Input: 
		--- GridMeshIrregPolLGCPSBCSSk_TIMEERRORj.rda and backed up as GridMeshIrregPolLGCPSBCSSk_PostTEj.rda, for j = 1,...8 denoting the time error and where k denotes the process additionally for j=3 or 2Skip we have GridMeshIrregPolLGCPSBCSSk_PostTimeErrorj.rda instead, GridMeshIrregPolLGCPSBCSSk_TIMEERROR5Typo.rda (typo for k = 5 and 14)
	-- Output:
		--- GridMeshIrregPolLGCPSBCSSk.rda, where k denotes the process
		--- Text Files:
			---- "AddingTimingErrorForProck.rda" or "AddingTimingErrorForProckErrori.txt", for i = 2,...,8 or "2Skip" and where k denotes the process,
			---- "DoubleCheckingTimingErrorAdd.txt" or "DoubleCheckingTimingErrorAddErrori.txt", for i = 2,...,8, 
			---- "CheckingStartingPositionsOldandNewProc150621.txt" or "CheckingStartingPositionsOldandNewProc160621Errori.txt", for i = 2,...,8, 				
			---- "CorrectingTimeError5TypeForProck.txt" (for k = 5 and 14 only), DoubleCheckingTimeError5TypeFix.txt".

- GridMeshIrregPolLGCPSBCSSi_SPACEERRORj.rda: these outputs (where j is empty or 2) were the results of the memory error and the errors were re-set with IrregSBCErrReSetProcs.R which outputs GridMeshIrregPolLGCPSBCSSi.rda which are returned to Balena to continue running.

- GridMeshIrregPolLGCPSBCSSi_PostErrResetj.rda: these are the outputs created from IrregSBCErrReSetProcs.R, and also saved under this name in the case of the error re-occurring and so preventing the new GridMeshIrregPolLGCPSBCSSi.rda being copied over and overiding the original output of the reset.

- GridMeshIrregPolLGCPSBCSSi_REMERROR.rda: these outputs were the re-labelled GridMeshIrregPolLGCPSBCSSi.rda outputs from Balena in order for IrregSBCErrRemovalProcs.R to remove the errors that were caused by the memory issue but not related to these runs in particular so they can be re-set and continue to run as normal. These output files are taken in an GridMeshIrregPolLGCPSBCSSi.rda are output and returned to Balena to continue running the simulations.

- GridMeshIrregPolLGCPSBCSSi_PostRemErr.rda: these are the outputs created from IrregSBCErrRemovalProcs.R, and also saved under this name in the case of the another error re-occurring and so preventing the new GridMeshIrregPolLGCPSBCSSi.rda being copied over and overiding the original output of the error removal.

- GridMeshIrregPolLGCPSBCSSi_TIMEERRORj.rda: these were the outputs where the runs took over 6 hours (or an unrealistically long time) without any result and therefore has `TIME ERROR j' placed in the required simulation-grid-mesh error slot, with the first Time Error just denoted `TIME ERROR'. For j=2, some errors were called *_TIMEERROR2SKIP.rda due to the grid-mesh combination post the TIME ERROR 2 addition being a much larger mesh resolution which could also have resulted in another time error and therefore, these errors were pre-emptively included so as not to risk waiting another 6 hours where the results could likely not be completed. The incrementing j for the time errors were mostly due to tracking time errors through the same runs often and so needing to distinguish between the errors, especially for re-running. These outputs are taken in by IrregSBCTimeErrInsertProcs.R where GridMeshIrregPolLGCPSBCSSi.rda is output. (There is additional outputs for processes 5 and 14 where TIME ERROR 5 was incorrectly labelled as TIME ERROR 4, and this was also corrected in IrregSBCTimeErrInsertProcs.R).

- GridMeshIrregPolLGCPSBCSSi_PostTEj.rda or GridMeshIrregPolLGCPSBCSSi_PostTimeErrorj.rda: if the same process resulted in another time error, then the previous output from IrregSBCTimeErrInsertProcs.R are re-named with this additional suffix, in order to retain the output from the addition of TIME ERROR j in case it may be needed in the future, and not be over-written by the output of IrregSBCTimeErrInsertProcs.R for the next time error.

- TimeErrorsTimeChecks_final.R: if the results from the Time Error re-runs finished in over 12 hours, which I may not have initially been able to catch and pause manually, then the outputs were removed, to ensure consistency across all processes, where the 12 hour time limit was set for the additional re-runs. This also takes in the relevant *_FULL.rda outputs for these processes and removes the relevant outputs that took over 12 hours to complete.
	-- Input: 
		--- GridMeshIrregPolLGCPSBCSSi.rda, for i = 1,...40 just for checks, and necessary process are manually relabelled as GridMeshIrregPolLGCPSBCSSk_FULL.rda, for k= 10, 18 and 33, in order to continue running the R script to remove the necessary outputs
	-- Output:
		--- longrunstimeerror.rda (contains the runs with a run time of greater than 12 hours)
		--- GridMeshIrregPolLGCPSBCSSk.rda, for k= 10, 18 and 33.
		--- Text Files:
			---- "ResettingTimingErrork.txt", for k= 10, 18 and 33
			---- "DoubleCheckingTimingErrorResetOverRun.txt".

- GridMeshIrregPolLGCPSBCSSi_FULL.rda: the outputs from the time error re-runs, although maybe the re-run took over 12 hours (the time limit) and while others were manually stopped these runs had been missed, and so for consistency we find such runs and re-set those particular outputs to be missing as though they were not retrieved initially. These data sets are the outputs containing these runs, before the output was removed and can also be found in the GRID_MESH/IRREGULAR_POLYGON_LGCP/IRREGPOLLGCP_OUTPUT directory as well.

- longrunstimeerror.rda: this contains a data frame with the processes that, when re-run with 16 processors on a node, took over 12 hours to re-run. This is important as we placed a time limit on these re-runs of 12 hours and while some runs were caught exceeding this time limit and manually stopped, we were not able to catch all of these runs and so some results were produced after this 12hr time limit. Therefore, for consistency we have to remove the results for the runs that completed in over 12 hours. This data frame was used to re-label the necessary processes with the suffix *_FULL.rda in order to remove the required outputs.

- GridMeshIrregPolLGCPSBCSSi.rda: these are the data sets from the most recent error reset/removal/time-insertion etc. If there were no further errors or to remove or insert or to reset results to NA is the time re-runs took too long then we did not include a suffix as these were not over-written with the erroneous output from further Balena runs. These outputs were placed back into Balena for continued running or (for processes 10, 18 and 33 which had extremely long re-runs) were placed in the IRREGPOLLGCP_OUTPUT directory for merging with the remaining results into one SBC dataset.

- GridMeshIrregPolLGCPSBCSSi_PostTimeErrorRuns.rda/GridMeshIrregPolLGCPSBCSSi_TIMEERRORFINAL.rda: for i = 2 or 7, these were some initial checks for the re-runs to compare for the pre- and post- rerun outputs, especially since, initially for process 7 the time error re-run failed due to a memory issue, and so this output saved with the original time error still in place, this was initiall checked using ComparingNewandOldProcs_final.R. However, the time error for Process 7 was re-run successfully at a later date and so the final output that is merged with the remaining outputs, has the time error re-run and an error message moved into the warnings. The new text output from ComparingNewandOldProcs_final.R overwrote the text output for these initial checks.

- ComparingNewandOldProcs_final.R: this takes the outputs from the final space error and time error pre-re-run outputs and compares them to the outputs post-re-runs to ensure there's is nothing drastically wrong with the results. The .txt file from this was labelled "DoubleCheckingTimingErrorReRun.txt".

- *.txt: these are the various outputs from the reset/removal/insertion of errors to check that the R scripts for any of these did not return odd outputs and so they can be replaced on Balena for further runs.
