63 INTEGER,
PARAMETER :: NLEVELS_MAX = 50, &
64 NBUCKETS_MAX = 10000, &
67 INTEGER,
PRIVATE :: nPoints
69 INTEGER,
DIMENSION(:),
ALLOCATABLE :: pointList
70 INTEGER,
DIMENSION(:,:),
ALLOCATABLE :: tree
72 REAL(RFREAL),
DIMENSION(:),
ALLOCATABLE :: pointXyz
88 INTEGER,
INTENT(IN) :: ndatapoints
91 INTEGER :: errorflag,ip
94 'RFLU_ModSplitTree.F90')
100 npoints = ndatapoints
106 ALLOCATE(tree(7,nbuckets_max),stat=errorflag)
107 global%error = errorflag
108 IF ( global%error /= err_none )
THEN
109 CALL
errorstop(global,err_allocate,__line__)
112 ALLOCATE(pointlist(npoints),stat=errorflag)
113 global%error = errorflag
114 IF ( global%error /= err_none )
THEN
115 CALL
errorstop(global,err_allocate,__line__)
118 ALLOCATE(pointxyz(npoints),stat=errorflag)
119 global%error = errorflag
120 IF ( global%error /= err_none )
THEN
121 CALL
errorstop(global,err_allocate,__line__)
146 INTEGER :: errorflag,ibranch1,ibranch2,ibucket,ibucketlast,ipl,ipm,ipg, &
147 isplitdir,nbuckets,nlevels
149 REAL(RFREAL),
INTENT(IN) :: xyz(3,npoints)
157 'RFLU_ModSplitTree.F90')
167 tree(2,ibucket) = npoints
168 tree(3,ibucket) = npoints
169 tree(4,ibucket) = isplitdir
176 isplitdir = isplitdir + 1
177 IF ( isplitdir > 3 )
THEN
187 IF ( tree(3,ibucket) > npoints_max )
THEN
191 IF ( nbuckets > nbuckets_max-2 )
THEN
198 DO ipg = tree(1,ibucket),tree(2,ibucket)
200 pointxyz(ipl) = xyz(isplitdir,pointlist(ipg))
204 pointlist(tree(1,ibucket):tree(2,ibucket)), &
207 ipm = tree(3,ibucket)/2 + 1
211 tree(5,ibucket) = pointlist(ipm)
213 ibranch1 = ibucket + 1
214 ibranch2 = ibucket + 2
216 tree(6,ibucket) = ibranch1
217 tree(7,ibucket) = ibranch2
221 nbuckets = nbuckets + 2
223 tree(1,ibranch1) = tree(1,ibucket)
224 tree(2,ibranch1) = ipm - 1
225 tree(3,ibranch1) = tree(2,ibranch1) - tree(1,ibranch1) + 1
226 tree(4,ibranch1) = isplitdir
228 tree(1,ibranch2) = ipm
229 tree(2,ibranch2) = tree(3,ibucket)
230 tree(3,ibranch2) = tree(2,ibranch2) - tree(1,ibranch2) + 1
231 tree(4,ibranch2) = tree(4,ibranch1)
236 IF ( ibucket < nbuckets )
THEN
237 IF ( ibucket /= ibucketlast )
THEN
238 ibucket = ibucket + 1
240 ibucketlast = nbuckets
250 IF ( nlevels < nlevels_max )
THEN
251 nlevels = nlevels + 1
252 ibucket = ibucket + 1
258 WRITE(*,*) nlevels,nbuckets
261 WRITE(*,*) ipl,tree(1:7,ipl)
281 'RFLU_ModSplitTree.F90')
283 DEALLOCATE(tree,stat=errorflag)
284 global%error = errorflag
285 IF ( global%error /= err_none )
THEN
286 CALL
errorstop(global,err_deallocate,__line__)
289 DEALLOCATE(pointlist,stat=errorflag)
290 global%error = errorflag
291 IF ( global%error /= err_none )
THEN
292 CALL
errorstop(global,err_deallocate,__line__)
295 DEALLOCATE(pointxyz,stat=errorflag)
296 global%error = errorflag
297 IF ( global%error /= err_none )
THEN
298 CALL
errorstop(global,err_deallocate,__line__)
subroutine registerfunction(global, funName, fileName)
subroutine, public rflu_destroysplittree(global)
subroutine, public rflu_buildsplittree(global, xyz)
subroutine, public rflu_createsplittree(global, nDataPoints)
subroutine quicksortrfrealinteger(a, b, n)
subroutine errorstop(global, errorCode, errorLine, addMessage)
subroutine deregisterfunction(global)