Side-effects (spillover) from one pmodel run to the other
Closed this issue · 2 comments
It appears, that runs of the pmodel (or phydro) model have unwanted side-effects, affecting subsequent runs in the same R session.
This might affect biomee as well. (see #204 (comment))
MWE is in:
rsofun/tests/testthat/test-model-runs.R
Lines 214 to 224 in d44e3f8
Specifically, here we find dpsi
and psi_leaf
to be zero, when running the pmodel. If we run phydro in between (which supposedly sets dpsi
and psi_leaf
), and then run again pmodel, we find that dpsi
and psi_leaf
have constant values referring to the last time step of the phydro simulation.
I think it should now be fixed: da95557
I consider the generalized use of module variables (having a global scope) and save
ed variables (implicitly or not) is dangerous (and they make the code impossible to parallelized should that be of interest). In addition, the use of flags (eg. use_phydro
) will make the code unmaintainable very soon. Use of object oriented programming supported by Fortran 2003 is highly encouraged.