Debian Codegraph @

packages/seacas/libraries/supes/mem_mgr/mylong.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 MYLONG (NAME1, NEWLEN, NEWLOC, MYV, MYCHAR, MYLOC,
7 * MYCLOC, UCLOC, COFFST, OFFSET,
8 * DICT, DPOINT, LDICT, NNAMES, VOID, LVOID, NVOIDS,
9 * FILL, FDATA, CFILL, CFDATA, CHRNUM, CHRCOL, MAXSIZ, LASTER)
10
11 IMPLICIT INTEGER (A-Z)
12 INCLUDE 'params.inc'
13
14 C***********************************************************************
15
16 C NAME1 Name of the vector which changes length
17 CHARACTER*8 NAME1
18 C NEWLEN The new length of the vector (character units)
19 C NEWLOC The new location of the vector (returned)
20 C MYV Internal reference array
21 DIMENSION MYV(*)
22 C MYCHAR Internal reference array.
23 CHARACTER MYCHAR(*)
24 C MYLOC Address of internal array
25 C MYCLOC Address of internal character array.
26 C UCLOC Address of user's character array.
27 C COFFST Offset between internal numeric array and user's
28 C character array.
29 C OFFSET Address offset from internal array to user's array
30 C DICT Dictionary name table
31 C DPOINT Dictionary pointer table
32 C LDICT Dimension of dictionary
33 C NNAMES Number of names in the dictionary
34 CHARACTER DICT(LDICT,CHRCOL)
35 DIMENSION DPOINT(LDICT,CHRCOL,3), NNAMES(2)
36 C VOID Void table
37 C LVOID Dimension of void table
38 C NVOIDS Number of voids
39 DIMENSION VOID(LVOID,CHRCOL,2), NVOIDS(2)
40 C FILL Flag for data fill.
41 C FDATA Data for fill.
42 LOGICAL FILL
43 C CFILL Flag for character data fill.
44 C CFDATA Data for fill.
45 LOGICAL CFILL
46 CHARACTER*1 CFDATA
47 C CHRNUM Number of characters per numeric storage unit
48 C CHRCOL Number of column for character names.
49 C MAXSIZ Dimension of static character array.
50 C LASTER Error return
51
52 C***********************************************************************
53
54 INTLEN = (NEWLEN + CHRNUM - 1) / CHRNUM
55
56 C Get current location and length.
57
58 CALL MYFIND (NAME1, DICT, DPOINT, LDICT, NNAMES,
59 * CHRCOL, LASTER, ROW)
60 IF (LASTER .NE. SUCCESS) RETURN
61
62 C Save the current location of the array.
63
64 OLDLOC = DPOINT(ROW,CHRCOL,1)
65 OLDLEN = DPOINT(ROW,CHRCOL,2)
66 OLDCL = DPOINT(ROW,CHRCOL,3)
67 NEWLOC = (OLDLOC - 1) * CHRNUM + 1 + COFFST
68
69 memret = -998
70 memlen = intlen
71
72 C ... If the old length == 0, then we don't have a valid pointer.
73 C Need to call malloc instead of realloc.
74 if (oldlen .eq. 0) then
75 memret = 0
76 if (memlen .gt. 0) then
77 call exmemy(memlen, newadr, memret)
78 end if
79 else
80
81 C ... Passing a size of 0 to realloc (via exmemy) is the
82 C same as a 'free' which invalidates the pointer.
83 C Supes wants the pointer to stay valid, so instead
84 C we request a space of '1' to maintain a valid pointer.
85 if (intlen .eq. 0) then
86 memlen = 1
87 end if
88
89 if (chrcol .eq. 1) then
90 newadr = oldloc+myloc-1
91 else
92 newadr = oldloc+mycloc-1
93 end if
94
95 call exmemy(-memlen, newadr, memret)
96 end if
97
98 if (memret .lt. 0 .or. memret .gt. memlen) then
99 write (*,*) 'ERROR in mylong ', memret, memlen
100 laster = ilblk
101 return
102 end if
103
104 IF (LASTER .NE. SUCCESS) RETURN
105
106 if (chrcol .eq. 1) then
107 DPOINT(ROW,CHRCOL,1) = newadr+1-myloc
108 else
109 DPOINT(ROW,CHRCOL,1) = newadr+1-mycloc
110 end if
111 NEWLOC = (DPOINT(ROW,CHRCOL,1) - 1) * CHRNUM + 1 + COFFST
112 DPOINT(ROW,CHRCOL,2) = INTLEN
113 DPOINT(ROW,CHRCOL,3) = NEWLEN
114
115 C Perform data fill if appropriate.
116
117 IF (CFILL) THEN
118 I1 = NEWLOC + UCLOC - MYCLOC + OLDCL
119 I2 = I1 + NEWLEN - OLDCL - 1
120 DO 130 I = I1, I2
121 MYCHAR(I) = CFDATA
122 130 CONTINUE
123 END IF
124
125 RETURN
126 END