FORTRAN example for axial force user subroutine

 

C---- SUB. AXIAL_FORCE : AXIAL(TRA,ROT)

      SUBROUTINE AXIAL_FORCE

     &          (TIME,UPAR,NPAR,JFLAG,IFLAG,RESULT)

C---- TO EXPORT * SUBROUTINE

      !DEC$ ATTRIBUTES DLLEXPORT,C::AXIAL_FORCE

 

C---- INCLUDE SYSTEM CALL

      INCLUDE 'SYSCAL.F'

 

C---- DEFINE VARIABLES

C     Parameter Information

C     TIME   : Simulation time of RD/Solver. (Input)

C     UPAR   : Parameters defined by user. (Input)

C     NPAR   : Number of user parameters. (Input)

C     JFLAG  : When RD/Solver evaluates a Jacobian, the flag is true. (Input)

C     IFLAG  : When RD/Solver initializes arrays, the flag is true. (Input)

C     RESULT : Returned axial force or torque value. (Output)

 

      DOUBLE PRECISION TIME, UPAR(*)

      INTEGER NPAR

      LOGICAL JFLAG, IFLAG

      DOUBLE PRECISION RESULT[REFERENCE]

 

C---- USER STATEMENT

C---- LOCAL VARIABLE DEFINITIONS

      INTEGER MKID(3), ID

      DOUBLE PRECISION DISP, VALUE(1)

      LOGICAL ERRFLG

 

C---- ASSIGN IMPACT PARAMETERS

      MKID(1) = INT(UPAR(1))

      MKID(2) = INT(UPAR(2))

      MKID(3) = INT(UPAR(3))

      ID = INT(UPAR(4))

 

C---- CALL AUXILIARY SUBROUTINES FOR CALCULATIONS

      CALL SYSFNC('DX', MKID, 3, DISP, ERRFLG)

      CALL RD_AKISPL(DISP, 0, ID, 0, VALUE(1), ERRFLG)

 

C---- ASSIGN THE RETURNED VALUE

      RESULT = VALUE(1)

 

      RETURN

      END