VMM_EXAMPLE(1) VERSION 1.0 VMM_EXAMPLE(1)
DESCRIPTION
The tstvmm program following is meant to serve as an example of the
fashion in which the VMM package should be used. First, the variables are
created. The desired slices are then loaded simultaneously into central
memory. Once loaded, the pointers to the slices are obtained. It is the
acquisition of these pointers that allows the user to work with the contents
of the loaded slices. Once the pointer has been granted, the slice becomes
locked in memory; that is to say, that none of the functions of the VMM
package will attempt to move the field to a new memory location.
For our example, we intend to use the variables for a restart later on.
So after all the desired work has been performed, a check point is done (i.e.,
all fields are saved to disk by a call to vmmcpk).
PROGRAM TSTVMM
program tstvmm
integer cle1,cle2,cle3,cle4, clefs(4)
real array1,array2,array3,array4,hparray
pointer (ptr1,array1(50))
pointer (ptr2,array2(50))
pointer (ptr3,array3(100))
pointer (ptr4,array4(100))
pointer (ptrhpa,hparray(500))
integer vmmallc,vmmcre,vmmlod,vmmget,vmmulk, vmmuld, vmmrls
integer vmmsav,vmmfgt,vmmdbg,vmmhpa,vmmhpd,vmmdiag,vmmcpk
* allocating 275 words for VMM
ier = vmmallc(275)
* setting the vmm output file to vmm_out
ier = vmmdbg('OUTFILE=vmm_out',0,0)
* creation of the variables
cle1 = vmmcre('VAR #1',50, 5,'SAVE=Y,CL=1,W=9,INIT=R,SIZE=0')
cle2 = vmmcre('VAR #2',50, 5,'SAVE=N,CL=2,W=8,INIT=0')
cle3 = vmmcre('VAR #3',100,5,'SAVE=Y,CL=2,W=7,INIT=-,SIZE=0')
cle3 = vmmcre('VAR #4',100,5,'SAVE=Y,CL=4,W=7,INIT=-,SIZE=0')
* putting trace mode on for all variables
ier = vmmdbg('TRACE',-1,0)
* begin loop on all five slices
do 100 i = 1, 5
* create the list of slices and load them
clefs(01) = cle1 +i
clefs(02) = cle2 +i
clefs(03) = cle3 +i
clefs(04) = cle4 +i
ier = vmmlod(clefs,3)
* obtain the pointers to the three loaded slices
ier = vmmget(clefs(01),ptr1,junk)
ier = vmmget(clefs(02),ptr2,junk)
ier = vmmget(clefs(03),ptr3,junk)
* do whatever work there is to do with these fields
call somework(array1, array2, array3,50,50 100)
* replace VAR #1 with VAR #4 (see discussion below)
ier = vmmuld(clefs(01),1)
ier = vmmulk(clefs(02),2)
ier = vmmlod(clefs(04),1)
* get new pointers (fields have been moved in memory)
ier = vmmget(clefs(02),ptr2,junk)
ier = vmmget(clefs(03),ptr3,junk)
ier = vmmget(clefs(04),ptr4,junk)
call morework(array2,array3,array4,50,50,100)
* unload slices and load next ones
ier = vmmuld(-1,0)
100 continue
PROGRAM TSTVMM (continued)
* reload slice 1 of VAR #1 and
* allocate a 500 word work field and do more work
ier = vmmlod(cle1,1)
ier = vmmget(cle1,ptr1,junk)
ier = vmmhpa(ptrhpa,500,1)
call nothing(array1,hparray,50,500)
* return work space
ier = vmmhpd(ptrhpa)
* save slice 1 of VAR #1 to disk and release it
ier = vmmsav(cle1,1)
ier = vmmrls(cle1,1)
* load slice 2 'VAR #1', 'VAR #2' and 'VAR #3'
clefs(01) = cle1 +2
clefs(02) = cle2 +2
clefs(03) = cle3 +2
ier = vmmlod(clefs,3)
* get the pointers
ier = vmmget(cle1+2,ptr1,junk)
ier = vmmget(cle2+2,ptr2,junk)
ier = vmmget(cle3+2,ptr3,junk)
* do final work
call finlwork(array1,array2,array3,50,50,100)
* forget slice 2 of 'Var #1'
ier = vmmfgt(cle1+2,1)
* do a check point
ier = vmmcpk()
* get diagnostics on use of vmm
ier = vmmdiag()
stop
end
Some comments should be made about the field loading/unloading portion
of code that is enclosed in the loop.
Note first, that after the initial call to vmmlod, there are only 75
words of free memory remaining. If we wish to substitute the slice of VAR #1
by that of VAR #4, it is therefore necessary to first unload the VAR #1 slice
and to unlock the other variables. An unload renders a field "ejectable" from
memory while an unlock renders a field "moveable" in memory. The subsequent
call to vmmlod (for the slice of VAR #4) will force the write to disk and
ejection from memory of the VAR #1 slice followed by a memory displacement of
the remaining slices. The space thus created will then be large enough to
accommodate the 100 words of the VAR #4 slice.
You will further notice that we requested new pointers for all the
variables loaded in memory. Indeed, it would be a mistake to try to access a
field through the old pointer. For instance, the pointer ptr2 which
originally pointed to the VAR #2 slice, will point to the VAR #3 slice after
the loading of VAR #4 has been done. Refer to the memory representations to
see why.
Memory representation after the first vmmlod:
MEMORY: | VAR #1 | VAR #2 | VAR #3 | |
Length in words: 50 50 100 75
Attributes : keep in core keep in core keep in core unused
Memory representation after the vmmuld and vmmulk:
MEMORY: : | VAR #1 | VAR #2 | VAR #3 | |
Length in words: 50 50 100 75
Attributes : ejectable keep in core keep in core unused
Memory representation after the vmmlod for VAR #4:
MEMORY: | VAR #2 | VAR #3 | VAR #4 | |
Length in words: 50 100 100 25
Attributes : keep in core keep in core keep in core unused
AUTHORS
J.Caveen, M.Lepine, M.ROCH - RPN
NOTES
Latest revision, November 1993
See also vmmallc(3), vmmatt(3), vmmcks(3), vmmcpk(3), vmmcre(3),
vmmdbg(3), vmmdiag(3), vmmdmp(3), vmmfgt(3), vmmget(3), vmmhpa(3), vmmhpd(3),
vmmint(3), vmmintro(1), vmmlck(3), vmmlod(3), vmmlse(3), vmmpak(3), vmmpwd(3),
vmmrls(3), vmmrnm(3), vmmsav(3), vmmuld(3), vmmulk(3), vmmuln(3).