Unexpected (output) behaviour when using dependencies on aggregated variables #184
|
During model development, I recently noticed the following behaviour when using (user-defined) standard variables with In my specific case I have three algae functional types and a standard variable: using: For each algae FT, the model does: The model has one zooplankton group whose grazing depends on the total algal biomass (i.e. Note that If I use the same dependency in a model that does not change any of the contributing variables, the lag does not occur, i.e. I am curious to know how this behaviour can be explained and whether this is intended or not? Cheers, P.S. For our zooplankton model, this behaviour can be avoided as the zooplankton model also requires the individual biomasses, so the dependency on the aggregated variable can be removed. |
Replies: 10 comments 4 replies
|
Hi Fabian, That sounds surprising. What is the version of FABM you are using, and what is the host model? And is You can get detailed information about the order in which FABM calls the different model components by adding Cheers, Jorn |
|
Hi Fabian, Thanks! From what I can tell, everything is behaving as I would expect: if the rotifer module requests the value of the total algal biomass, FABM will ensure that its value is computed before the rotifer module is called ( Cheers, Jorn |
|
Hi Jorn, Our BGC This is the only location where In the main routine, the call sequence during the simulation is this (again in shortened pseudocode form): For testing, I added another In the previously uploaded log files, Provided I interpret the logs correctly, the model only does the aggregation once for eacht aggregation variable and it does it at the first required necessary location. However, perhaps something in the call sequence above is not as it should be to achieve the desired behaviour? |
|
It's puzzling... Regarding the code snippets above, the only thing that looks unusual is that you have the call to |
|
Hi Jorn, There is a time update between Re. Is there any way to enforce aggregation of all |
|
The strange thing is that aggregate variables should be updated: they are by default marked for output and - if no other FABM module requests them - are therefore scheduled to be calculated by Regarding the vey first output: diagnostics are calculated somewhere in the sequence |
|
The output variable is a user-defined standard variable: I am adding it to the output via In fact, I will do another test with |
|
My guess is that it is the rotifers (or any other module) depending on algae biomass that makes the difference, because that forces the calculation of the algae biomass at an earlier (before-rotifer) stage - whether or not a module adds sources to one of the constituents of the aggregate variable should not matter, as that impact is essentially dealt with outside FABM by the host perfoming time-integration. |
|
One more thing to note: in the sequence I'm not sure what "apply" means, but I'd note it is not safe to change the state (e.g. time-integrate) there, as it will mean that some parts of |
|
Jorn, thank you so much for letting me pick your brain! I have one last question (re. this work complex, possibly more to come in the further process). My entire So, the output written during the first iteration is my initial state with all diagnostic and aggregation variables being properly set/initialised. |
Yes that is very likely the cause. I'd suggest declaring
int_source_termsfor the full domain (adding thei_verticaldimension), feedingint_source_terms(:,i_vertical,:)intoget_interior_sources, and doing theinterior_stateupdate based on that afterfinalize_outputswith something likeIf you further do the output in between
finalize_outputsand the above state update, you'd get the nice result that state and diagnostics are in sync in output.