FORTRAN example for ERRMES

 

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

      DOUBLE PRECISION A, DIST

      INTEGER MKID(2)

      LOGICAL ERRFLG

     

C---- INITIALIZE

      ERRFLG = .TURE.

C---- ASSIGN IMPACT PARAMETERS

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

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

C---- CALL AUXILIARY SUBROUTINE FOR CALCULATIONS

      CALL SYSFNC('DZ',MKID,2,DIST,ERRFLG)

      CALL ERRMES(ERRFLG,'SYSFNC_DX',1,'CONTACT')

      IF( DIST .EQ. 0.0D0 ) THEN

         ERRFLG = .FALSE.

      ELSE

         A = 100.0D0 / DIST

      ENDIF

      CALL ERRMES(ERRFLG,'DEVIDED BY ZERO',1,'CONTACT')

C---- ASSIGN THE RETURNED VALUE

      RESULT = DIST

 

      RETURN

      END