I see. Thanks Charles. I also realized that the initialization in usr_rates.f happens every time loop, and the IC condition only happens once at the beginning of the simulation. Is that right?
That’s right, “IC” is Initial Condition, so that is applied only at t=0.
It’s not strictly necessary to initialize all the variables in usr_rates.f, especially if your code is simple. But I recommend it, it’s good practice. For example, in the Spouted Bed example,
DOUBLE PRECISION c_O2 ! Oxygen
without setting it to 0, and further down:
IF(Pg_CO .GT. ZERO .AND. Pg_O2 .GT. ZERO) THEN
! Compute gas phase concentrations of O2, CO, and water vapor.
c_O2 = RO_g(IJK)*X_g(IJK,O2)/MW_g(O2)
If that IF statement is not executed, c_O2 is never set to any particular value at all, since it was not initialized to 0, it will be essentially random, leading to unpredictable/unreproducible behavior. (In this case it doesn’t really matter because c_O2 is not referenced outside that IF block. But it could be an issue in a different setting.)