Accelerated photosynthesis routine in LPJmL4

. The increasing impacts of climate change require strategies for climate adaptation. Dynamic global vegetation models (DGVMs) are one type of multi-sectorial impact model with which the effects of multiple interacting processes in the terrestrial biosphere under climate change can be studied. The complexity of DGVMs is increasing as more and more processes, especially for plant physiology, are implemented. Therefore, there is a growing demand for increasing the computational performance of the underlying algorithms as well as ensuring their numerical accuracy. One way to approach this issue is to analyse the routines which have the potential for improved computational efﬁciency and/or increased accuracy when applying sophisticated mathematical methods. In this paper, the Farquhar–Collatz photosynthesis model under water stress as implemented in the Lund–Potsdam– Jena managed Land DGVM (4.0.002) was examined. We additionally tested the uncertainty of most important parameter of photosynthesis as an additional approach to improve model quality. We found that the numerical solution of a nonlinear equation, so far


Introduction
Climate change is increasingly affecting the world we live in, and that in turn affects nature's contribution to our livelihoods (Pörtner et al., 2022).Estimating the extent and impact of climate change has become more and more urgent over the last couple of decades.Earth system models (ESMs) as well as impact models are used to develop strategies for climate adaptation and mitigation to achieve the Paris climate accord (Masson-Delmotte et al., 2021;Pörtner et al., 2022).Climate change affects vegetation dynamics, biodiversity, water, and biogeochemical cycles, which could reduce the biosphere's capacity to absorb carbon from the atmosphere in the future.Dynamic global vegetation models (DGVMs) are applied to study the net effects of multiple interacting processes that affect carbon sequestration (photosynthesis) and storage (in biomass and soil), see Prentice et al. (2007).It shows the demand for reliable and consistent model projections which require continuous work on reducing model uncertainty.While increasing complexity of the models by including more and more processes in DGVMs has been matched by increasing high-performance computing capabilities over the past decades, little has been invested into identifying and optimising computationally intensive routines in the model (Reichstein et al., 2019).These routines often have a long model history as they frequently belong to the core routines stemming from the very first model version.This includes, e.g. the physiological modelling core of simulating photosynthesis in connection with atmospheric water demand or plant-water stress.The photosynthesis model is based on the Farquhar approach (Collatz et al., 1991(Collatz et al., , 1992;;Farquhar et al., 1980) implemented in land surface schemes of the second generation (Pitman, 2003) followed by the first global biome models (Haxeltine and Prentice, 1996a) from which DGVMs evolved later on (Prentice et al., 2007).
The Farquhar-Collatz approach was implemented in the land surface of the SiB2 model by Sellers et al. (1992Sellers et al. ( , 1996a)), where it replaced their empirical photosynthesis model.The photosynthesis model in SiB2 (Sellers et al., 1996b) covers the co-limitation by Rubisco enzyme activity, light availability, and export limitation of carbon compounds.Furthermore, it covers the gradient between inner-stomatal CO 2 concentration to the CO 2 concentration around the leaf surface in the computation of stomatal conductance.By implementing the semi-mechanistic photosynthesis model and coupling it to transpiration via stomatal conductance, the land surface model (LSM) could then not only investigate biophysical effects of climate change but also the biogeochemical effects of rising atmospheric CO 2 in the earth system (Pitman, 2003).The SiB2 model (Sellers et al., 1992(Sellers et al., , 1996a)), the NCAR CCM2 model (Bonan et al., 1995), and the MOSES land surface model of the UK Met office (Cox et al., 1998) were among the first to implement this photosynthesis scheme and evaluate it against field campaigns.At present, the Farquhar-Collatz photosynthesis model is used in a number of land surface models of the CMIP-5 earth system models, such as the Community Atmosphere Biosphere Land Exchange (CABLE), the LSM of the Australian community climate and earth system simulator (ACCESS, see de Kauwe et al., 2015, and ref. therein), as well as the ORCHIDEE DGVM (Krinner et al., 2005) of the IPSL-CM5 earth system model (Dufresne et al., 2013).Different models of stomatal conductance were evaluated for the JSBACH LSM (Reick et al., 2013) of the Max Planck Institute earth system model (MPI-ESM) to account for hydraulic properties and drought response (Knauer et al., 2015).The Community Land Model CLM4.5 (Oleson et al., 2013) of the NCAR ESM use the Ball-Berry model of stomatal conductance and extended it to account for leaf temperature acclimation and leaf water potential (Bonan et al., 2014); a similar approach was implemented in the JULES-vn5.6land surface model (Oliver et al., 2022) of the UK Hadley Centre ESM (Sellar et al., 2019).
While land surface models detail vertical water, energy, and carbon profiles within the canopy, which extrapolates the photosynthetic capacity calculated at the leaf level to canopy photosynthesis (Sellers et al., 1996b), stand-alone DGVMs often use a big-leaf approach and compute daytime photosynthesis for canopy conductance, which goes back to the BIOME-3 model (Haxeltine and Prentice, 1996b) that opened up the second line of vegetation models by embedding the Farquhar-Collatz photosynthesis model in a mod-elling framework of plant physiology and vegetation dynamics in DGVMs (Prentice et al., 2007).The Haxeltine and Prentice (1996b) implementation is used in the LPJ model family originating from Sitch et al. (2003) and the LPJ-GUESS model (Smith et al., 2001(Smith et al., , 2014)), as well as the current LPJmLv4 model (Schaphoff et al., 2018a, b).The Farquhar photosynthesis module forms the core of many other DGVMs, see e.g.Smith et al. (2001Smith et al. ( , 2014)); Krinner et al. (2005).Today, 14 DGVMs (stand-alone and coupled to land surface models) contribute to the TRENDY intercomparison project (https://blogs.exeter.ac.uk/trendy/, last access: 14 December 2022), which informs the global carbon project on the state of the land carbon sink (Sitch et al., 2015).
In order to apply the model to the global land surface it is no longer sufficient to use faster or larger computing infrastructure or to try to parallelise the code as in von Bloh et al. (2010).Rather it requires the evaluation of the underlying algorithm structure of the code and, in particular, the used numerical methods.Replacing "old" numerical algorithms with modern methods will result in a significantly better run time performance while simultaneously maintaining or even increasing the accuracy of the method.We quantified the run time required by each submodule (or routine) of the LPJmL DGVM using the profiling option of the compilation command and the Linux gprof utility.We found that the repeated execution of the photosynthesis routine demands a big fraction, i.e. 38 %, of the computational time.All other routines require less than 11 %.
To illustrate our approach, our goal was to improve the computational efficiency of DGVMs by accelerating the photosynthesis module under water stress conditions using the Lund-Potsdam-Jena DGVM, Schaphoff et al. (2018a, b) as an example.A key ingredient in the modelling of photosynthesis is the determination of the ratio λ between intracellular and ambient CO 2 concentration.Mathematically, λ is computed as a zero of a nonlinear equation f (λ) = 0, which has so far been solved by a simple bisection algorithm.We expected to improve the computational efficiency by applying one of the more sophisticated solution methods, namely Regula falsi, secant and Newton's method.In this technical paper, we describe testing all three methods but found that only with Newton's method was the computational efficiency significantly improved.Only a few detailed specialised studies mention the use of Newton's or similar methods to solve coupled balance schemes, (Collatz et al., 1991;Pearcy et al., 1997;Soo-Hyung and Lieth, 2003;Dubois et al., 2007), or extensions of the photosynthesis-transpiration scheme along the leaf-plant-soil continuum in DGVMs (Bonan et al., 2014) are mentioned, but none provide documentation on the computational efficiency or how the numerical method was implemented in the model and/or their code.In addition, we test the effect of sensitive photosynthesis parameters on the annual gross primary production (GPP) of the computationally efficient model where we build on recent work by Walker et al. (2021).
We start with a short description of the different mathematical methods to find the zeros of a general nonlinear continuous function f and their advantages and disadvantages.Afterwards, we introduce the relevant function f from the photosynthesis module and calculate its derivative.We then compare the performance of Newton's algorithm and bisection in terms of the number of iterations and the computational time that is necessary to achieve a given accuracy.Finally, we benchmark the updated LPJmL version to show that the simulated vegetation dynamics as well as storage and fluxes of carbon and water remain robust.

Solution of nonlinear equations
The computation of the ratio λ between intracellular and ambient CO 2 concentrations requires us to compute the zero of a function f (λ).In most cases, this task cannot be solved analytically but requires a numerical approach, mostly based on iterative methods.Given a nonlinear continuous function f : R → R, we want to find the zero(s) x s of this function within a certain interval [a, b].While bisection, regula falsi, and secant methods are very simple to implement, Newton's method requires the computation of the derivative of f , which will be provided for the photosynthesis equation described in Sect.3.2.
Here, the computational efficiency is determined by the speed of convergence.To compare the methods with respect to the speed of convergence we define the order of convergence as follows: let x s be a zero of f found by computing a sequence (x k ) of approximate solutions via an iteration scheme.The iteration method has the order of convergence with 0 < K < ∞ and K < 1 for p = 1.Thus a high order of convergence implies a fast convergence, which on the other hand means fewer iteration steps.Numerically, the iteration is stopped either if the function value f (x k ) of the iterate x k is almost zero, i.e. less than a given accuracy y acc , or if the iterate itself changes less than a given accuracy Let us introduce some of the methods in the following subsections, see Schwarz and Köckler (2009) for details.

Bisection
For bisection we have to choose [a, b] such that f (a)•f (b) < 0, i.e. f (a) and f (b) have different signs.We compute the midpoint of the interval x m = a+b 2 and its function value This method always converges but slowly with convergence order p = 1, i.e. linear convergence.

Regula falsi
For the regula falsi method, we also need to choose a, b such that f (a) • f (b) < 0. Instead of the midpoint of [a, b], we compute the next iterate x 1 for an approximation of x s by computing the zero of the linear function through the points (a|f (a)) and (b|f (b)).Again we check if |f (x 1 )| < y acc and abort or check if f (a) • f (x 1 ) < 0, and repeat this procedure either with [a, x 1 ] or [x 1 , b].Convergence is always assured and is also linear, i.e. p = 1.

Secant method
The secant method only differs from the regula falsi in that the starting values a = x 0 and b = x 1 do not have to fulfil the condition f (a) • f (b) < 0. The next iterate is computed by . (2) This method can fail to converge depending on the starting values.If the method converges, it does so with order p = 1.618.Since the conditions on the starting values to ensure convergence depend on the knowledge of x s , in practise a and b still have to fulfil the condition f (a) • f (b) < 0.

Newton's method
Newton's method starts at an arbitrary approximation x 0 of x s and uses the tangent of the function f at (x 0 , f (x 0 )) to compute the next iterate x 1 as the zero of the tangent.This is repeated, thus the next iterate is always computed from the previous one by provided that f (x k ) = 0.The method belongs to the class of fixed point iterations because the computation of the next iterate depends on the previous iterate only.If f is three times differentiable on [a, b] and f (x s ) = 0, then there exists an interval I = [x s − δ, x s + δ] such that f is a contraction on I .It implies that for every start value from I , the method converges at least with order p = 2 (Schwarz and Köckler, 2009).We remark that the gain in convergence speed has to be weighted against the time it takes to compute the derivative of f .

Application to the problem
We now analyse the difference in speed of convergence between the bisection and Newton's methods when applied to the optimisation equation of the photosynthesis routine of the LPJmL DGVM.In presenting the function f (λ), we follow the nomenclature of Schaphoff et al. (2018a), which contains a detailed description of the derivation of this function.A list of the used symbols is given in Appendix A. We want to find λ = c i c a = p i p a , i.e. the ratio between the intracellular and ambient CO 2 concentration, or partial pressure, respectively, as the solution of the following equation: Here A nd is the net daily photosynthesis, R leaf is the leaf respiration, dayl is the hours of daylight, p a is the ambient partial pressure, g c is the canopy conductance, and g min is the minimum canopy conductance for a specific plant functional type (PFT).The first term is the photosynthesis during daylight.It is the gross daily photosynthesis A gd minus leaf respiration, A nd (λ) = A gd (λ)−R leaf .The second term represents the dark respiration, i.e. respiration during night time.
The third term represents the photosynthesis that is possible to achieve a potential canopy conductance.In finding λ such that f (λ) ≈ 0 we actually balance both light-and Rubiscolimited photosynthesis (first two terms) and photosynthesis related to the potential canopy conductance.
To shorten the formulas we define the abbreviation The second summand does not depend on λ, whereas A gd (λ) has a more complex representation.The gross photosynthesis rate A g is the minimum of the light-limited, J C , and Rubiscolimited photosynthesis rate, J E .It can be shown that the minimum can be computed as where θ is a shape parameter that allows for a gradual transition from one limitation to the other.Light-limited photosynthesis depends on the absorbed photosynthetically active radiation (APAR); Rubisco-limited photosynthesis is determined by the maximum Rubisco capacity V m : Setting the internal partial pressure p i = λp a and using another abbreviation , where K c is the Michaelis constant for CO 2 and [O 2 ] and K O are the partial pressure and the Michaelis constant for oxygen, we have Here, α C 3 and α C 4 are the intrinsic quantum efficiencies for CO 2 uptake in C 3 and C 4 plants, respectively.* is the carbon dioxide compensation point and T stress is a temperature stress function defined as with T d as the daily air temperature and T 1 to T 4 being PFTspecific temperature parameters (Sitch et al., 2000).LPJmL simulates vegetation dynamics for the 10 PFTs; we provide the parameter values used for T 1 to T 4 in Appendix A, Table A1, for the PFT types from Schaphoff et al. (2018a).

Derivative of f
To compute the derivative f of f we rearrange Eq. ( 5): Since the last two terms are constant the derivative is given by To determine A gd we apply sum, chain, and product rule of differentiation to Eq. ( 6) and get The derivatives of J E and J C are given by To compute C 1 from Eq. ( 9) and C 2 from Eq. ( 10) we use the quotient rule for C 4 -Photosynthesis. ( for C 3 -Photosynthesis 0 for C 4 -Photosynthesis. ( We describe the consequent changes in the model code which were required to implement the computation of the derivative fcnd(λ) in the Appendix B. The function f is defined for all λ > 0, as long as As a composition of at least 3 times differentiable functions, it fulfils the differentiability condition of Newton's method.The parameters in the definition of f vary with the geographic location and season.A plot of f for parameters from different locations (boreal, temperate, and tropical) and at different times can be seen in Fig. 1.
The condition f (λ) = 0 as well as the suitability of a staring value can not be generally ensured.In all our computations convergence was not a problem.To be on the safe side, one can implement a hybrid method that switches to bisection if convergence of the iterates does not occur.

Numerical performance and discussion
We have tested the different methods in the routine regarding computational time and number of iterations for given accuracy x acc .There was no significant speed up with the secant and regula falsi method.Hence, we concentrated on the comparison of bisection and Newton's methods and describe the outcome in this section.
In a first test, the LPJmL model was run over 120 simulation years and the number of iterations in the bisection and Newton's routine was counted and averaged over all grid cells and one year (Fig. 2).For x acc = 0.01 this number was about 3 for Newton's method and 7 for bisection (dotted lines in Fig. 2).When x acc was set to 0.001 the number of iterations with Newton's method increased only slightly, whereas the bisection method needed 9 to 10 iterations (solid lines in Fig. 2).Until now, the bisection algorithm used 10 as the maximal number of iterations.Using maximum 10 iterations fits into the interval width of 2 −10 ≈ 0.001, our accuracy measure x acc .Increasing the maximum number of iterations had no effect on the number of required iterations.We conclude that Newton's method reduces the necessary number of iteration to a third.
In a next step, a spin-up run of LPJmL over 5000 simulation years was conducted to compare the time performance using both routines.Usually, LPJmL simulation experiments start from bare ground, i.e. initial vegetation conditions are not prescribed.Therefore, a spin-up run is used to bring all vegetation and soil carbon pools into equilibrium with climate.For the usually implemented accuracy x acc = 0.1 the computation time for 5000 years was about 5250 s in both cases.This means that the advantage of Newton's method in terms of iteration numbers is levelled by the additional time for computing the derivative of f .For x acc = 0.01, the bisection method needed 6700 s, while Newton's method needed 5600 s.Thus a reduction of about 16 % in time could be observed.It implies that with almost the same amount of time (5250 s vs. 5600 s) a higher accuracy can be achieved with Newton's method (Fig. 3).While the accuracy y acc does not increase significantly for the bisection method for x acc = 0.001, we gain a 2 orders of magnitude increase in y acc for the Newton's method.As a result, a change of x acc from 0.1 to 0.01 will be permanently implemented in the LPJmL model for future model applications.We expect that with the implementation of new model developments that affect the photosynthesis module (e.g.nutrient limitation from nitrogen and leaf temperatures) an efficient and increased model accuracy (y acc ) for finding the zero of f (λ) will be even more important.It can be expected that the computation time for the bisection method would increase substantially, while increasing only moderately for Newton's method. https://doi.org/10.5194/gmd-16-17-2023 Geosci.Model Dev., 16, 17-33, 2023  In order to check if the implementation of Newton's method is robust for all important model variables, we performed a transient simulation with the LPJmL model starting from the spin-up and covering the years 1901-2000.Model configuration and input data are as in Schaphoff et al. (2018a).We compared the main diagnostic variables of the published LPJmL4.0 version against the version using Newton's method (see Appendix C).We found that most global diagnostic variables related to fluxes and storage of carbon and water had differences of < ±1.0 %, including total vegetated area.Only marginal changes (+3 gC per m 2 and month) in net primary productivity (NPP), heterotrophic respiration, and evaporation are seen mainly in Europe and southern as well as southeastern Asia.The reductions in carbon storage in litter and soil are very small and apply only to the boreal zone across the Northern Hemisphere and central Eu-rope (compare spatial maps of carbon and water variables in Appendix C).
The photosynthesis module is also applied to the crop functional types and managed grassland within LPJmL4.0.Therefore, sawing dates, crop productivity, and harvest are among the simulated variables.Comparing both model versions in the model benchmark, we found that global harvest changed for a number of crops.Rainfed and irrigated rice increased by 5 % and 8 %, respectively, mainly in India and southeast Asia.Harvest of rainfed temperate cereals increased by < 1.0 %, mainly found in central Europe.Harvest of irrigated temperate cereals (incl.wheat) increased by 4.5 %, which mainly applied to India as well.Harvest of irrigated and rainfed soybeans increased by 2.3 % and 1.5 % globally; the differences are mainly found in the US and Brazil.All other crop functional types had marginal to zero changes in global productivity as well as simulated harvest (see Table in Appendix C).
For all global carbon pools (vegetation and soil) and carbon (GPP, heterotrophic respiration, and fire emissions) as well as water fluxes (transpiration and runoff) we found no difference in the temporal changes in the transient simulation over the 20th century.All variables showed similar, if not identical, dynamics (data not shown).Small changes were found in the fractional coverage of plant functional types, i.e. most differences were negligible.The fractional coverage of temperate broadleaved summergreen trees increased by 4.8 % globally, which mainly applies to Europe, the northeastern USA, and parts of China.Increases in temperate C 3 grasses are found in the boreal zone, summing up to 4.8 % globally.Marginal changes of < 0.5 % per grid cell are found for all other PFTs, which imply small adjustments in vegetation composition in these vegetation zones (see difference maps in Appendix C).Comparisons using flux tower measurements on carbon and water fluxes as well as discharge data showed no differences so we can conclude that also for these variables the results are robust (data not shown).We can therefore conclude that the LPJmL results were robust before but are now achieved due to improved accuracy of the photosynthesis routine.
After improving the computational efficiency and numerical precision, we can now test the parameter uncertainties following Walker et al. (2021), who tested the sensitivity of θ, α C 3 , b C 3 , k c25 , and K o25 on their impacts on global GPP.The LPJmL model computes V m as follows (Schaphoff et al., 2018a, Eq. 35): Therefore, the sensitivity of V cmax results from varying b C 3 indirectly since the reciprocal of b C 3 is used to calculate V cmax in a linear equation.Varying b C 3 is therefore the adequate sensitivity test which relates to V cmax .We varied each parameter by 10 % independently and find that θ (α C 3 , b C 3 , k c25 , K o25 ) increases global annual GPP (AGPP, hereafter)   1 shows the difference of the two most important parameter on global AGPP.Geographically, increasing θ yields higher AGPP mainly in the tropics and temperate forest regions, where AGPP increases up to 100 gC m −2 .However, AGPP increases between 200 and 500 gC m −2 when changing α C 3 , see Fig. 4. It turns out that AGPP is increased in all regions, where LPJmL simulates woody PFTs.Also here, the largest effects are seen in (sub-)tropical and temperate regions which span larger areas than the areas with increased AGPP as a result of varying θ .
We remark that future work on the photosynthesis approach could focus on the new Johnson and Berry scheme (Johnson and Berry , 2021) with the advantage of calculating gas exchange and relying less on empirical coefficients.

Conclusions
The computational load of dynamic global vegetation models, caused by increased complexity of the modelling processes, has so far been counteracted by the high-performance computing systems used.However, more recently it has become clear that updates in computing infrastructure are not sufficient anymore.Consequently, we proposed to carefully evaluate the algorithmic structure of DGVMs and identify and update routines that can benefit from the use of modern mathematical methods.As a showcase, we investigated the photosynthesis model in the LPJmL DGVM.Specifically, we investigated the computation of the ratio λ between intracellular and ambient CO 2 , which is obtained as the zero of a function f .We proposed to replace the so far used bisection method with a Newton method, which is known to converge significantly faster.We carefully compared the model performance of the published LPJmL4.0 version with the version developed in this study and found that the model performance is robust.Using a more sophisticated mathematical method in the photosynthesis module allowed for a higher precision in the computation of λ and resulted in slightly increased productivity in continental and mountainous areas.We think that the new results are more accurate than the previous version due to the higher accuracy of the Newton method visible in Fig. 3.With the currently implemented accuracy bounds, the run time of the model with the Newton routine implemented is about 16 % lower than the old version.This advantage will be much more prominent if the complexity of the model is further extended or if more accurate modelling results are required.Consequently, the Newton-based routine will be implemented in the LPJmL model.Additionally, we believe that the Newton method can also be applied to photosynthesis modules in other DGVMs and can increase model accuracy and/or computational efficiency. https://doi.org/10.

Figure 3 .
Figure 3. Mean decadic logarithm of the accuracy y acc for bisection (upper lines, blue) and Newton (lower lines, red) for accuracy x acc = 0.01 (dotted) and 0.001 (solid).The dashed-dotted line shows the accuracy of the original version of LPJmL.

Figure 4 .
Figure 4. Parameter sensitivity on annual gross primary productivity (AGPP, average of 1901-2000) shown as the difference between new parameter and reference simulations.Both simulations have the Newton approach implemented.Increasing θ by 10 % increased AGPP mainly in forested regions (a).Increasing α C 3 by 10 % has a much larger effect on AGPP, especially in the tropics (b).

Figure C6 .
Figure C6.Difference maps of (a) runoff and (b) tree cover fraction.

Table 1 .
Change in the AGPP after varying the listed parameters by 10 %.GPP is calculated as the global average mean for the years 1901-2000.

Table C1 .
Global sums of actual vegetation, including land-use, comparing Newton approach (benchmark run) against bisection approach (run).Tece is temperate cereals.NA -not applicable, Mha -megahectare, Mt DM -megatonnes of dry matter.