Hi Radovan,
There is a way to do this by using mdl.set_ns_var() and mdl.get_ns_var() functions.
Let say your variable is named temp_var. To read it you can call:
With mdl.get_ns_var("temp_var") you will get value of that variable.
Problem occurs when you want to change it. If you just call mdl.set_ns_var("temp_var", 10) your variable will still be set on the previous value after compile. Reason for this is that during compilation model init is called and it will overwrite changed variable.
What you could do is to leave model init empty and than you will not face this problem, however if you try to compile it through schematic, you will get an error because there is no variable defined.
Better approach is to check first if variable already exists, in model init of course. Something like this:
if "temp_var" not in mdl.get_ns_vars():
temp_var = 1
In this case you will be always able to load compile model through schematic, or through API. If you dont set ns varable, temp_var will be set to 1, but if you set with set_ns_var to, lets say 10, it will be 10.
Drawback of this is that you will not be able to read initial value, at least without compiling the model.