The source code for the user subroutines is very similar between Windows and Linux. The example axial force routine below shows the modifications for using the user subroutines for Linux. The included file is set to be SYSCAL_LN.H for C++ routines and is set to SYSCAL_LN.F for Fortran subroutines. There are also changes to the subroutine declaration statement, as shown in the example code.
//#include "stdafx.h"
//#include "DllFunc.h"
#include "SYSCAL_LN.H"
//C_API void __cdecl axial_force
extern "C" void 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
// upar: Parameters defined by user
// npar: Number of user parameters
// jflag: When RD/Solver evaluates a Jacobian, the flag is true.
// iflag: When RD/Solver initializes arraies, the flag is true.
// result: Returned value
// User statement
// Local Variable Definition
int mkid[3], errflg, akispl_id;
int usp3,usp4;
double usp2;
double disp, value[3];
// Assign Impact Parameters
mkid[0] = (int) upar[0];
mkid[1] = (int) upar[1];
mkid[2] = (int) upar[2];
akispl_id = (int) upar[3];
usp3 = 3;
usp2 = 0.0;
usp4 = 0;
// Call the Auxiliary subroutines for Calculation
// The argument of the function must be changed to Pointer.
sysfnc("DX", mkid, &usp3, &disp, &errflg);
rd_akispl(&disp, &usp2, &akispl_id, &usp4, value, &errflg);
// Assign the Returned Value
*result = value[0];
}
USUB Example
• USUB : <Linux Solver Install Dir>/USUB/
• SYSCAL_LN File : <Linux Solver Install Dir>/USUB/