[go: up one dir, main page]

0% found this document useful (1 vote)
755 views13 pages

Subroutine MSC Adams

This document provides information about writing subroutines for Adams/Solver. Key points include: - Subroutines can be written in C or Fortran and are used to override standard functionality, implement complex logic, or interact with other software. - They require compiling with Intel Fortran and Microsoft Visual Studio compilers. - Subroutines should have a specific structure including elements to override like Adams/Help. - Utility subroutines are provided for common tasks like querying system states, performing mathematics functions, and file input/output. - Examples demonstrate a simple message subroutine, modifying an input, and using utilities like SYSFNC and IMPACT within a subroutine. -

Uploaded by

subit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
755 views13 pages

Subroutine MSC Adams

This document provides information about writing subroutines for Adams/Solver. Key points include: - Subroutines can be written in C or Fortran and are used to override standard functionality, implement complex logic, or interact with other software. - They require compiling with Intel Fortran and Microsoft Visual Studio compilers. - Subroutines should have a specific structure including elements to override like Adams/Help. - Utility subroutines are provided for common tasks like querying system states, performing mathematics functions, and file input/output. - Examples demonstrate a simple message subroutine, modifying an input, and using utilities like SYSFNC and IMPACT within a subroutine. -

Uploaded by

subit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

ADAMS/Solver

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.

• Discontinuous /or non smooth function- create trouble


for numerical integration
• Challenging to debug
• Adams/ solver function expressions will generally run
faster than a subroutine equivalent.
• Platform dependent.
Contents
• Setup
• Subroutine structure
• Utility subroutine
Setup: Compiling and Linking
• Must have the shell environment configured properly
– Intel 64 VS 2015 Environment
• Compiling
– Adams2017_2 cr-u n sfosub1.f sfosub2.f –n mylib.dll
• Linking
– “C:\Program Files
(x86)\IntelSWTools\compilers_and_libraries_2017.1.143\
windows\bin\ifortvars.bat” intel64
Structure: Elements to Override
• Adams/Help
Example 1: SFOSUB
• Simple example writes
message containing SFORCE
ID
– Data type
– Subroutine USRMES is used for
messaging
– The sfosub is called many
times during execution
– SUBROUTINE SFOSUB1 ( ID, TIME, PAR,
NPAR, DFLAG, IFLAG, VALUE )
– PARA()
– NPARA
Example2
• Modified to use input from the PAR() array
– Should check the number of inputs via NPAR.
Utility Subroutines
• Utility subroutine are
provided for common tasks
as:
– Querying system states
– Mathematics message
– Interfacing files input/output
Utilities: Querying system states
• Adams/solver provides two utilities that return model states(disp, vel, f,
ect.) at the current simulation time:
– SYSFNC()-return single system state
– SYSARY()-return an array of system states

– 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

You might also like