4.8.3.96. RD_SYSTEM
The RD_SYSTEM subroutine returns whether the analysis has been converged in the current step.
Language type |
Subroutine |
FORTRAN |
call rd_system(repflg) |
C/C++ |
rd_system(&repflg) |
Variable Name |
Size |
Description |
repflag |
int |
The output variable, when convergence of analysis is reached at every step, this flag is set. |
Note
If the user uses the RD_SYSTEM function, the user can write a result computed with successful solutions at each time.
If RecurDyn/Solver processor enters the reporting stage, the value of repflg is one, or not, the value is zero.
Using GETCONVERGENCEFLAG instead of RD_SYSTEM, the result is the same.
C---- SUB. REQUEST
SUBROUTINE REQUEST_USUB
& (TIME,UPAR,NPAR,IFLAG,RESULT)
C---- TO EXPORT * SUBROUTINE
!DEC$ ATTRIBUTES DLLEXPORT,C::REQUEST_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 IFLAG : When RD/Solver initializes arrays, the flag is true. (Input)
C RESULT : Returned values. (Output, Size : 8)
DOUBLE PRECISION TIME, UPAR(*)
INTEGER NPAR
LOGICAL IFLAG
DOUBLE PRECISION RESULT[REFERENCE](8)
C---- USER STATEMENT
DOUBLE PRECISION VY
INTEGER ID(2),REPFLG
LOGICAL ERRFLG
ID(1) = INT(UPAR(1))
ID(2) = INT(UPAR(2))
CALL SYSFNC('VY',ID,2,VY,ERRFLG)
CALL RE_SYSTEM(REPFLG)
WRITE(10000,*) '*TIME=',TIME
IF(REPFLG .EQ. 1) WRITE(10000,*) '*VY=',VY
DO I= 1, 8
RESULT(I) = 0.0D0
ENDDO
RESULT(1) = VY
RETURN
END
#include "stdafx.h"
#include "DllFunc.h"
#include <stdio.h>
FILE *fGlobal[100];
int iInitialize;
int iWrite;
int ifclose;
RD_SYSTEM_API void __cdecl request_usub
(double time, double upar[], int npar, int iflag, double result[8])
{
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)
// iflag : When RD/Solver initializes arrays, the flag is true. (Input)
// result : Returned values. (Output, Size : 8)
// User Statement
// User Declared Variables
double VY, Endtime;
int ID[2],REPFLAG,ERRFLG;
int i,id;
// Assign User parameters into the Variables
ID[0] = (int)upar[0];
ID[1] = (int)upar[1];
id = 1;
Endtime = 5.0;
// Measure the Velocity between Marker1 and Marker2
sysfnc("VY",ID,2,&VYW,&ERRFLG);
//Initialize
if( iInitialize == 0 ){
for(i=0;i<100;i++) fGlobal[i] = NULL;
CString str;
str.Format("output&d.txt",id);
fGlobal[100] = fopen(str,"w+");
iInitialize = 1;
iWrite = 1;
}
re_system(&REPFLG);
if(REPFLG == 1 && iWrite == 1) {
fprintf(fGlobal[100], "Time = %8.5f ",time);
fprintf(fGlobal[100], "VY = %8.5f \n",VY);
}
//close file
if( time >= Endtime && iFclose == 0 ){
fclose(fGlobal[100]);
iFclose = 1;
iWrite = 0;
}
}