Escolar Documentos
Profissional Documentos
Cultura Documentos
Subroutines
Shubhakant Swain
CSM Software
Adams/solver subroutines
• Subroutine can be written in C or Fortran.
• Intel Fortran and Microsoft Visual Studio are required
• Version
– Adams_2017_2 cr-u n
• Linking of compilers
– Ifort
– Cl
When to use and not to use
subroutines
• Override the standard functionality in ADAMS/Solver
• Implement complex logic
• Incorporating new code
• Interact with other software or complex data files.
– DX,DY,DZ,DM
– VX,VY,VZ,VR
– FX,FY,FZ,FM
– BUSH,DIF,BEAM
Example: to determine the velocity of marker 33 w.r.t marker 42 in marker 42’s
coordinate reference
IPAR(1)=33
IPAR(2)=42
IPAR(3)=42
NSIZE=3
Call SYSFNC(‘vy’, IPAR, NSIZE, VEL_Y, ERRFLG)
Utilities: Mathematics
• ADAMS/Solver function expression can be invoked in
subroutine
– STEP(),STEP5()
– IMPACT(),BISTOP()
• Example
– CALL STEP5(x,x0,h0,x1,iord,value,errflg)
– Iord
• 0->
• 1-> 1st time derivative
• 2->2nd time derivative
– Value: return
– Errflg : error flag
Example 3 SFOSUB with Utilities
• Sforce implements an IMPACT() function
– Inputs for PAR()
– SYSFNC call
– Return force value
• Example demonstration
Cautions: General
• Include comments in your source code for future
reference
• Produce smooth output
• Extra cautious regarding divide by zero and other
runtime error
• IMPLICIT NONE for Fortran code. Error are found
during compilation.
• IORD
• IF(),MOD() are discontinuous
• Try avoiding flags