How to add new biogeochem or soilbiogeochem changes to the CN Matrix solution - ESCOMP/CTSM GitHub Wiki

How to add the CN Matrix solution to new BGC or soil-BGC changes

For an example set of changes for this look at the dynGrossUnrepMod.F90 and CN?StateUpdate2Mod.F90 code that goes along with it (CStateUpdate2g and NStateUpdate2g).

Changes to CN?StateUpdate Code

Most state updates are removed

Exceptions:

  • xsmrpool
  • transfer pools
  • possibly new feature specific storage pools

An "if ( .not. use_matrixcn )"

conditional goes around most of the state updates. Transfer and xsmrpool updates stay outside of the condition however (as does any new specific storage pools that aren't already handled in the matrix).

The equivalent of those state updates that were removed goes into the main code that supports the feature in another

"if ( use_matrixcn )"

section. Put a pair of comment that points from one file to the other.

Soil BGC updates in the update code

Soil-BGC updates will likely have a

"if (.not. use_soil_matrixcn)"

section and a

"else"

section for the matrix solution with decomp vr pools changes going into a matrix vector (matrix_?input%V) instead.

Changes for matrix in the feature supporting code

In the conditional pointed out above...

"if ( use_matrixcn )"

is added to the feature supporting code. Pool transfer rates are added to the appropriate part of the matrix.

Final checks added to feature code

Some final checks need to be added to the feature code when matrix is on to make sure some pool transfer rates don't exceed 1/delta(t). This might already have been done in other places for terms that are added to in the feature code, if so those pools especially need to be handled. This creates a chain of events that has to happen each time the same transfer pool is added to.