4.8.3.5. ERRMES
Language type |
Subroutine |
FORTRAN |
call errmes(errflg,’Devided by zero’,id,’Contact’) |
C/C++ |
errmes(errflg, “Devided by zero”, id, “Contact”) |
Variable Name |
Size |
Description |
errflg |
int |
The input variable, if errflg is set with zero, the pre-defined message is printed in message file and simulation is stopped. |
ErrorString |
char[80] |
The input variable, The array size must be 80 byte. The message to identify the type of error.This information is released as below format. ‘USER ERROR MESSAGE : #’ |
id |
int |
The input variable, This ID is user defined index to identify message. This information is released as below format. ‘USER ID = #’ |
command |
char[512] |
The input variable, Keyword to identify the type of entity. |
Note
If the user use not ERRMES but STOP or EXIT function, RecurDyn/Modeler process is simultaneously terminated.
If the value of errflg is false, RecurDyn/Solver processor automatically is stopped with a specified error message.
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
#include "stdafx.h"
#include "DllFunc.h"
ERRMSG_API void __cdecl axial_force
(double time, double upar[], int npar, int jflag, int iflag, double* result)
{
using namespace rd_syscall;
// Parameter Information
// time : Simulation time of RD/Solver. (Input)
// upar : Parameters defined by user. (Input)
// npar : Number of user parameters. (Input)
// jflag : When RD/Solver evaluates a Jacobian, the flag is true. (Input)
// iflag : When RD/Solver initializes arrays, the flag is true. (Input)
// result : Returned axial force or torque value. (Output)
// User Statement
// Local Variable Definition
double a,dist;
int mkid[2];
int errflg;
// Assign Impact Parameters
errflg = TRUE;
mkid[0] = (int) upar[0];
mkid[1] = (int) upar[1];
// call the auxiliary subroutine for calculation
sysfnc("DZ",mkid,2,&dist,&errflg);
errmes(errflg,"SYSFNC_DX",1,"CONTACT");
if(dist == 0.0 {
errflg = FALSE;
}
else{
A = 100.0 / dist;
}
errmes(errflg,"275",275,"275275275");
//Assign the Returned Value
*result = dist;
}