Debian Codegraph @

packages/seacas/libraries/supes/mem_mgr/mymemy.f

raw
1 C Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6 SUBROUTINE MYMEMY( MEMREQ, LOCBLK, MEMRTN, MAXSIZ )
7 SAVE NUSED
8 DATA NUSED /0/
9
10 ************************************************************************
11
12 C FORTRAN EXTENSION LIBRARY - ANSI FORTRAN - USER INTERFACE ROUTINE
13
14 C DESCRIPTION:
15 C This routine requests the operating system to allocate or release
16 C numeric storage. A positive MEMREQ indicates a request for memory,
17 C while a negative MEMREQ indicates a release. All locations and
18 C sizes are measured in numeric storage units.
19
20 C In memory request mode, MEMRTN .LT. MEMREQ indicates an error.
21
22 C In memory release mode, MEMRTN .LE. -MEMREQ. Furthermore, memory
23 C must be released from the top down, i.e., LOCBLK must not change.
24
25 C This version actually allocates storage from a static pool, whose
26 C size is defined by the parameter MAXSIZ. If system dependent
27 C support for the function IXLNUM is not implemented, the PARAMETER
28 C and COMMON statements above must be duplicated in the caller.
29
30 C FORMAL PARAMETERS:
31 C MEMREQ INTEGER Number of numeric units
32 C LOCBLK INTEGER Location of memory block
33 C MEMRTN INTEGER Size of memory block at routine completion
34 C MAXSIZ INTEGER Size of character memory - dimension in
35 C MDINIT.
36
37 C SAVED VARIABLES:
38 C NUSED INTEGER Number of units dynamically allocated
39
40 ************************************************************************
41
42 IF ( MEMREQ .GE. 0 ) THEN
43
44 C Allocate storage -
45 LOCBLK = 1 + NUSED
46 MEMRTN = MIN( MAXSIZ-NUSED , MEMREQ )
47 NUSED = NUSED + MEMRTN
48 ELSE
49
50 MEMRTN = -MEMREQ
51 END IF
52
53 RETURN
54 END