You will only be able to do this if you have the source code of IFs and a license for its use (and if you have Visual Basic programming skills).
To add a variable to IFs (or to eliminate one):
- Edit IfsVar.mdb. This is an MS Access file. Add a new line for a new variable and provide values for the various fields by looking at similar, already existing variables in the file.
- After adding a variable to IFs, you must rebuild the common block, rebuild the base case, and re-run the model.
- Be aware that this topic has only described the addition of a variable to the input/output interface of IFs. It will have values of 0 unless you do something with it in the model code:
- Use it as an output variable, calculated from other variables in IFs.
- Use it as an input parameter or variable with specified initial condition. If you want to do this, you would also need to learn how to change the data files of IFs and the code in the pre-processor.
Legacy Approach to Adding a Variable. In older versions of IFs that process was harder. The following description should not be necessary for those with new copies of the source code:
Edit DECLARE2.BAS to change the total number of positions in the vector that stores all results from IFs. Near the bottom of that file you will find code like this:
Type DATAPT2 '- New system
elem2(5000) As Single
elem3(3456) As Single
' elem3(4698) As Single
' Dim BufElem in RebBase sets total size of buffer; may need to
' expand that also - now set at 70000
DATAPT2 contains an element which is always dimensioned to 5000, because data is transferred to and from result files in a buffer which is 5000 positions in length. The number of positions needed will change with the number of variables in IFs and their dimensionality. You will need to change the dimensionality of elem3 in DATAPT3 in order to pick up the residual positions after the 5000-position buffer is used as frequently as needed.
When adding a variable of known length (e.g. a scalar of length 1 or a regionalized variable across x regions), it is possible to adjust elem3’s dimensionality on the front end of an attempt to rebuild common. Often it is difficult to calculate the number of positions needed (especially for the change in subscripts applied to many variables). In this case, rebuild the common and let that procedure abort with a message that will tell you the new size needed for the total number of positions; adjust elem3 dimensionality accordingly and rebuilt the common again (hopefully now with success).
It is possible to change the dimensionality of variables by edition IFs.grp. Again, you would need similarly to change the number of positions in DECLARE2.BAS and rebuild common.
For your information, the total number of positions (FILEN) in each year of the result file is calculated from IfsVar.mdb when the model is initiated. You need not do so (its length will be elem2 dimensionality * x(as needed) + elem3 dimensionality.