4.8.3.94. PRINTMSG

The PRINTMSG subroutine prints some messages during analysis to the Output Window.

Table 4.233 Function Name

Language type

Subroutine

FORTRAN

CALL PRINTMSG(sName, nName)

C/C++

printmsg(sName , nName)

Table 4.234 Parameter information

Variable Name

Size

Description

sName

char

The input variable, this string value is printed in output window.

nName

int

The input variable, the nName have to be set with the size of string.

Listing 4.102 Fortran code for PRINTMSG
 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
 C     upar: Parameters defined by user
 C     npar: Number of user parameters
 C     jflag: When RD/Solver evaluates a Jacobian, the flag is true.
 C     iflag: When RD/Solver initializes arrays, the flag is true.
 C     result: Returned value

       DOUBLE PRECISION TIME, UPAR(*)
       INTEGER NPAR
       LOGICAL JFLAG, IFLAG
       DOUBLE PRECISION RESULT[REFERENCE]
       CHARACTER(len=256) messageString;

 C---- USER STATEMENT

 C---- LOCAL VARIABLE DEFINITIONS
       INTEGER MKID(3), ID, OPENFILE(1), ivar
       DOUBLE PRECISION DISP, VALUE(1)
       LOGICAL ERRFLG, REPFLG

 C---- ASSIGN IMPACT PARAMETERS
       MKID(1) = INT(UPAR(1))
       MKID(2) = INT(UPAR(2))
       MKID(3) = INT(UPAR(3))
       ID = INT(UPAR(4))


 C---- CALL AUXILIARY SUBROUTINES FOR CALCULATIONS
       CALL SYSFNC('DX', MKID, 3, DISP, ERRFLG)
       CALL RD_AKISPL(DISP, 0, ID, 0, VALUE(1), ERRFLG)

 C---- ASSIGN THE RETURNED VALUE
       RESULT = VALUE(1)

 C---- WRITE RESULTS IN THE OUTPUT WINDOW
       WRITE(messageString,*) 'Result = ',RESULT
       CALL PRINTMSG(messageString//char(0),len(trim(messageString)))

       RETURN
       END
Listing 4.103 C/C++ code for PRINTMSG
 #include "stdafx.h"
 #include "DllFunc.h"

 #include <stdio.h>

 Test_USUB_axial_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
   //   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 arrays, the flag is true.
   //   result: Returned value

   // User statement
   // Local Variable Definition
   int mkid[3], errflg, akispl_id;
   double disp, value[3];
   char messageString[256];


   // Assign Impact Parameters
   mkid[0] = (int) upar[0];
   mkid[1] = (int) upar[1];
   mkid[2] = (int) upar[2];
   akispl_id = (int) upar[3];

   // Call the Auxiliary subroutines for Calculation
   sysfnc("DX", mkid, 3, &disp, &errflg);
   rd_akispl(disp, 0, akispl_id, 0, value, &errflg);

   // Assign the Returned Value
   *result = value[0];

   // Write results in the Output window
   sprintf(messageString, "Result = %f", *result);
   printmsg(messageString, strlen(messageString));

 }