If you go through the user-defined functions chapter (chapter 24- Volume 4) of User manuals of Fluent, you can see a function called "DEFINE_ON_DEMAND". This will be used in accessing the user-defined variables and you can execute them based on ur requirement.