)      SUBROUTINE GETCOR (NWDS,IREF,KREF1)1C_TITLE  GETCOR  Dynamic core allocation routine.C_ARGUMENTS8	INTEGER NWDS      ![I] Number of words to be allocated.4	INTEGER*2 IREF(1) ![I] Reference array from caller.9	INTEGER KREF1     ![I] Index of memory relative to IREF.GC_DESCRIPTION  The subroutine GETCOR allocates INTEGER*2 virtual memoryKC dynamically.  Kref1 will be the index of memory relative to IREF, or 0 ifCC the memory could not be obtained (insufficient virtual memory).  )C  To get memory for use in a subroutine: C  if (kref1.eq.0) go to <error>"C  call subr(iref(kref1),nwds,...)   C   end C   subroutine subr(ia,nwds,...)C   integer*2 ia(nwds):C   [refer to memory in usual way as elements of array ia]
C   returnC   endMC  to get and use memory in same the routine, compute the base index relativeC  to the fixed array:C   integer*2 iref(1) C   call getcor(nwds,iref,kref1)!C   if (kref1.eq.0) go to <error>AC   kref0=kref1-1  [refer to nth word of memory as iref(kref0+n)]C   to as iref(kref0+n)]CC_CALLS  LIB$GET_VM & LIB$FREE_VM system run-time library routines.KC_HISTORY  82Apr27 R.Mehlman UCLA computation of index, frecor entry added 	C 2/2/83.C_PAUSE!      IR = LIB$GET_VM(2*NWDS,LOC)      IF (.NOT.IR) GO TO 10$      KREF1 = (LOC - %LOC(IREF))/2+1      RETURN
 10   KREF1=0      RETURN        =CC_TITLE  FRECOR  Frees INTEGER*2 virtual memory dynamically.CC_ARGUMENTS@C	INTEGER NWDS       ![I] Number of INTEGER*2 words to be freed.6C	INTEGER*2 IREF(1)  ![I] Reference array from caller.;C	INTEGER KREF1      ![I] Index of memory relative to IREF.C       (as returned by GETCOR)
C DESCRIPTION%C Free N Integer*2 words dynamically.#CC_HISTORY  R.Mehlman  UCLA 83Feb02CC_END#      ENTRY FRECOR(NWDS,IREF,KREF1)$      LOC=(KREF1-1) * 2 + %LOC(IREF)"      IR=LIB$FREE_VM(2 * NWDS,LOC)      RETURN	      END