FORTRAN example for motion user subroutine

 

C---- SUB. MOTION_USUB

      SUBROUTINE MOTION_USUB

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

C---- TO EXPORT * SUBROUTINE

      !DEC$ ATTRIBUTES DLLEXPORT,C::MOTION_USUB

 

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     IORD   : Integrator order. (Input)

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

C     RESULT : Returned value. (Output)

 

      DOUBLE PRECISION TIME, UPAR(*)

      INTEGER NPAR, IORD

      LOGICAL IFLAG

      DOUBLE PRECISION RESULT[REFERENCE]

 

C---- USER STATEMENT

      DOUBLE PRECISION SHIFT, OMEGA

      DOUBLE PRECISION VALUE

      DOUBLE PRECISION COEF(3)

      LOGICAL ERRFLG

 

      SHIFT = UPAR(1)

      OMEGA = UPAR(2)

      COEF(1) = UPAR(3)

      COEF(2) = UPAR(4)

      COEF(3) = UPAR(5)

 

      CALL RD_FORCOS(TIME, SHIFT, OMEGA, COEF, 3, IORD, VALUE, ERRFLG)

 

      RESULT = VALUE

 

      RETURN

      END