If you get a compiler error/warning, then you should troubleshoot this issue before the subsequent errors/warnings. Your UDF code looks fine to me, but for some reason, it appears that the script is not compiled correctly.
Are you following these steps here to Build and Load the UDF? 5.2. Compiling a UDF Using the GUI (ansys.com)
Do you get any errors when loading the UDF?
Please Login to Report Topic
Please Login to Share Feed