Nemo: computational challenges in ocean simulation

The ocean plays a very important role in modulating the temperature of the Earth through absorbing, storing and transporting the energy that arrives from the sun. Better understanding the dynamics of the ocean can help us to better predict the weather and to better comprehend the climate, two topics of special relevance for society. Ocean models had become an extremely useful tools, as they became a framework upon with it was possible to build knowledge. Using computers it became possible to numerically solve the fluid equations of the ocean and by improving how ocean models exploit the computational resources, we can reduce the cost of simulation whilst enabling new developments that will increase its skill. By facing the computational challenges of ocean simulation we can contribute to topics that have a direct impact on society whilst helping to reduce the cost of our experiments. Being the major European ocean model and one of the main state-of-the-art ocean models worldwide, this thesis has focused on the Nucleus NEMO. To find a way to improve the computational performance of ocean models, one of the initial goals was to better understand their computational behaviour. To do so, an analysis methodology was proposed, paying special attention to inter-process communication. Used with NEMO, the methodology helped to highlight several implementation inefficiencies, whose optimization led to a 46-49\% gain in the maximum model throughput, increasing the scalability of the model. This result illustrated that this kind of analysis can significantly help model developers to adapt their code highlighting where the problems really are. Another of the issues detected was that the impact of the domain decomposition was alarmingly underestimated, since in certain circumstances the model's algorithm was selecting a sub-optimal decomposition. Taking into account the factors that make a specific decomposition impact the performance, a method to select an optimal decomposition was proposed. The results showed that that by a wise selection of the domain decomposition it was possible not only to save resources but also to increase the maximum model throughput by a 41\% in some cases. After the successes achieved during the first part of the thesis, that allowed an increase of the maximum throughput of the model by a factor of more than two, the attention focused on mixed-precision algorithms. Ideally, a proper usage of numerical precision would allow to improve the computational performance without sacrificing accuracy. In order to achieve that in ocean models, a method to find out the precision required for each one of the real variables in a code was presented. The method was used with NEMO and with the Regional Ocean Modelling System showing that in both models most of the variables could use less than the standard 64-bit without problems. Last but not least, it was found that being ocean models nonlinear it was not straightforward to determine whether a change made into the code was deteriorating the accuracy of the model or not. In order to solve this problem a method to verify the accuracy of a non-linear model was presented. Although the different contributions that gave form to this thesis have been diverse, they helped to identify and tackle computational challenges that affect computational ocean models. These contributions resulted in four peer-reviewed publications and many outreach activities. Moreover, the research outcomes have reached NEMO and EC-Earth consortium codes, having already helped model users to save resources and time. These contributions not only have significantly improved the computational performance of the NEMO model but have surpassed the original scope of the thesis and would be easily transferable to other computational models.