Accessing previous values of diagnostic variables #163
|
Hi all, I am working on a biogeochemical model and have a variable currently implemented as a diagnostic. For numerical reasons, I would like to use its value from the previous timestep as an input (as an initial guess in an iterative solver). I understand that state variables naturally provide this access to the last value, but in this case the variable should not be treated as a state variable (i.e. it should not be transported or time-integrated by the host). My questions are:
Many thanks in advance for your help! |
Replies: 2 comments 2 replies
|
Hi! You'll need a workaround to access the (previous) value of the diagnostic. In the module that implements the diagnostic, you can register a dependency with the same name. This dependency is then implicitly coupled to the diagnostic and will provide read access to it. In the routine that updates the original diagnostic, the dependency will be equal to the diagnostic's previous value.
|
|
I have now ported some of the documentation describing these features to from its not-easy-to-find PDF to the wiki |
Hi! You'll need a workaround to access the (previous) value of the diagnostic. In the module that implements the diagnostic, you can register a dependency with the same name. This dependency is then implicitly coupled to the diagnostic and will provide read access to it. In the routine that updates the original diagnostic, the dependency will be equal to the diagnostic's previous value.
act_as_state_variable=.true.is typically used for more exotic functionality. It can be used by moduleAto create a diagnostic that look like a state variable to another moduleB, which then contributes source terms (or bottom/surface fluxes) to it. ModuleAcan then retrieve those sources and do somethin…