A coupled 2D-3D catchment-lake model with a parallel processing framework

ABSTRACT Modeling catchment-lake interactions is computationally demanding, usually requiring coupled numerical models and parallel processing capabilities. However, models with these requirements are still rare. In this paper, we developed a coupled 2D-3D model for lake catchments using a parallel scheme that leverages processing power of GPU and multiple CPUs. The model allows for hydrodynamic simulation applications considering diffuse water flows at the interface between the catchment and the lake. We coupled the Environmental Fluid Dynamics Code (EFDC) with a two-dimensional shallow water model and test it on the Peri Lake Catchment in southern Brazil. The results revealed the ability of the model simulate lake water levels as well as the diffuse inputs of water and solutes, providing the possibility of its use in lake and reservoir water management.


INTRODUCTION
Physical, chemical, and biological aspects of lake circulation are determined by the interaction of lake and catchment water flows (Rueda & MacIntyre, 2010;Lopes et al., 2018).Point water inputs are important to represent the contributions from main rivers into the lake.Diffuse water inputs consider the distributed contributions from the catchment that enter the lake along the entire shore (Janssen et al., 2019).These point and diffuse water inputs can be simulated using coupled hydrological and hydrodynamic models (Huang et al., 2016).While most coupling approaches generally consider point inlets between the lake and the main rivers, diffuse water inputs that occur at the catchment-lake boundaries are more challenging to model (Xie et al., 2012;Li et al., 2014).
Hydrological processes within catchments are highly variable in space and time and influence the hydrodynamics of water bodies such as lakes and reservoirs (Zhang et al., 2019).To insert the hydrological components of the catchment into the lake hydrodynamics, most studies use data from flows gauged in the main rivers of the catchment (Bocaniov et al., 2016;Umgiesser et al., 2016).However, in many catchments this procedure is seriously restricted by the limited availability of gauged data and human and financial resources to carry out field monitoring (Lopes et al., 2018).In addition, this approach generally disregards diffuse water and nutrient inputs that may occur through hillslope and groundwater transport.This limitation can be overcome by coupling catchment with lake hydrodynamic models (Hwang et al., 2021;Shin et al., 2019).
The coupling of models has some limitations related to the simulation time, as it solves the equations of the two models and exchanges data between them with conventional programming methods that perform sequential calculations (Lopes et al., 2018).Besides, input data pre-processing usually requires advanced knowledge of a programming language and manual procedures with the application of several software (Shin et al., 2019).Performing each steps of the coupling manually is time-consuming and prone to data manipulation errors, in addition to limiting real-time modeling (Gregersen et al., 2007).
Simulation time can be shortened by using hydrological and hydrodynamic models prepared to use high performance computing and parallel processing methods in multiprocessor clusters, supercomputers, or in massively parallel devices such as General Purpose Graphics Processing Units -GPGPU (Ahn et al., 2021;Carlotto et al., 2018Carlotto et al., , 2019Carlotto et al., , 2021;;O'Donncha et al., 2014).As an example, the EFDC model is one of the most used and technically defensible hydrodynamic model for hydrodynamic simulation (Lai et al., 2016).It is open source and can simulate one, two and three-dimensional flows, sediment transport, thermal and biological processes in rivers, lakes, reservoirs and estuaries (Hwang et al., 2021).The EFDC model is capable of simulating the wetting and drying process in lakes and can deal with transient and intermittent events of water, nutrients and sediments coming from rivers or hillslopes (Hamrick, 1992).Recently, parallelized versions of the EFDC model were developed by O'Donncha et al. (2014) and Ahn et al. (2021) to provide fast and efficient simulations in high-performance computing structures such as clusters with multiple processors and massively parallel devices.The SW2D-GPU is another recently parallelized model that runs in GPU in order to provide fast and efficient simulations of surface water flows in catchments (Carlotto et al., 2021).It was implemented in CUDA C language which greatly improved its performance compared with the sequential CPU processing with Fortran language.
Regarding limitations in preprocessing and data sharing, they can be improved with the automation of the coupling process of the hydrological and hydrodynamic models for applications in lake ecosystems modeling (Alarcon et al., 2014;Gregersen et al., 2007;Hwang et al., 2021;Shin et al., 2019;Zhang et al., 2017).For example, Huang et al. (2016) coupled a 2D hydrological model (Xinanjiang) and the Environmental Fluid Dynamics Code (EFDC) in which the Xinanjiang model simulates inflow discharges for the boundary conditions of the hydrodynamic model of Lake Chao, China.Zhang et al. (2017) coupled the Soil and Water Assessment Tool (SWAT) and the Delft3D model to simulate the interactions between water flows in ungauged zones of the catchment and Lake Poyang in China.Hwang et al. (2021) used SWAT-EFDC to evaluate the water quality improvement scenarios considering the agricultural system and nonpoint source pollution of the upper Ganwol estuarine reservoir catchment located in South Korea.The models used in these studies are good alternative options, their coupling schemes disregard diffuse inputs and they are not implemented considering high-performance computing.
The objective of this paper is to couple the parallelized version of the EFDC model (O'Donncha et al., 2014) with the SW2D-GPU model (Carlotto et al., 2021) for the simulation of catchment-lake interactions considering the diffuse inputs between the catchment and the lake shores.The resulting coupled model (SW2D-EFDC) uses parallel computing with hybrid processing in which water flows in the catchment are calculated on the Graphics Processing Unit (GPU) and the 3D simulation of the lake hydrodynamics is performed on a computer cluster using Message Passing Interface (MPI).The SW2D-EFDC model can be used to answer important questions such as: what are the relationships between water levels in the lake and water flows from the catchment?How do changes in hydrological regimes influence lake hydrodynamics?We test the developed SW2D-EFDC model using the Peri Lake catchment case study to simulate diffuse water inflows across the interface between the catchment and the lake, considering atmospheric forcing (wind on and wind off scenarios) and the transport of a virtual tracer (dye) to visualize the inlets and movement of water in the lake during a rainfall event.

MATERIAL AND METHODS
Here we present the development of a fully automated framework for: (i) application of a hydrological model; (ii) selection of the variables to be used in the hydrodynamic model; (iii) definition of the positions in which the variable will be inserted in the boundary between catchment and lake (boundary conditions); (iv) creation of the input files, and (v) execution of the hydrodynamic model.

Two-dimensional shallow water model accelerated by GPGPU (SW2D-GPU)
The SW2D-GPU model is based on the 2D shallow water equations (Carlotto et al., 2021;Noh et al., 2016).In this Carlotto & Chaffe 3/14 formulation, the viscosity terms, wind resistance and Coriolis resistance are neglected.The equations of the two-dimensional shallow water model are written as follows: Continuity equation: (2) Momentum equations: Frictions terms: where t is the time; = , where u and v are the velocities in the x and y directions respectively; e r is the effective rainfall; r is the rainfall rate; INT is the percentage of rainfall interception loss; INF is the percentage of rainfall infiltration loss; LWL is the lake water losses (only in the cells in the lake area and water bodies); ex q is the term that defines the flow into the drainage network; E is the potential evaporation; 1 f and 2 f are the friction components, g is the gravitational acceleration and n is Manning's roughness coefficient.
The space-time discretization uses a finite difference scheme and the Leapfrog method in which water depths are calculated at the cell centers and fluxes are calculated at the boundaries of adjacent cells.The numerical solution of the momentum and continuity equations in the spatial dimension is processed in the parallel in the GPU.The temporal evolution is performed iteratively with a sequential code processed in the CPU (Figure 1).More details on the numerical and computational formulation of the model can be found in (Carlotto et al., 2021).

Environmental Fluid Dynamics Code (EFDC-MPI)
The EFDC-MPI model is based on the Reynolds-averaged Navier-Stokes equations.The model has an extensive mathematical formulation that includes a water quality model, a particle tracking model, temperature, sediment transport, among others.More details about the model and its formulation can be found in Hamrick (1992).The continuity and momentum equations use the Boussinesq approximation for a variable density fluid (Hamrick, 1992).The three-dimensional continuity equations are: The momentum equations are: where the vertical velocity w is related to the physical vertical velocity * w by: where H is the total depth of water column, defined as ( b h η + ); b h and η are the water depth below the vertical reference level and the water surface elevation above the vertical reference level, respectively; w is the vertical velocity in the z direction; f is the Coriolis parameter; v A is the vertical diffusivity; x m and y m are the square roots of the diagonal components; is the root of the Jacobian; p is the pressure; u Q and v Q , are the affluent-effluent movement terms and g the gravitational acceleration.Figure 2 shows a scheme of the vertical coordinate system.
The EFDC model uses a time variable stretching transformation to provide uniform resolution in the vertical direction.The stretching transformation is given by: where * z denotes the original physical vertical coordinates.
To solve the equations of motion, the EFDC model uses a second order finite difference method in a staggered or orthogonal curvilinear grid (Hamrick, 1996).A three-time Leapfrog numerical integration scheme with periodic trapezoidal corrections is used for the temporal integration of the model (Hamrick, 1992(Hamrick, , 1996)).The finite difference scheme is divided into external mode (barotropic mode) and internal mode (baroclinic mode).The external mode RBRH, Porto Alegre, v. 28, e2, 2023 4/14 A coupled 2D-3D catchment-lake model with a parallel processing framework solution is semi-implicit and calculates the two-dimensional field of water surface elevations with the pre-conditioned conjugate gradients method.The new surface elevation field is used to calculate the depth averaged barotropic velocities.In external mode it is possible to simultaneously define surface elevations, wave characteristics, or volumetric flow to be used as boundary conditions.The internal scheme for solving the momentum equations uses the same time step as the external solution and is implicit with respect to vertical diffusion (Hamrick, 1996).

Coupling
The SW2D-EFDC model uses hybrid parallel processing that leverages the processing power of the GPU and multiple CPUs (cluster).The structure of the codes implemented in CUDA C and MPI is illustrated in Figure 1.The coupling module is implemented in the SW2D-GPU model, comprising functions to map lake-catchment boundaries and automate the creation of the computational domain grid and the inputs for coupled simulations.
The coupling scheme contains functions that automate the process of creating EFDC-MPI model inputs while running the SW2D-GPU model.Inputs that do not depend on the solution of the shallow water equation or the identification of the lakecatchment boundary (i.e., files that define the grid, the computational domain decomposition and the initial conditions of temperature, salinity and dye concentrations) are created at the initialization of the SW2D-GPU model.The boundary conditions applied at the lake-catchment boundaries (i.e., salinity, temperature, and dye Carlotto & Chaffe 5/14 concentration time series) and the flow time series that depend on the solution of the shallow water equations are created at the end of the SW2D-GPU model run.This computational code enables efficient communication between models and can be the basis for the development of new coupling strategies using Open Modelling Interface (OpenMI) tools (Gregersen et al., 2007;Harpham et al., 2019).
The main input data to initialize the calculations of water flows in the catchment with the SW2D-GPU model are: • Topographic data: a file containing the digital elevation model (DEM) [m] is a mandatory entry, bathymetry must be included in areas where there are lakes; • Hydrometeorological data: rainfall [mm], temperature [°C], solar radiation [Wm 2 ], inflow and outflow time series [m 3 s -1 ] (monitored data of the water inlet or outlet).Temperature and solar radiation data are needed when the evaporation process is considered.The evaporation is computed by the model using energy balance method; • Initial and boundary conditions: initial water level [m] in the lake, Boundary condition of known value [m] (points of interest with a known fixed value); • Parameters: Manning roughness coefficient, albedo (value in the range between 0 and 1), lake water losses [%], rainfall interception loss [%] and infiltration [%].
The functions that make up the coupling module and the main automatically generated files for data sharing in the SW2D-EFDC model are described below (Figure 1).

Computational grid
In the SW2D-GPU model, the computational domain is discretized with square cells and a Cartesian grid, therefore, the EFDC-MPI model is also configured to use a grid that maintains the same characteristics.
Grid specification files: The grid generating pre-processor code, gefdc.f, is used to generate the horizontal grid and the DXDY.• GEFDC.INP: master input file for gefdc.f.
• When running gefdc.f the following files are created: • DXDY.INP: provides the spatial resolution x ∆ and y ∆ , the initial water depth, the bottom elevations, and the roughness coefficient; • LXLY.INP: provides geometric properties of the computational domain (cell center coordinates and the components of a rotation matrix).

Domain decomposition file:
The computational domain grid is decomposed into Locally Optimal Rectilinear Partition (LORP) using an optimal partition calculation code (O'Donncha et al., 2014).The LORP code runs automatically in the SW2D-EFDC coupled model, requiring only the information on the number of processors and the CELL.INP file as input.In this step, the LORP.INP file is generated containing the information for domain decomposition with load balanced among a defined number of processors.

Mapping lake-catchment boundaries
The flows calculated by the SW2D-GPU model are inserted in the EFDC-MPI model through the catchment-lake boundaries.The determination of the i and j positions of the cells that belong to the lake-catchment boundary is determined with a mapping algorithm that uses as input a lake mask composed of values 1 in the lake region and 0 elsewhere (Figure 3a).The code in Figure 3c identifies the differences in lake mask values whenever a lake-catchment boundary cell is reached.At the boundary positions belonging to the catchment domain, the values of flows in the south (S), north (N), east (E), and west (W) directions are calculated.These values are used as boundary conditions written in the QSER.INP file to be applied to the boundary cells (BC) belonging to the lake domain (i.e., BC cells in Figure 3b).Flow values are grouped according to the directions from which they enter the lake and recorded along with simulation times and BC positions (Figure 3b).The values of u, v and h are dynamically updated with the results of the SW2D-GPU model at each time interval of the simulation and the water velocities in BC are internally calculated by the EFDC-MPI model with the values of h of the boundaries belonging to the lake domain.

Flow coupling
The SW2D-EFDC model couples the water flows from the catchment into the lake (Figure 4a) and establishes a link with the heat exchange (Figure 4b) and transport processes.
The SW2D-EFDC model simulates the 2D-3D hydrodynamics of the lake system and provides a detailed view of the vertical profiles of velocity, temperature and chemical composition of water in the lake (Figure 4c).In the lake domain, a vertical Sigma Stretch Grid is used in which the vertical resolution is distributed according to the number of layers and the height of the water above the lake bottom in each cell.In this scheme, the number of layers remains fixed regardless of the water level, but the vertical resolution is variable in space depending on water depth (Figure 1a).The calculation to determine the vertical resolution of each layer is performed internally by the EFDC model based on the number of layers and proportions defined in the EFDC.INP file.For the coupling of the SW2D-GPU and EFDC-MPI models, the vertical resolution of each lake cell is divided equally between the layers.Likewise, the water flows entering the lake are divided by the number of layers and distributed evenly in each layer of cells at the lake-catchment boundaries (Figure 4e).This implementation can be adapted to non-uniform vertical flux distributions at catchment-lake boundaries through empirical equations obtained by analyzing data monitored in the field, showing great potential for testing hypotheses aiming to improve the understanding of hydrological processes at catchment-lake boundaries.
Figure 4d shows the horizontal coupling between the catchment and lake domains.The flows calculated by the SW2D-GPU model are stored and attributed according to the orientation of the faces at the boundaries of the EFDC-MPI model and the direction of the flows coming from the catchment.Water flowing from the north (Q yn ) enter north facing boundaries, flows from south (Q ys ) enter south facing boundaries, flows from east (Q xe ) enter east facing boundaries and flows from west (Q xw ) enter west facing boundaries.Flow values are automatically written to the QSER.INP file and entered into the lake domain as a volume flow boundary condition.

Study area
The Peri Lake catchment is located in Santa Catarina Island, southern Brazil (Figure 5), with average annual precipitation of 1500 mm (Chaffe et al., 2021;Hennemann & Petrucio, 2011).The lake surface area is 5 2 km with average depth of 7.0 m and maximum depth of 11.0 m.The surrounding hillslopes are covered by remains of Subtropical Atlantic Rain Forest and sandy Restinga (Perez et al., 2020;Santos et al., 2021).It is the largest source of water supply on the Island and an important ecosystem for biodiversity preservation.The lake supplies water to the local population through the Water and Sanitation Company (CASAN), which is authorized to extract up to 200 -1 Ls of lake water (water abstraction point is marked with a triangle in Figure 5).

Catchment-Lake simulation using SW2D-EFDC model
The SW2D-EFDC model is tested using Peri Lake data.The computational domain consists of a grid with 701 rows and 556 columns of rectangular cells with spatial resolution of 10 m.The catchment domain has 143723 active cells and the lake domain has 50638 active cells, 1394 cells belonging to the catchment-lake coupling interface.
In the simulations we use a Manning coefficient of 0.12 considering the presence of boulders with correction for channels covered by forests (Arcement & Schneider, 1989) and a time step of 0.04 seconds for the SW2D-GPU model (catchment).
For the 3D hydrodynamic model (lake), the coefficient of roughness of the bottom is assumed as 0.00025 m or 0.25 mm, representing a condition where there is little influence of roughness (Qin et al., 2004) and the time step of the numerical solver is 0.5 seconds.The time steps adopted were chosen to ensure the stability criteria of the models (Carlotto et al., 2021;Shin et al., 2019).The temporal resolution of the meteorological data is of 1 hour (Figure 6).The meteorological data used in this study were monitored using an automatic weather station located in the Peri Lake catchment (green circle in Figure 5b).The meteorological data used correspond to the period from 22/01/2020-09:00 to 29/01/2020-09:00 and have no gaps.Peri Lake water level data were provided by the Water and Sanitation Company (CASAN) which carried out the monitoring at the water abstraction point, whose location is indicated by the triangle in Figure 5b.
The simulations are carried out for considering wind off and wind on (only in the lake area) scenarios.A dye tracer transport has been included in the simulation for the visualization of water inputs and lake hydrodynamics.The water that comes from the catchment is represented by the concentration 10.00 -1 mgL and the initial concentration in the lake is null.We used data from Carlotto et al. (2021) to define that 45% of rainfall is lost by interception (INT), 20% is lost by infiltration (INF) in the RBRH, Porto Alegre, v. 28, e2, 2023 8/14 A coupled 2D-3D catchment-lake model with a parallel processing framework catchment.In the lake area, a water loss (LWL) equivalent to 30% is considered.The water treatment plant is represented using an abstraction point of 120 -1 Ls (Figure 5b).

RESULTS
During the simulations, water level variations in the lake are recorded.We compare the two models and verify the conservation of mass and that the water inlets in the lake are compatible with those of the SW2D-GPU using the SW2D-EFDC model (Figure 7).First, only the SW2D-GPU model is used to verify whether the parameters n (Manning coefficient), INT (percentage of rainfall interception loss), INF (percentage of rainfall infiltration loss) and LWL (lake water losses), used would provide a good representation of the water level variations in the lake.The model is well adjusted as the Root Mean Square Error (RMSE) equal to 0.779.The coupled version SW2D-EFDC is applied and the simulated values of the water levels in the lake are compared again with the measured values.We identified that the SW2D-EFDC model provided an improvement in the fit of the simulated values to the measured data, showing a reduction of the RMSE to 0.750.The lake water level is well represented by both the SW2D-GPU model and the coupled SW2D-EFDC version (Figure 7).In the first 60 hours (period in which the catchment has the greatest contributions to the water inputs in the lake), the coupling between the two models is well established so that there are no significant water losses at the catchment-lake interface.A small difference in the simulated levels is verified after 80 hours, in which the levels of the coupled model SW2D-EFDC are slightly higher due to differences in water extraction (by evaporation and water abstraction) in the 3D hydrodynamic model lake domain.However, this difference remains less than 1 cm (which is the precision of the level sensor) throughout the simulated period.The Figure 8 presents other aspects of the lake hydrodynamics, showing how the dye concentration (virtual tracer) propagates inside the lake.The Figure 8 presents the results of coupled simulation of water flows in the catchment and the hydrodynamics of the lake in wind on and wind off scenarios in which, in addition to the water velocities, the dynamics of a virtual tracer are also simulated.Water enters through rivers that have the largest drainage network, and in the period of the most intense rainfall the water velocities coming from the main river cause higher velocities in the inner part of the lake.However, there are also several smaller water inlets across the catchment-lake boundary (Figure 8i-l).In a scenario that includes wind velocities and directions we can see the hydrodynamic behavior of the lake, estimate how the water velocities in the lake behave (Figure 8m-p) and estimate how the transport of a dye or solutes would enter from the catchment (Figure 8q-t).
In the simulation, the waters entering the catchment are mixed with a virtual tracer that facilitates the visualization of diffuse water inflows into the lake.In the wind-off scenario, it is easier to perceive the water inflows coming from the two main rivers, which with higher velocities transport the virtual tracer towards the central area of the lake, whereas the diffuse inflows distributed along the entire catchment-lake boundary have lower velocities and the virtual tracer remains on the lake shores.
When wind velocities and directions are considered, the hydrodynamics of the lake is modified, with the wind as the main controller of water movement.In this scenario, the effect of the mixing of the virtual tracer that enters through the catchment-lake boundary becomes visible, as now the tracer concentrations that were retained on the lake shores are carried by the water towards the central region.This behavior, in addition to showing that wind velocities are of great importance for lake hydrodynamics, also reveals that diffuse water inflows across catchment-lake boundaries can significantly influence lake water composition.Although this case study shows a way to use virtual tracer concentrations (dye) to visualize diffuse water inflows into the lake, it can also be a good way to infer possible entry points for nutrients and solutes from the catchment, estimate for which regions of the lake are transported, and possibly define where the highest concentrations can be found.

The benefit of coupling using high-performance models
The technological development and the consequent increase in the capacity of computers to perform large amounts of calculations also began to require the development of compatible mathematical and computational models capable of using such technologies (O'Donncha et al., 2019).This is a fundamental aspect to be considered in the next years, in which scientific and technological development in the area of water resources will be closely related to the creation of computational tools focused on generating knowledge about hydrological processes and ecosystem relationships in catchments in a scenario of climate change and concerns about the water and energy security (Getirana et al., 2021).
In this work we show that the coupling of the SW2D-GPU model with the EFDC-MPI hydrodynamic model provide a 3D hydrodynamic modeling of the lake considering the diffuse water inflows from the catchment, solute transport and wind influences (Figure 8).This coupling resulted in the SW2D-EFDC model that uses parallel processing in multi-core and GPU architectures.Thus, it minimizes the problem of long computational time, which is one of the main obstacles for the application of coupled models in real-world simulations (Hu et al., 2020;Munar et al., 2018).Another problem inherent to the complexity of the models is the preparation of the inputs to start the simulation, mainly in the part of the 3D hydrodynamic model (Huang et al., 2016).Therefore, in the coupling that we carried out, the processes of creating the inputs and the configuration of the 3D hydrodynamic model were automated to ensure the continuity of the solution and the data sharing between the SW2D-GPU model and the EFDC-MPI model.The SW2D-EFDC model is one of the main contributions of this work, containing the following potentialities: (i) it allows hydrological and hydrodynamic simulations in large areas and with high spatial resolution; (ii) it simulates hydrodynamics in lake ecosystems with little availability of measured data; (iii) it simulates catchment and lake interactions; (iv) it is ideal for simulations using GPUs and clusters with multiple processors (CPUs) and can also be used in common office computers.

Model applicability
The catchment hydrology influences the spatial heterogeneity of nutrient loads, as the sources of water entering lakes can be local or widely dispersed, which determines the distribution of nutrients and solutes in the water body (Janssen et al., 2019).In this sense, the SW2D-EFDC model was developed to provide the study of the effects of diffuse water inputs that come from the catchment on the hydrodynamics of the lake and thus improve the understanding of how do changes in hydrological regimes influence lake hydrodynamics and which are the relationships between water levels in the lake and water flows from the catchment.
These issues are important, especially in a closed lake like Peri Lake, which can have significant water inflows from slopes and small streams where there is no monitoring, this behavior is evidenced in the results presented in Figure 8 through the simulation with tracer dye.In this context, this work showed that the SW2D-EFDC model can bring important contributions to the study of lake hydrodynamics related to the variability of water levels and the transport of solutes in lake water, allowing to improve the understanding of these ecosystems that are sensitive to climate change and human activities that occur in the catchment (Couture et al., 2014).
The practical applications of the SW2D-EFDC model go beyond the case study presented in this work, and may be useful in other study areas and in different contexts, such as lakes formed in hydroelectric dams and reservoirs used for public water supply.In these cases, the coupled model can be a powerful tool to assess the water supply and water quality improvement scenarios considering the agricultural system and diffuse source pollution and also to assess the environmental risk of pollution incidents in quantitative terms around lakes which are important sources of drinking water (Hwang et al., 2021;Tian et al., 2019).Overall the SW2D-GPU model can be applied to quantifying the effects of external forcing and water inputs on the lake hydrodynamic processes, the approach used allow the prediction of flows in ungauged areas, providing a representation of the diffuse discharges entering the lake boundaries.The model can be constantly improved and tested as the catchment is being instrumented.Regarding usability, the SW2D-EFDC model significantly reduces the difficulties commonly encountered in the hydrological-hydrodynamic modeling of lake ecosystems, since most of the configuration procedures were automated.

CONCLUSIONS
In this work it was shown that the SW2D-EFDC coupled model is able to represent the exchange of water between the catchment and the lake.The tests and application of the coupled model SW2D-EFDC were developed in the Peri Lake catchment, which is a lake ecosystem with a tropical climate located in southern Brazil.It was verified that the coupled model correctly simulated lake water levels during a precipitation event.The SW2D-EFDC model was applied to simulate the lake hydrodynamics considering the transport of a virtual tracer in wind-off and wind-on scenarios.This application showed that the model remained stable for water velocities induced by wind velocities measured in the catchment.The transport of a virtual tracer showed the model ability to represent the inputs and dynamics of solutes coming from the catchment.Therefore, the SW2D-EFDC model can be a useful tool to study water flows in the catchment and its influences on water levels and lake hydrodynamic at a catchment scale.
The coupling of the SW2D-GPU model and the EFDC-MPI model allowed us to take an important step towards studying the influence of catchment flows on lake hydrodynamics, in an automated way and with high-performance computational resources using a parallel scheme that leverages processing power of GPU and multiple CPUs.Some limitations still remain and offer opportunities for future studies.One of the challenges for coupled hydrological-hydrodynamic modeling is the bidirectional representation of flows.In the SW2D-EFDC model, the flows occur only from the catchment to the lake, this was a simple way adopted to test how the EFDC-MPI model would behave in the face of a coupling involving the entire boundary between catchment and lake.The test results showed good computational performance and there was no loss of numerical stability, indicating that a more complex coupling scheme involving the bidirectional representation of the flows is viable for future studies.

Figure 1 .
Figure1.Flowchart of the SW2D-EFDC model.The SW2D-GPU model, the coupling module and a single time step of the EFDC-MPI model are illustrated.t is time, ∆t is time step, t max is simulation time, t out is output time, u and v are velocities in x and y directions and h is water depth.In the SW2D-GPU model, the momentum equations are solved in the step of calculating the flow components and the solution of the continuity equation is carried out in two intermediate steps according to the Leapfrog method(Carlotto et al., 2021).
INP and LXLY.INP files.This code is provided with the original version of the EFDC model.However, to use gefdc.f the input files CELL.INP, DEPDAT.INP, GRIDEXT.INP, GEFDC.INP are required.Here we developed a code called make_grid_inputs.c to automate the creation of these files using the digital elevations model with bathymetry coupled from the SW2D-GPU model and a mask that defines the lake region, both are files in Esri ASCII raster format.• CELL.INP: file containing computational domain definition and horizontal cell type identifier; • CELLLT.INP: file containing horizontal cell type identifier for saving mean mass transport.The file CELLLT.INP may be equal CELL.INP file or define a subset of the water cells in the computational domain; • DEPDAT.INP: file containing depth or bottom topography (based on lake bathymetry); • GRIDEXT.INP: file of water cell corner coordinates;

Figure 2 .
Figure 2. The EFDC vertical coordinate system.(a) In the physical space; (b) In the sigma space (adapted from DSI LLC, 2022).

Figure 3 .
Figure 3. Mapping of lake-catchment boundaries.(a) Mask in which the cells belonging to the lake region are set to 1 and the other cells to 0; (b) Illustrates lake-catchment boundary cell positions where boundary cells (BC) belong to the lake domain and catchment cells are identified with directions from which flows entering the lake are coming (South -S, North -N, East -E, and West -W).On the right, the records of times (t), flows (Q yn , Q ys , Q xe , and Q xw ) and x and y positions are presented, grouped according to the direction from which the flows come; (c) Code for mapping the i and j coordinates of lake-catchment boundaries and calculating volume flows.Where s_bc, n_bc, w_bc and e_bc store the coordinate values at the south, north, west, and east boundaries, respectively.s_val, n_val, w_val and e_val store the calculated flow values at the south, north, west and east boundaries, respectively.N is the number of time intervals in the simulation.

Figure 4 .L
Figure 4. Illustration of the SW2D-EFDC coupled model.(a) Illustration of the Catchment-Lake coupling; (b) 3D model of the lake showing the distribution of simulated temperatures; (c) Vertical temperature profiles; (d) Illustration of the horizontal coupling in which the arrows indicate the direction of the flows Q yn , Q ys , Q xe and Q xw (flows from north, south, east, and west, respectively); (e) 3D view of the coupling interface in a section in which the 3D lake model has 3 vertical layers that receive flows 1 L Q , 2 L Q and 3 L Q

Figure 5 .
Figure 5. Study area.(a) Shows the location of the Peri Lake catchment on the map of Florianópolis Island in Southern Brazil; (b) Peri Lake catchment in which the elevations, drainage network and the bathymetry of the lake (contour lines) are shown.The color bar represents the topographic elevations.The triangle represents the location of the water abstraction and the circle represents the location of the automated weather station.

Figure 7 .
Figure 7. Simulated water levels and gauge data.The black dots represent the gauged level data.The red dashed line represents the lake water level simulated by the SW2D-GPU model and the blue line represents the lake water level simulated by the SW2D-EFDC coupled model.

Figure 8 .
Figure 8. Interactions between water flows in the catchment and the lake.(a-d) Water depth variation in the catchment;(e-h) Water velocities in the lake in a wind-off setting; (i-l) The dynamics of a dye in the lake in a wind-off scenario; (m-p) Water velocities in the lake in a wind-on scenario; (q-t) Dynamics of a dye in the lake in a wind-on scenario.The columns represent the results at 24, 48, 72 and 96 hours, respectively.