4.8.3.91. LINSPL
Language type |
Subroutine |
FORTRAN |
call rd_linspl(xval, zval, identity, order, array, errflg) or linspl(xval, zval, identity, order, array, errflg) |
C/C++ |
rd_linspl(xval, zval, identity, order, &array[0], &errflg) or linspl(xval, zval, identity, order, &array[0], &errflg) |
Variable Name |
Size |
Description |
xval |
double |
An input variable for the LINSPL function.
|
zval |
double |
An input variable for the LINSPL function.
|
identity |
int |
The id of spline. |
order |
int |
The interpolation method for the functions (return the value if 0, return calculation for 1st order differential equation if 1)
|
array |
double |
|
error |
logical/int |
If an error is encountered in invoking Predefined subroutine, this variable becomes true. This variable must be declared as a logical variable. |
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)
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_LINSPL to get the result of spline
if (iflagTest) then
call RD_LINSPL(time,0,splineID,0,result_order0(1),ERRFLG)
errorID = 1000
call ERRMES(ERRFLG,'Error : order 0',errorID,'LINSPL')
call RD_LINSPL(time,0,splineID,1,result_order1(1),ERRFLG)
errorID = 1001
call ERRMES(ERRFLG,'Error : order 1',errorID,'LINSPL')
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)
endif
else
call RD_LINSPL(time,0,splineID,iorder,result_order(1),ERRFLG)
errorID = 2000
call ERRMES(ERRFLG,'Error : order',errorID,'LINSPL')
C------- Assign the returned value to User Subroutine
RESULT = result_order(1)
endif
RETURN
END
#include "stdafx.h"
#include "DllFunc.h"
Linspl_C_API void __cdecl motion_usub
(double time, double upar[], int npar, int iord, 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)
// iord : Integrator order. (Input)
// iflag : When RD/Solver initializes arrays, the flag is true. (Input)
// result : Returned value. (Output)
// User Statement
// Local Variable Definition
double result_order0 = 0.0;
double result_order1 = 0.0;
int splineID;
int iorder = 0;
int iflagTest = 0;
int ERRFLG = 0;
int errorID = 0;
// Assign Parameters
splineID = (int)upar[0];
iorder = (int)upar[1];
iflagTest = (int)upar[2];
// Call RD_LINSPL to collect information for calculations
if (iflagTest)
{
rd_linspl(time,0,splineID,0,&result_order0,&ERRFLG);
errorID = 1000;
errmes(ERRFLG,"Error : order 0",errorID,"LINSPL");
rd_linspl(time,0,splineID,1,&result_order1,&ERRFLG);
errorID = 1001;
errmes(ERRFLG,"Error : order 1",errorID,"LINSPL");
// Assign the returned value to User Subroutine
if (iorder == 0)
{
*result = result_order0;
}
else if (iorder == 1)
{
*result = result_order1;
}
}
else
{
// Assign the returned value to User Subroutine
rd_linspl(time,0,splineID,iorder,result,&ERRFLG);
errorID = 2000;
errmes(ERRFLG,"Error : order",errorID,"LINSPL");
}
}