Your Ansys, Inc. distribution medium contains the source codes for all user routines:
If you are running Mechanical APDL under Linux, the source code for the UPF routines resides in directory /ansys_inc/v242/ansys/customize/user/.
If you are running Mechanical APDL under Windows, the source code for the UPF routines resides in directory Program Files\ANSYS Inc\V242\ansys\customize\user\.
Most of the user routines have at least simple functionality, so print out the routines of interest before you start programming. All source routines are concatenated onto file user.f or user.for. Delete the routines you do not want and make appropriate changes to the others.