UALLOC  - - Example



    ualloc.f is a file in the user directory that allows one to define named arrays for dynamic allocation out of FEAP's blank common memory management system.  To set up a user allocatable array one
merely needs to edit the file ualloc.f to include the new array name and update the number of user allocatable arrays.


    For instance to add the user allocatable arrays 'OANGL' and 'PANGL' to the program one needs to edit the file ualloc.f as follows:     To use the arrays that have been compiled into the program one uses the ualloc( ) logical function to allocate memory, resize memory, or delete memory.  This also involves the use of common blocks comblk.h and upointer.h.   To use the ualloc call you must specify both the name of the array and its numerical location in the list.  Specifically:     Ualloc takes 4 arguments.  The first is the numerical location of the user array in the list in ualloc.f, the second is the name of the array, the third is the desired length of the array, and the forth is the precision of the array ( 1 for integer and 2 for double precision real).  After the call to ualloc the pointer array up( ) will contain the correct pointers into the blank common.

    A example ualloc.f and example calls to ualloc are given below.


Source file:

c$Id: ualloc.f,v 1.1 1998/08/28 18:19:29 rlt Exp $
      logical function ualloc(num,name,length,precis)

c      * * F E A P * * A Finite Element Analysis Program

c....  Copyright (c) 1984-1998: Robert L. Taylor

c-----[--.----+----.----+----.-----------------------------------------]
c      Purpose: Define, delete, or resize a user dictionary entry.
c               Pointer defined for integer (single) and real
c               (double precision) arrays.

c               N.B. Currently limited to 200 names by dimension of
c               common blocks 'allotd','allotn','pointer','upointer'

c      Inputs:

c         num        - Entry number for array (see below)
c         name       - Name of array          (see below)
c         length     - Length of array defined: =0 for delete
c         precis     - Precision of array: 1 = integers; 2 = reals

c      Output:

c         up(num)    - Pointer to first word of array in blank common
c-----[--.----+----.----+----.-----------------------------------------]

      implicit  none

      include  'allotd.h'

      logical   usetmem
      character name*(*)
      integer   i, num,length,precis

c     Storage definitions for UALLOC variables

      integer   list
      parameter (list = 2)                  ! <--- Edit to increase list size

      character names(list)*5

      save

c     Define and store names

      data   (names(i),i=1,list)/

     &         'OANGL',                 ! <--- Edit to add name
     &         'PANGL'/                  ! <--- Edit to add name

c     Short description of variables

c              'OANGL',     !     1: Orthotropic angle with respect to x-axis   !<-- Example comment
c              'PANGL',      !     2: Orthotropic angle with respect to y-axis   !<-- Example comment

c     Do memory management operations

      ualloc = usetmem(list,names,num,name,length,precis)

      end


Example Calls to ualloc


      logical   errck,ualloc

      include  'upointer.h'
      include  'comblk.h'
 

      if(up(1).eq.0) then          ! <--- Example initial allocation of OANGL as double precision length numel
        errck =  ualloc(1,'OANGL',numel,2)
        if(.not.errck) write(*,*) 'UALLOC ERROR - OANGL'
      endif

      hr(up(1) + n - 1) = angle  !<--- Example setting of the n^th element of OANGL

       errck = ualloc(1,'OANGL',0,2) !<--- Example deletion of OANGL array (set size to zero)

      if(up(2).eq.0) then          ! <--- Example initial allocation of PANGL as integer length numel
        errck =  ualloc(2,'PANGL',numel,1)
        if(.not.errck) write(*,*) 'UALLOC ERROR - PANGL'
      endif

      mr(up(2) + n - 1) = pset  !<--- Example setting of the n^th element of PANGL

       errck = ualloc(2,'PANGL',numel-50,1) !<--- Example resize of PANGL array (set a new length)