The RELSUB restart subroutine allows you to reload any information needed to restart user-written subroutines. Adams Solver calls SAVSUB during a SAVE command to write user data. RELSUB can then read the data during a RELOAD command.
SAVSUB and RELSUB are optional. You only need them if you want the SAVE and RELOAD commands to save and reload user data, in addition to internal Adams Solver data.
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; Relsub 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
Calling Sequence
SUBROUTINE RELSUB(iunit, errflg)
Input Argument
iunit | An integer variable that contains the FORTRAN IO unit of the Adams Solver save file. Adams Solver opens the save file as sequential and unformatted. If SAVSUB has written data to the save file, the RELSUB may read it from this unit with an unformatted FORTRAN READ statement. |
Output Argument
errflg | A logical variable that indicates to Adams Solver that an error has occurred while reading user data. If you set errflg to true, Adams Solver writes an error message to the screen and to the message file. |
Tip: | The most straightforward way to reinitialize user-written subroutines may be to collect the necessary variables in a COMMON block, use SAVSUB to write them to the save file, and RELSUB to read them back from the save file. |
Caution: | RELSUB must read data from the save file in the same order in which SAVSUB wrote the data. |
Structure
A sample structure for RELSUB is shown next. The comments describe how the subroutine works.
SUBROUTINE RELSUB(IUNIT, ERRFLG)
C
C === Type and dimension statements ===================
C
C --- External variable definitions -------------------
C
INTEGER IUNIT
LOGICAL ERRFLG
C
C IUNIT FORTRAN IO unit attached to Save File
C ERRLFG used to signal problems back to ADAMS
C
C --- COMMON Blocks -----------------------------------
C
COMMON ...
C
C === Executable code =================================
C
C Read in the information which appears in the COMMON
C blocks, through which this routine shares information
C with other user-written subroutines.
C
READ (IUNIT) ...
C
RETURN
END
Example
For an example of this subroutine, see
relsub.f.