FORTRAN example for rotational force user subroutine

 

C---- SUB. ROTATIONAL_FORCE

      SUBROUTINE ROTATIONAL_FORCE

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

C---- TO EXPORT * SUBROUTINE

      !DEC$ ATTRIBUTES DLLEXPORT,C::ROTATIONAL_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 value. (Output)

 

      DOUBLE PRECISION TIME, UPAR(*)

      INTEGER NPAR

      LOGICAL JFLAG, IFLAG

      DOUBLE PRECISION RESULT[REFERENCE](3)

 

C---- USER STATEMENT

C---- LOCAL VARIABLE DEFINITIONS

      INTEGER I

      INTEGER MINUS(3)

DOUBLE PRECISION PI

      DOUBLE PRECISION VALUE(3)

 

C---- ASSIGN IMPACT PARAMETERS

PI = DACOS(-1.0d0)

      MINUS(1) = UPAR(1)

      MINUS(2) = UPAR(2)

      MINUS(3) = UPAR(3)

 

DO I=1, 3

IF(MINUS(I) .NE. 0) THEN

VALUE(I) = -(((4*PI)**2)/3)**0.5;

ELSE

VALUE(I) = (((4*PI)**2)/3)**0.5;

 ENDIF

ENDDO

 

C---- ASSIGN THE RETURNED VALUE

      RESULT(1) = VALUE(1)

RESULT(2) = VALUE(2)

RESULT(3) = VALUE(3)

 

      RETURN

      END