Development and debugging user-written subroutines
This section provides information that is helpful during the development and testing of subroutines.
User written subroutines written in FORTRAN can use any text-editor. If linked into the TMG model through an include file specified within a preprocessor, then the source code file must have the following structure:
- The first subroutine in the file is
USER1
. -
The first line of the file must start with
SUBROUTINE USER1
.Make sure that there are exactly six spaces before the word
SUBROUTINE
. Alternately the file can start withFUNCTION
as long as theUSER1
routine appears later. - All other user routines must be included in the file.
It is a good idea to compile the routines separately before running the TMG model so that syntax errors can be resolved. This negates the possibility of having a run end because of a compiler error.
Debugging USER1 subroutine using Visual Studio
You can compile USER1
subroutine with the debugger attached. You must use:
- The
DEBUG_USER1=1
environment variable. - NX 10 or later version.
- Correct version of Visual Studio.
To debug, you need to start Simcenter3D/NX session with the debugger attached to the process. There are two USER1
debug modes:
- USERDLL, when attach to process called analyz.exe.
- T12.exe scheme, when attach to process called t12.exe.
You have to set any breakpoints to examine your code. This can either be an infinite loop or a pause.
The debugger lets you examine:
- The values stored in variables.
- The changes of the values.
- The execution path of your code.