The SAVSUB restart subroutine allows you to store any information needed to later restart user-written subroutines. Adams Solver calls SAVSUB during a SAVE command to write user data. The RELSUB restart subroutine can then read the data during a RELOAD command.
SAVSUB and RELSUB are optional. You only need them if you want to use 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; Savsub 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 SAVSUB(iunit, errflg)
Input Arguments
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. You may store data in the save file by writing it to this unit with an unformatted FORTRAN WRITE statement. |
Output Argument
errflg | A logical variable that indicates to Adams Solver that an error has occurred while saving 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 might 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 SAVSUB is shown next. The comments describe how the subroutine works.
SUBROUTINE SAVSUB(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 Write out the information which appears in the COMMON
C blocks, through which this routine shares information
C with other user-written subroutines.
C
WRITE (IUNIT) ...
C
RETURN
END
Example
For an example of this subroutine, see
savsub.f.