I have created a user written GFOSUB subroutine. The subroutine will have a number of values passed to it from ADAMS, based on these inputs it will assign desired values to a number of global variables within the subroutine and then calculate the appropriate output forces based on the values of the global variables.
When I use this subroutine for one body, it produces the desired outputs. However, when I implement this subroutine to two different bodies with different inputs for each body, the results are incorrect for both as the global variables are not assigned a value.
I have found one way around this, by simply defining the global variables as arrays and adding an additional input to the GFOSUB which identifies which array element to use.
However, is there a different or more appropriate method of solving this issue?