In Mechanical APDL running under Windows, each user routine is built into a separate dynamic link library (DLL). To share data, functions and data must be explicitly exported and imported. The following subroutines enable you to share data between user routines via common-block variables:
For more information, see Sharing Data Between User Routines.
*deck,userdata USERDISTRIB function getusercmvals(iloc,sz,outdata) c!DEC$ ATTRIBUTES DLLEXPORT :: getusercmvals #include "usercm.inc" integer iloc,sz,getusercmvals double precision outdata(*) if ( iloc.lt.1.or.iloc+sz.gt.userdatsz) then getusercmvals = 0 else outdata(1:sz)= userdata(iloc:iloc+sz) getusercmvals = 1 endif return end function setusercmvals(iloc,sz,indata) c!DEC$ ATTRIBUTES DLLEXPORT :: setusercmvals #include "usercm.inc" integer iloc,sz,setusercmvals double precision indata(*) if ( iloc.lt.1.or.iloc+sz.gt.userdatsz) then setusercmvals = 0 else userdata(iloc:iloc+sz) = indata(1:sz) setusercmvals = 1 endif return end subroutine initusercmvals(arraysz) c!DEC$ ATTRIBUTES DLLEXPORT :: initusercmvals #include "impcom.inc" #include "ansysdef.inc" #include "usercm.inc" integer arraysz external fAnsMemAlloc PTRFTN fAnsMemAlloc character*16 memlabel memlabel = 'userdat' userdatptr = fAnsMemAlloc(arraysz,MEM_DOUBLE,memlabel) userdatsz = arraysz return end subroutine freeusercmvals() c!DEC$ ATTRIBUTES DLLEXPORT :: freeusercmvals #include "usercm.inc" external fAnsMemFree call fAnsMemFree(userdatptr) userdatptr = 0 return end function getusercmvalsz() c!DEC$ ATTRIBUTES DLLEXPORT :: getusercmvalsz #include "usercm.inc" integer getusercmvalsz getusercmvalsz = userdatsz return end