Revision history [back]
After hours of debugging and testing. I figured out there is no better solution than the described in the question.
Also, I've noticed the time performance of using mdlind for getting the machine position in the arrays and change the var array instead of calling change_var is significantly better when developing machine models in fortran.
Here, I write some examples, where:
bus_macis the bus number where the machine is.id_macis the id of the machine inside the bus.l_macis the position of the machine in thevararray.n_valis the new value to set to the position, for example,l_mac+2of thevararray.
Way 1 - Better performance: only fortran
call mdlind(bus_mac, id_mac, 'GEN', 'VAR', l_mac, ierr)
var(l_mac+2) = n_val
Way 2 - Secure and API use: fortran
call mdlind(bus_mac, id_mac, 'GEN', 'VAR', l_mac, ierr)
call change_var(l_mac+2, n_val, ierr)
Way 2 - Secure and API use: python
ierr, l_val= psspy.mdlind(bus_mac, id_mac, 'GEN', 'VAR')
ierr = psspy.change_var(l_mac+2, n_val)
After hours of debugging and testing. I figured out there is no better solution than the described in the question.
Also, I've noticed the time performance of using mdlind for getting the machine position in the arrays and change the var array instead of calling change_var is significantly better when developing machine models in fortran.
Here, I write some examples, where:
bus_macis the bus number where the machine is.id_macis the id of the machine inside the bus.l_macis the position of the machine in thevararray.n_valis the new value to set to the position, for example,l_mac+2of thevararray.
Way 1 - Better performance: only fortran
call mdlind(bus_mac, id_mac, 'GEN', 'VAR', l_mac, ierr)
var(l_mac+2) = n_val
Way 2 - Secure and API use: fortran
call mdlind(bus_mac, id_mac, 'GEN', 'VAR', l_mac, ierr)
call change_var(l_mac+2, n_val, ierr)
Way 2 - Secure and API use: python
ierr, l_val= psspy.mdlind(bus_mac, id_mac, 'GEN', 'VAR')
ierr = psspy.change_var(l_mac+2, n_val)