Moved the main calculation loop into its own function, which is needed for implementing task parallelism. directives file changed appropriately to reflect this.