FORTRAN example for AKISPL

 

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

C---- Local Variable Definition

      double precision result_order(1)

      double precision result_order0(1)

      double precision result_order1(1)

      double precision result_order2(1)

      integer splineID

      integer iorder

      integer iflagRest

      logical ERRFLG

      integer errorID

 

C---- Assign Parameter

      splineID = int(UPAR(1))

      iorder = int(UPAR(2))

      iflagTest = int(UPAR(3))

     

C---- Call RD_AKISPL to get the result of spline

      if (iflagTest) then

         call RD_AKISPL(time,0,splineID,0,result_order0(1),ERRFLG)

         errorID = 1000

         call ERRMES(ERRFLG,'Error : order 0',errorID,'AKISPL')

 

         call RD_AKISPL(time,0,splineID,1,result_order1(1),ERRFLG)

         errorID = 1001

         call ERRMES(ERRFLG,'Error : order 1',errorID,'AKISPL')

 

         call RD_AKISPL(time,0,splineID,2,result_order2(1),ERRFLG)

         errorID = 1002

         call ERRMES(ERRFLG,'Error : order 2',errorID,'AKISPL')

 

C------- Assign the returned value to User Subroutine

         if (iorder .eq. 0) then

            RESULT = result_order0(1)

         else if (iorder .eq. 1) then

            RESULT = result_order1(1)

         else if (ioerder .eq. 2) then

            RESULT = result_order2(1)

         endif

      else

         call RD_AKISPL(time,0,splineID,iorder,result_order(1),ERRFLG)

         errorID = 2000

         call ERRMES(ERRFLG,'Error : order',errorID,'AKISPL')

 

C------- Assign the returned value to User Subroutine

         RESULT = result_order(1)

      endif

 

      RETURN

      END