2D AMRCLAW
reclam.f
Go to the documentation of this file.
1 c
2 c -----------------------------------------------------------
3 c
4  subroutine reclam (index, nwords)
5 c
6 c ::::::::::::::::::::::::: RECLAM :::::::::::::::::::::::::::
7 c
8 c return of space. add to free list.
9 c iplace points to next item on free list with larger index than
10 c the item reclaiming, unless said item is greater then
11 c everything on the list.
12 c
13 c ::::::::::::::::::::::::::::::::::;:::::::::::::::::::::::::
14 c
15  use amr_module
16  implicit double precision (a-h,o-z)
17 
18 
19 !$OMP CRITICAL (MemMgmt)
20 
21 c
22  do 20 i = 1, lenf
23  iplace = i
24  if (lfree(i,1) .gt. index) go to 30
25  20 continue
26  write(outunit,902)
27  write(*,902)
28  902 format(' no insertion pointer into freelist. error stop')
29  stop
30 c
31 c check previous segment for merging
32 c
33  30 iprev = iplace - 1
34  if (lfree(iprev,1)+lfree(iprev,2) .lt. index) go to 40
35  lfree(iprev,2) = lfree(iprev,2) + nwords
36  go to 50
37 c
38 c check after segment - no previous merge case
39 c
40  40 nexti = index + nwords
41  if (lfree(iplace,1).ne. nexti) go to 70
42  lfree(iplace,1) = index
43  lfree(iplace,2) = lfree(iplace,2) + nwords
44  go to 99
45 c
46 c check following segment - yes previous merge case
47 c
48  50 nexti = index + nwords
49  if (lfree(iplace,1) .ne. nexti) go to 99
50 c
51 c forward merge as well, bump all down 1
52 c
53  lfree(iprev,2) = lfree(iprev,2)+lfree(iplace,2)
54  ipp1 = iplace + 1
55  do 60 i = ipp1, lenf
56  lfree(i-1,1) = lfree(i,1)
57  60 lfree(i-1,2) = lfree(i,2)
58  lenf = lenf - 1
59  go to 99
60 c
61 c no merges case - insert and bump future segments up to make room
62 c
63  70 if (lenf .eq. lfdim) go to 900
64  do 80 ii = iplace, lenf
65  i = lenf + 1 - ii + iplace
66  lfree(i,1) = lfree(i-1,1)
67  80 lfree(i,2) = lfree(i-1,2)
68  lenf = lenf + 1
69  lfree(iplace,1) = index
70  lfree(iplace,2) = nwords
71  go to 99
72 c
73  900 write(outunit,901) lfdim
74  write(*,901) lfdim
75  901 format(' free list full with ',i5,' items')
76  stop
77 c
78  99 lentot = lentot - nwords
79  if (sprint) write(outunit,100) nwords, index, lentot
80  100 format(' reclaiming ',i8,' words at loc. ',i8,' lentot ',i10)
81 
82 !$OMP END CRITICAL (MemMgmt)
83 
84  return
85  end
subroutine reclam(index, nwords)
Definition: reclam.f:4