Hello!
As part of the Ansys policy, employees cannot debug UDFs on the forum. However, I would suggest you to have a look at the following things.
For the macro C_UDSI, if you try to use the macro before you have specified the user-defined scalars in your Ansys Fluent model then an error will result.
3.2. Data Access Macros (ansys.com) -> Check section 3.2.11.3
Please also have a look at the definition of the macro C_UDMI and how the arguments are defined at the link below.
3.2. Data Access Macros (ansys.com) -> Check section 3.2.12.4
Additionally, this is the link from the Ansys manual for defining the source term. Make sure that you have correctly defined the dS[] array with respect to the dependent variable.
2.3. Model-Specific DEFINE Macros (ansys.com) -> Check section 2.3.43
Lastly, these are the time dependent macros which you can use to access variables for previous timesteps.
3.5. Time-Dependent Macros (ansys.com)
If you are not able to access the link, please refer to this forum discussion: Using Help with links (ansys.com)
Thanks!