4.8.3.55. GET_RFLEX_NMODE

The GET_RFLEX_NMODE subroutine returns the number of selected modes. GET_RFLEX_ NMODE is an auxiliary subroutine for MODAL_FORCE or MODAL_FORCE_EXT.

Table 4.155 Function Name

Language type

Subroutine

FORTRAN

call get_rflex_nmode(ifbody, nmode, errflg)

C/C++

get_rflex_nmode(ifbody, &nmode, &errflg))

Table 4.156 Parameter information

Variable Name

Size

Description

ifbody

int

Sequential id of RFlex body defined in RecurDyn/Solver.

nomode

int

Number of selected modes.

Errflg

int

Error flag.
If the result of this argument is -1 (means TRUE in Fortran logical value), there is no error.
The others mean that there is an error.
Listing 4.76 Fortran code for GET_RFLEX_NMODE
 C---- SUB. MODAL_FORCE
       SUBROUTINE MODAL_FORCE
     &          (ID,TIME,UPAR,NPAR,IFBODY,POS,VEL,ACC,
     &           NMODE,NNODE,NMODALLOAD,MODALLOADS,
     &           JFLAG,IFLAG,RESULT)
       implicit none
 C---- TO EXPORT * SUBROUTINE
       !DEC$ ATTRIBUTES DLLEXPORT,C::MODAL_FORCE

 C---- INCLUDE SYSTEM CALL
       INCLUDE 'SYSCAL.F'
       INTEGER ID, NPAR, IFBODY
       DOUBLE PRECISION TIME, UPAR(*), POS(12), VEL(6), ACC(6)
       INTEGER NMODE, NNODE, NMODALLOAD
       DOUBLE PRECISION MODALLOADS(6+NMODE, NMODALLOAD)
       LOGICAL JFLAG, IFLAG
       DOUBLE PRECISION RESULT[REFERENCE](6+NMODE)

 C----USER STATEMENT
       INTEGER check_nmode,ierr
       call get_rflex_nmode(ifbody,check_nmode,ierr)
       call errmes(ierr,"MForce",ID,"hyc_usub_test");
       if(check_nmode.ne.nmode) then
         call errmes(0,"MForce",ID
           & "Selected number of mode is wrong!!!
           & There's an error!")
       endif
       do i=1, 6+nmode
         result(i)=0.0d0
       enddo

       RETURN
       END
Listing 4.77 C/C++ code for GET_RFLEX_NMODE
 #include "stdafx.h"
 #include "DllFunc.h"
 #include "math.h"

 using namespace rd_syscall;

 ModalForce_API void __cdecl modal_force
   (int id, double time, double upar[], int npar, int ifbody, double pos[12],
   double vel[6], double acc[6], int nmode, int nnode, int nModalLoad,
 double *ModalLoads, int jflag, int iflag, double *result)
 {
   // User Statement
   int check_nmode,ierr;

   // Check number of selected mode
   get_rflex_nmode(ifbody,&check_nmode,&ierr);
   errmes(ierr,"MForce",id,"hyc_usub_test");

   // The number of selected modes must be the same
   // between "get_rflex_nmode()" funtion and "nmode" argument of ModalForceUSUB.
   if(nmode!=check_nmode)
   {
       errmes(0,"MForce",id,"Selected number of mode is wrong!!! There's an error!");
   }

   for(int i=0;i<6+nmode;i++) result[i]=0.0;
 }