Storage Management Subroutines

This chapter provides you with information about the storage management subroutines. Before reading this chapter, read the section on storage allocation in "OSL Terms and Concepts". That will familiarize you with the terms and concepts used below.

The storage management subroutines, and what they do, are:


Saving and Restoring Model Information in Storage (EKKPSHS and EKKPOPS)

You may want to save the current settings of Nfirstfree and Nlastfree and then, after doing something that changed them, such as calling EKKCOPY, restore them to their saved settings. This can be done by "pushing" and "popping" the top reserved area of dspace with EKKPSHS and EKKPOPS.

EKKPSHS saves the status of dspace; for example (1-7000) and (9300-10000). When EKKPOPS is called, this information is restored.

For any matrices or arrays that were put in high storage after calling EKKPSHS but before calling EKKPOPS, EKKPOPS checks all arrays known to the library modules to see if the index to the starting element is in the freed area. If so, a message is issued and the index set to zero. These messages are useful debugging aids, but you may wish to switch them off in production mode using EKKMSET.

Following is an example that uses EKKPSHS, EKKPOPS, EKKNGET, and EKKCOPY taken from "Sample FORTRAN Program EXCOPY".

          .
          .
          .
C
C   Read model data from MPS file on unit 98.
      CALL EKKMPS(RTCOD,DSPACE,98,2,0)
C
C   Get copy of matrix stored by rows, print row starts,
C   and release space.
C   Print current storage map.
      CALL EKKSMAP(RTCOD,DSPACE)
C   "Push" current storage map.
      CALL EKKPSHS(RTCOD,DSPACE)
C   Make copy of matrix stored by rows.
      CALL EKKCOPY(RTCOD,DSPACE,3)
C   Get index control variables.
      CALL EKKNGET(RTCOD,DSPACE,OSLN,OSLNLN)
C   Get integer control variables.
      CALL EKKIGET(RTCOD,DSPACE,OSLI,OSLILN)
C   Write row starts.
      WRITE(6,8000)
8000  FORMAT (5X,'Row Number',5X,'Row Start')
      DO 100 I=NROWRC,NROWRC+INUMROWS-1
        WRITE(6,9000) I-NROWRC+1, MSPACE(I)
100   CONTINUE
9000  FORMAT (7X,I5,9X,I5)
C   Print current storage map.
      CALL EKKSMAP(RTCOD,DSPACE)
C   "Pop" storage map to release the space.
      CALL EKKPOPS(RTCOD,DSPACE)
C
C   Solve using the simplex method.
      CALL EKKSSLV(RTCOD,DSPACE,1,2)
          .
          .
          .


Reserving Some High Storage for Your Program (EKKHIS)

The library modules keep fixed-length arrays in high storage. You may also want to do this.

For an example of the use of EKKHIS with EKKQPAR see "Sample FORTRAN Program EXQPAR". The example shows a technique for dynamically allocating storage from dspace using EKKHIS. Some of the arrays created in this way are treated as integer arrays by the subroutine GETIN. When these arrays are passed back to EKKLMDL or EKKNMDL, error messages may be issued to indicate that the user's arrays overlap with dspace. These error messages can be ignored. 


Finding the Starting Indices of Data in Storage (EKKNGET)

EKKNGET provides a way of locating pieces of information in dspace, mspace, and cspace. Refer to the subroutine description "EKKNGET - Request Current Start Indices of OSL Information" for more information about what types of information can be referenced by EKKNGET.

For an example, refer to the example "Sample FORTRAN Program EXNGET"


Getting and Putting Model Information (EKKGTMI and EKKPTMI)

Control information is stored in common blocks. You may want to save all the current information using EKKPTMI. To restore it later, use EKKGTMI. EKKPTMI and EKKGTMI are particularly useful for swapping models. For example, if you have two models within an application, and model 1 is active, to switch to model 2 use the following code:

C      Save model 1 information.
       CALL EKKPTMI(RTCOD,DSPACE,1)
 
C      Restore model 2 information.
       CALL EKKGTMI(RTCOD,DSPACE,2)
 
C      Now model 2 is the current model.

If you have defined more than one model for your application, it is also possible to save the current model as a different model. For example, if model 1 is active, and you wish to save model 1 as model 3, use:

C      Save model 1 information as model 3.
       CALL EKKPTMI(RTCOD,DSPACE,3)
C      Model 1 is still the current model, but is also saved as model 3.
C      This causes an error message that says you are saving
C      model 1 as model 3.  This message can be ignored.

Note that this saves all the control variables, pointers, and other information for model 1 as model 3. However, the data (matrix, bounds, costs, and other arrays) are not copied. So, a change to the constraint matrix for model 1 in the example above would make the same change in model 3.

For an example of using EKKGTMI and EKKPTMI along with EKKPSHS, EKKPOPS, EKKGEMV, EKKINVT, EKKGES, and EKKCOL to implement the Dantzig-Wolfe Decomposition Algorithm, see "Sample FORTRAN Program EXDANWOL".


[ Top of Page | Previous Page | Next Page | Table of Contents ]