I am trying to find if an inout port is used as an input port or as an output port during simulation from my PLI based C-code. How can it be done?
Before you go down this path, note that most tools have capabilities to give you this information with Extended VCD files or in other formats usually associated with power estimation tools.
Doing this withe the VPI requires extensive knowledge of the §38 VPI routines and §36 VPI object model diagrams in the 1800-2012 LRM. I can give you an outline of what needs to be done:
inout
port
cbValueChange
callback using vpi_register_cb