CONSUB

The CONSUB driver subroutine can be used to control an Adams simulation from within a user subroutine. Interactively issuing the CONTROL command (C++ or FORTRAN) invokes CONSUB. Other user-written subroutines cannot call CONSUB.
 
Note:  
Use mixed case names for the Adams subroutine names when using the C style interface. For the default subroutine name capitalize the first letter and have the remaining letters lower case; Consub for example. Doing this ensures that Adams Solver correctly distinguishes a C style subroutine from Fortran and calls with the appropriate interface.

Use

Corresponding Command

CONTROL/ [FUNCTION=USER(r1[,...,r30])[/]]
[[ ]] Optionally select an item combination

Calling Sequence

SUBROUTINE CONSUB (par, npar)

Input Arguments

 
npar
An integer variable that indicates the number of constants specified in the parenthetical list of the USER keyword. The primary purpose of npar is to provide CONSUB with the number of values stored in the par array.
par
A double-precision array of constants taken in order from the parenthetical list in the USER keyword CONTROL command.

Extended Definition

Adams Solver passes the parameters in the CONTROL statement FUNCTION=USER() argument as an array of real numbers to the user-written subroutine CONSUB. From CONSUB, any utility subroutines such as SYSARY, SYSFNC, or AKISPL can be called.
The MODIFY utility subroutine can be called to change an Adams Solver statement just as it would be done interactively.
The ANALYS utility subroutine can be called to invoke one of the Adams Solver analysis types.
The DATOUT utility subroutine can be called to process output from the Adams Solver simulation(s).
When execution of CONSUB stops, Adams Solver prompts you for another command.
 
Caution:  
When program control passes to CONSUB, automatic generation of output stops. If you want to create output, call the DATOUT utility subroutine.

FORTRAN - Prototype

A sample structure for CONSUB is shown next. The comments explain how the subroutine works.
SUBROUTINE CONSUB ( PAR, NPAR )
C
C === Type and dimension statements ==================
C
C
C - External variable definitions ---------
C      INTEGER                     NPAR      DOUBLE PRECISION            PAR( * )
C
C PAR       Array containing passed parameters
C NPAR     Number of passed parameters
C
C - Local variable definitions -----------
C      ...
C
C === Executable code ================================
C
C - Your commands -----------------
C      ...
C      
RETURN      
END

C Style - Prototype

typedef void adams_c_CONSUB(const struct sAdamsControl* con);
/*
* CONTROL
*/
struct sAdamsControl
{
int NPAR;
const double* PAR;
};
 

Cautions

Calls to the utility functions SYSFNC and SYSARY are permitted from within a CONSUB. As long as the model is at a consistent state, calls to SYSFNC/SYSARY will return consistent values (correct values).
At the end of every dynamic, static, quasi-static, settle and linear simulations Adams Solver will set the model at a consistent state by solving the corresponding governing equations. After an initial condition displacements, all displacements are at a consistent state. After an initial condition velocities, all velocities and displacements are at a consistent state. After an initial conditions acceleration, all forces and reaction forces (due to the constraints in the model) will be at a consistent state.
However, you may issue simulation commands that can set the model temporarily at an inconsistent state. For example, the following commands modify the model topology and immediately make a call to a CONSUB:
SIM/DYN, END=1, STEPS=10
MARKER/99, QP=1,3.3,3.9
DEACTIVATE/JOINT, ID=8
CONTROL/FUNCTION=USER(55,5,99)
After the dynamic simulation is completed, the model is at a consistent state. The MARKER command and the DEACTIVATE will set the model temporarily at an inconsistent state; the model is being changed. The next simulation command, if any, will set the model back to a consistent state. Nevertheless, if the CONSUB above makes calls to SYSFNC and SYSARY before a simulation command, then the returned values are in general not consistent (incorrect). If the CONSUB makes calls to SYSFNC and SYSARY, users should explicitly issue a simulation command before making the calls to SYSFNC/SYSARY. For example:
SIM/DYN, END=1, STEPS=10
MARKER/99, QP=1,3.3,3.9
DEACTIVATE/JOINT, ID=8
SIM/INITIAL_CONDITIONS
CONTROL/FUNCTION=USER(55,5,99)
The initial conditions command will set the model at a consistent state. The initial conditions command is not required if an explicit simulation command follows before making the calls to SYSFNC/SYSARY within the consub subroutine.

Examples

For an example of this subroutine, see consub.f.