Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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_mac is the bus number where the machine is.
  • id_mac is the id of the machine inside the bus.
  • l_mac is the position of the machine in the var array.
  • n_val is the new value to set to the position, for example, l_mac+2 of the var array.

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 - 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 - 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_mac is the bus number where the machine is.
  • id_mac is the id of the machine inside the bus.
  • l_mac is the position of the machine in the var array.
  • n_val is the new value to set to the position, for example, l_mac+2 of the var array.

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)