[yt-svn] commit/yt: 8 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Jul 12 07:28:02 PDT 2014
8 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/bd07cd3da93b/
Changeset: bd07cd3da93b
Branch: yt-3.0
User: drudd
Date: 2014-07-11 16:53:46
Summary: Fixed Forthon compilation in setup.py for Forthon >= 0.8.13
Affected #: 1 file
diff -r c6b09204f3e728a7d3611ffc16a962ad037ddbee -r bd07cd3da93b00596101b78429be3da3d986aeec setup.py
--- a/setup.py
+++ b/setup.py
@@ -61,8 +61,8 @@
cwd = os.getcwd()
os.chdir(os.path.join(cwd, 'yt/utilities/kdtree'))
cmd = [Forthon_exe, "-F", "gfortran", "--compile_first",
- "fKD_source", "--no2underscores", "--fopt", "'-O3'", "fKD",
- "fKD_source.f90"]
+ "fKD_source", "--no2underscores", "--fopt", "'-O3'",
+ "-f", "fKD.f90", "fKD", "fKD_source.f90"]
subprocess.check_call(cmd, shell=False)
shutil.move(glob.glob('build/lib*/fKDpy.so')[0], os.getcwd())
os.chdir(cwd)
https://bitbucket.org/yt_analysis/yt/commits/35f73f4583e0/
Changeset: 35f73f4583e0
Branch: yt-3.0
User: drudd
Date: 2014-07-11 16:58:24
Summary: Remove Forthon kdTree test
Affected #: 1 file
diff -r bd07cd3da93b00596101b78429be3da3d986aeec -r 35f73f4583e00701dc9387342c11a6ec19571767 yt/utilities/tests/test_kdtrees.py
--- a/yt/utilities/tests/test_kdtrees.py
+++ b/yt/utilities/tests/test_kdtrees.py
@@ -15,50 +15,11 @@
from yt.testing import *
-try:
- from yt.utilities.kdtree.api import *
-except ImportError:
- mylog.debug("The Fortran kD-Tree did not import correctly.")
-
from yt.utilities.spatial import cKDTree
def setup():
pass
-def test_fortran_tree():
- r"""This test makes sure that the fortran kdtree is finding the correct
- nearest neighbors.
- """
- # Four points.
- try:
- fKD.pos = np.empty((3, 4), dtype='float64', order='F')
- except NameError:
- return
- # Make four points by hand that, in particular, will allow us to test
- # the periodicity of the kdtree.
- points = np.array([0.01, 0.5, 0.98, 0.99])
- fKD.pos[0, :] = points
- fKD.pos[1, :] = points
- fKD.pos[2, :] = points
- fKD.qv = np.empty(3, dtype='float64')
- fKD.dist = np.empty(4, dtype='float64')
- fKD.tags = np.empty(4, dtype='int64')
- fKD.nn = 4
- fKD.sort = True
- create_tree(0)
- # Now we check to make sure that we find the correct nearest neighbors,
- # which get stored in dist and tags.
- fKD.qv[:] = 0.999
- find_nn_nearest_neighbors()
- # Fix fortran counting.
- fKD.tags -= 1
- # Clean up before the tests.
- free_tree(0)
- # What the answers should be.
- dist = np.array([2.43e-04, 3.63e-04, 1.083e-03, 7.47003e-01])
- tags = np.array([3, 0, 2, 1], dtype='int64')
- assert_array_almost_equal(fKD.dist, dist)
- assert_array_equal(fKD.tags, tags)
def test_cython_tree():
r"""This test makes sure that the cython kdtree is finding the correct
https://bitbucket.org/yt_analysis/yt/commits/8ab106d762cf/
Changeset: 8ab106d762cf
Branch: yt-3.0
User: drudd
Date: 2014-07-11 16:58:56
Summary: Remove kdtree subpackage from setup
Affected #: 1 file
diff -r 35f73f4583e00701dc9387342c11a6ec19571767 -r 8ab106d762cf7aa9f07d299e4e440c4c8f924230 yt/utilities/setup.py
--- a/yt/utilities/setup.py
+++ b/yt/utilities/setup.py
@@ -154,7 +154,6 @@
config.add_subpackage("amr_kdtree")
config.add_subpackage("poster")
config.add_subpackage("answer_testing")
- config.add_subpackage("kdtree")
config.add_subpackage("spatial")
config.add_subpackage("grid_data_format")
config.add_subpackage("parallel_tools")
https://bitbucket.org/yt_analysis/yt/commits/560803d287f3/
Changeset: 560803d287f3
Branch: yt-3.0
User: drudd
Date: 2014-07-11 16:59:27
Summary: Remove Forthon and Fortran kDTree stuff from setup.py
Affected #: 9 files
diff -r 8ab106d762cf7aa9f07d299e4e440c4c8f924230 -r 560803d287f3e35963562d7ba1f0899e3a0e9f39 setup.py
--- a/setup.py
+++ b/setup.py
@@ -25,48 +25,6 @@
from distutils.core import Command
from distutils.spawn import find_executable
-def find_fortran_deps():
- return (find_executable("Forthon"),
- find_executable("gfortran"))
-
-class BuildForthon(Command):
-
- """Command for building Forthon modules"""
-
- description = "Build Forthon modules"
- user_options = []
-
- def initialize_options(self):
-
- """init options"""
-
- pass
-
- def finalize_options(self):
-
- """finalize options"""
-
- pass
-
- def run(self):
-
- """runner"""
- (Forthon_exe, gfortran_exe) = find_fortran_deps()
- if None in (Forthon_exe, gfortran_exe):
- sys.stderr.write(
- "fKDpy.so won't be built due to missing Forthon/gfortran\n"
- )
- return
-
- cwd = os.getcwd()
- os.chdir(os.path.join(cwd, 'yt/utilities/kdtree'))
- cmd = [Forthon_exe, "-F", "gfortran", "--compile_first",
- "fKD_source", "--no2underscores", "--fopt", "'-O3'",
- "-f", "fKD.f90", "fKD", "fKD_source.f90"]
- subprocess.check_call(cmd, shell=False)
- shutil.move(glob.glob('build/lib*/fKDpy.so')[0], os.getcwd())
- os.chdir(cwd)
-
REASON_FILES = []
REASON_DIRS = [
"",
@@ -197,17 +155,6 @@
build_src.build_src.run(self)
-class my_install_data(np_install_data.install_data):
- def run(self):
- (Forthon_exe, gfortran_exe) = find_fortran_deps()
- if None in (Forthon_exe, gfortran_exe):
- pass
- else:
- self.distribution.data_files.append(
- ('yt/utilities/kdtree', ['yt/utilities/kdtree/fKDpy.so'])
- )
- np_install_data.install_data.run(self)
-
class my_build_py(build_py):
def run(self):
# honor the --dry-run flag
@@ -277,8 +224,7 @@
configuration=configuration,
zip_safe=False,
data_files=REASON_FILES,
- cmdclass={'build_py': my_build_py, 'build_forthon': BuildForthon,
- 'build_src': my_build_src, 'install_data': my_install_data},
+ cmdclass={'build_py': my_build_py, 'build_src': my_build_src},
)
return
diff -r 8ab106d762cf7aa9f07d299e4e440c4c8f924230 -r 560803d287f3e35963562d7ba1f0899e3a0e9f39 yt/utilities/kdtree/LICENSE
--- a/yt/utilities/kdtree/LICENSE
+++ /dev/null
@@ -1,98 +0,0 @@
-
-The KDTREE2 software is licensed under the terms of the Academic Free
-Software License, listed herein. In addition, users of this software
-must give appropriate citation in relevant technical documentation or
-journal paper to the author, Matthew B. Kennel, Institute For
-Nonlinear Science, preferably via a reference to the www.arxiv.org
-repository of this document, {\tt www.arxiv.org e-print:
-physics/0408067}. This requirement will be deemed to be advisory and
-not mandatory as is necessary to permit the free inclusion of the
-present software with any software licensed under the terms of any
-version of the GNU General Public License, or GNU Library General
-Public License.
-
-
-Academic Free License
-Version 1.1
-
-This Academic Free License applies to any original work of authorship
-(the "Original Work") whose owner (the "Licensor") has placed the
-following notice immediately following the copyright notice for the
-Original Work: "Licensed under the Academic Free License version 1.1."
-
-Grant of License. Licensor hereby grants to any person obtaining a
-copy of the Original Work ("You") a world-wide, royalty-free,
-non-exclusive, perpetual, non-sublicenseable license (1) to use, copy,
-modify, merge, publish, perform, distribute and/or sell copies of the
-Original Work and derivative works thereof, and (2) under patent
-claims owned or controlled by the Licensor that are embodied in the
-Original Work as furnished by the Licensor, to make, use, sell and
-offer for sale the Original Work and derivative works thereof, subject
-to the following conditions.
-
-Right of Attribution. Redistributions of the Original Work must
-reproduce all copyright notices in the Original Work as furnished by
-the Licensor, both in the Original Work itself and in any
-documentation and/or other materials provided with the distribution of
-the Original Work in executable form.
-
-Exclusions from License Grant. Neither the names of Licensor, nor the
-names of any contributors to the Original Work, nor any of their
-trademarks or service marks, may be used to endorse or promote
-products derived from this Original Work without express prior written
-permission of the Licensor.
-
-WARRANTY AND DISCLAIMERS. LICENSOR WARRANTS THAT THE COPYRIGHT IN AND
-TO THE ORIGINAL WORK IS OWNED BY THE LICENSOR OR THAT THE ORIGINAL
-WORK IS DISTRIBUTED BY LICENSOR UNDER A VALID CURRENT LICENSE FROM THE
-COPYRIGHT OWNER. EXCEPT AS EXPRESSLY STATED IN THE IMMEDIATELY
-PRECEEDING SENTENCE, THE ORIGINAL WORK IS PROVIDED UNDER THIS LICENSE
-ON AN "AS IS" BASIS, WITHOUT WARRANTY, EITHER EXPRESS OR IMPLIED,
-INCLUDING, WITHOUT LIMITATION, THE WARRANTY OF NON-INFRINGEMENT AND
-WARRANTIES THAT THE ORIGINAL WORK IS MERCHANTABLE OR FIT FOR A
-PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
-WORK IS WITH YOU. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
-PART OF THIS LICENSE. NO LICENSE TO ORIGINAL WORK IS GRANTED HEREUNDER
-EXCEPT UNDER THIS DISCLAIMER.
-
-LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL
-THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE,
-SHALL THE LICENSOR BE LIABLE TO ANY PERSON FOR ANY DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING
-AS A RESULT OF THIS LICENSE OR THE USE OF THE ORIGINAL WORK INCLUDING,
-WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE,
-COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL
-DAMAGES OR LOSSES, EVEN IF SUCH PERSON SHALL HAVE BEEN INFORMED OF THE
-POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT
-APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH
-PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH
-LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR
-LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION
-AND LIMITATION MAY NOT APPLY TO YOU.
-
-License to Source Code. The term "Source Code" means the preferred
-form of the Original Work for making modifications to it and all
-available documentation describing how to access and modify the
-Original Work. Licensor hereby agrees to provide a machine-readable
-copy of the Source Code of the Original Work along with each copy of
-the Original Work that Licensor distributes. Licensor reserves the
-right to satisfy this obligation by placing a machine-readable copy of
-the Source Code in an information repository reasonably calculated to
-permit inexpensive and convenient access by You for as long as
-Licensor continues to distribute the Original Work, and by publishing
-the address of that information repository in a notice immediately
-following the copyright notice that applies to the Original Work.
-
-Mutual Termination for Patent Action. This License shall terminate
-automatically and You may no longer exercise any of the rights granted
-to You by this License if You file a lawsuit in any court alleging
-that any OSI Certified open source software that is licensed under any
-license containing this "Mutual Termination for Patent Action" clause
-infringes any patent claims that are essential to use that software.
-
-This license is Copyright (C) 2002 Lawrence E. Rosen. All rights
-reserved. Permission is hereby granted to copy and distribute this
-license without modification. This license may not be modified without
-the express written permission of its copyright owner.
-
-
diff -r 8ab106d762cf7aa9f07d299e4e440c4c8f924230 -r 560803d287f3e35963562d7ba1f0899e3a0e9f39 yt/utilities/kdtree/Makefile
--- a/yt/utilities/kdtree/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# if you want to build this statically, you need to include fKD.f90 to the
-# compile line, so pick the first of the two below. Otherwise, eliminate it,
-# like the second, for a shared object.
-
-ifdef FORTHON_EXE
-FORTHON=$(FORTHON_EXE)
-else
-FORTHON=Forthon
-endif
-
-fKD: fKD.f90 fKD.v fKD_source.f90
-# Forthon --compile_first fKD_source --no2underscores -g fKD fKD.f90 fKD_source.f90
- @echo "Using $(FORTHON) ($(FORTHON_EXE))"
- $(FORTHON) -F gfortran --compile_first fKD_source --no2underscores --fopt "-O3" fKD fKD_source.f90
- mv build/lib*/fKDpy.so .
-
-clean:
- rm -rf build fKDpy.a fKDpy.so
diff -r 8ab106d762cf7aa9f07d299e4e440c4c8f924230 -r 560803d287f3e35963562d7ba1f0899e3a0e9f39 yt/utilities/kdtree/api.py
--- a/yt/utilities/kdtree/api.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from .fKDpy import \
- chainHOP_tags_dens, \
- create_tree, \
- fKD, \
- find_nn_nearest_neighbors, \
- free_tree, \
- find_chunk_nearest_neighbors
-
-
diff -r 8ab106d762cf7aa9f07d299e4e440c4c8f924230 -r 560803d287f3e35963562d7ba1f0899e3a0e9f39 yt/utilities/kdtree/fKD.f90
--- a/yt/utilities/kdtree/fKD.f90
+++ /dev/null
@@ -1,346 +0,0 @@
-subroutine create_tree(treeID)
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer, intent (in), optional :: treeID
-
- integer :: ID
-
- if (present(treeID)) then
- ID = treeID
- else
- ID = -1
- end if
-
- ! create a kd tree object
-
- if (ID == 1) then
- t1%tree2 => kdtree2_create(t1%pos,sort=t1%sort,rearrange=t1%rearrange)
- elseif (ID == 2) then
- t2%tree2 => kdtree2_create(t2%pos,sort=t2%sort,rearrange=t2%rearrange)
- else
- tree2 => kdtree2_create(pos,sort=sort,rearrange=rearrange)
- end if
-
- return
-
-end subroutine create_tree
-
-subroutine add_tree(treeID)
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: treeID
-
- if (treeID == 1) then
- t1 => Newtree_set()
- elseif (treeID == 2) then
- t2 => Newtree_set()
- end if
-
- return
-
-end subroutine add_tree
-
-subroutine find_nn_nearest_neighbors()
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
- !integer, parameter :: nn ! number of nearest neighbors found
-
- allocate(results(nn))
-
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
-
- dist = results%dis
- tags = results%idx
-
- !do k=1,nn
- ! print *, "k = ", k, " idx = ", tags(k)," dis = ", dist(k)
- ! print *, "x y z", pos(1,results(k)%idx), pos(2,results(k)%idx), pos(3,results(k)%idx)
- !enddo
-
-
- deallocate(results)
- return
-
-end subroutine find_nn_nearest_neighbors
-
-subroutine find_many_nn_nearest_neighbors()
- ! Given an input array of query vectors (qv_many), find their
- ! nearest neighbors.
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k, number
- type(kdtree2_result),allocatable :: results(:)
-
- allocate(results(nn))
-
- number = size(qv_many,2)
-
- do k=1, number
- qv(:) = qv_many(:,k)
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
- nn_tags(:, k) = results%idx
- end do
-
- deallocate(results)
- return
-
-end subroutine find_many_nn_nearest_neighbors
-
-subroutine find_r_nearest()
- ! Given an input array of a point (qv), find the number, fortran indices and
- ! squared distances to all neighbors within (radius) of (qv).
- ! The number of neighbors with indices and radius returned is set by
- ! (radius_n), and if this is smaller than (nfound) when returned,
- ! there are neighbors missing from the results.
- ! Store the results in (dist) and (tags).
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
-
- allocate(results(radius_n))
- nfound = 0
-
- ! do it.
- call kdtree2_r_nearest(tp=tree2,qv=qv,r2=radius,nfound=nfound,nalloc=radius_n,results=results)
-
- tags(:) = results%idx
- dist(:) = results%dis
-
- deallocate(results)
- return
-
-end subroutine find_r_nearest
-
-subroutine find_many_r_nearest(treeID)
- ! Given an input array of a points (qv_many), find the number, fortran indices and
- ! squared distances to all neighbors within (radius) of (qv).
- ! The number of neighbors with indices and radius returned is set by
- ! (radius_n), and if this is smaller than (nfound) when returned,
- ! there are neighbors missing from the results.
- ! Store the results in (dist) and (tags).
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer, intent (in), optional :: treeID
-
- integer :: ID
- integer :: k, number
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
-
-
- if (present(treeID)) then
- ID = treeID
- else
- ID = -1
- end if
-
- if (ID==1) then
- allocate(results(t1%radius_n))
- number = size(t1%qv_many,2)
- do k=1, number
- t1%qv(:) = t1%qv_many(:,k)
- t1%nfound = t1%nfound_many(k)
- call kdtree2_r_nearest(tp=t1%tree2,qv=t1%qv,r2=t1%radius,nfound=t1%nfound,nalloc=t1%radius_n,results=results)
- t1%nfound_many(k) = t1%nfound
- t1%nn_tags(:, k) = results%idx
- t1%nn_dist(:, k) = results%dis
- end do
- elseif (ID==2) then
- allocate(results(t2%radius_n))
- number = size(t2%qv_many,2)
- do k=1, number
- t2%qv(:) = t2%qv_many(:,k)
- t2%nfound = t2%nfound_many(k)
- call kdtree2_r_nearest(tp=t2%tree2,qv=t2%qv,r2=t2%radius,nfound=t2%nfound,nalloc=t2%radius_n,results=results)
- t2%nfound_many(k) = t2%nfound
- t2%nn_tags(:, k) = results%idx
- t2%nn_dist(:, k) = results%dis
- end do
- else
- allocate(results(radius_n))
- number = size(qv_many,2)
- do k=1, number
- qv(:) = qv_many(:,k)
- nfound = nfound_many(k)
- call kdtree2_r_nearest(tp=tree2,qv=qv,r2=radius,nfound=nfound,nalloc=radius_n,results=results)
- nfound_many(k) = nfound
- nn_tags(:, k) = results%idx
- nn_dist(:, k) = results%dis
- end do
- end if
-
- deallocate(results)
- return
-
-end subroutine find_many_r_nearest
-
-subroutine find_all_nn_nearest_neighbors()
- ! for all particles in pos, find their nearest neighbors and return the
- ! indexes and distances as big arrays
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
-
- allocate(results(nn))
-
- do k=1,nparts
- qv(:) = pos(:,k)
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
- nn_dist(:,k) = results%dis
- nn_tags(:,k) = results%idx
- end do
-
- deallocate(results)
- return
-
-end subroutine find_all_nn_nearest_neighbors
-
-subroutine find_chunk_nearest_neighbors()
- ! for a chunk of the full number of particles, find their nearest neighbors
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
- allocate(results(nn))
- do k=start,finish
- qv(:) = pos(:,k)
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
- chunk_tags(:,k - start + 1) = results%idx
-
- end do
-
- deallocate(results)
- return
-
-end subroutine find_chunk_nearest_neighbors
-
-subroutine chainHOP_tags_dens()
- ! for all particles in pos, find their nearest neighbors, and calculate
- ! their density. Return only nMerge nearest neighbors.
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k, pj, i
- real :: ih2, fNorm, r2, rs
- integer, allocatable :: temp_tags(:)
- real, allocatable :: temp_dist(:)
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
- allocate(results(nn))
- allocate(temp_tags(nn))
- allocate(temp_dist(nn))
-
- do k=1,nparts
- qv(:) = pos(:,k)
-
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
- temp_tags(:) = results%idx
- temp_dist(:) = results%dis
-
- ! calculate the density for this particle
- ih2 = 4.0/maxval(results%dis)
- fNorm = 0.5*sqrt(ih2)*ih2/3.1415926535897931
- do i=1,nn
- pj = temp_tags(i)
- r2 = temp_dist(i) * ih2
- rs = 2.0 - sqrt(r2)
- if (r2 < 1.0) then
- rs = (1.0 - 0.75*rs*r2)
- else
- rs = 0.25*rs*rs*rs
- end if
- rs = rs * fNorm
- dens(k) = dens(k) + rs * mass(pj)
- dens(pj) = dens(pj) + rs * mass(k)
- end do
-
- ! record only nMerge nearest neighbors, but skip the first one which
- ! is always the self-same particle
- ! nn_tags(:,k) = temp_tags(2:nMerge)
- end do
-
- deallocate(results)
- deallocate(temp_dist)
- deallocate(temp_tags)
- return
-
-end subroutine chainHOP_tags_dens
-
-subroutine free_tree(treeID)
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer, intent (in), optional :: treeID
-
- integer :: ID
-
- if (present(treeID)) then
- ID = treeID
- else
- ID = -1
- end if
-
- ! this releases memory for the tree BUT NOT THE ARRAY OF DATA YOU PASSED
- ! TO MAKE THE TREE.
- if (ID == 1) then
- call kdtree2_destroy(t1%tree2)
- elseif (ID == 2) then
- call kdtree2_destroy(t2%tree2)
- else
- call kdtree2_destroy(tree2)
- end if
-
- ! The data to make the tree has to be deleted in python BEFORE calling
- ! this!
-end subroutine free_tree
-
diff -r 8ab106d762cf7aa9f07d299e4e440c4c8f924230 -r 560803d287f3e35963562d7ba1f0899e3a0e9f39 yt/utilities/kdtree/fKD.v
--- a/yt/utilities/kdtree/fKD.v
+++ /dev/null
@@ -1,139 +0,0 @@
-fKD
-
-****** fKD_module vars:
-t1 _tree_set
-t2 _tree_set
-# This contains the objects that any given kD tree might wish to use.
-# Not all of these are being used all the time, but they only take memory
-# if they're initialized in python.
-tags(:) _integer # particle ID tags
-dist(:) _real # interparticle spacings
-nn_tags(:,:) _integer # for all particles at once, [nth neighbor, index]
-chunk_tags(:,:) _integer # for finding only a chunk of the nearest neighbors
-nn_dist(:,:) _real
-pos(3,:) _real
-dens(:) _real
-mass(:) _real
-qv(3) real
-qv_many(3,:) _real
-nparts integer
-nn integer
-nMerge integer # number of nearest neighbors used in chain merging
-start integer
-finish integer
-tree2 _kdtree2
-sort logical /.false./
-rearrange logical /.true./
-radius real # the unsquared radius for radius searches
-radius_n integer # the number of results to return
-nfound integer # number of neighbors within radius
-nfound_many(:) _integer # an array of number of neighbors within radius
-
-%%%% interval:
-lower real
-upper real
-#real(kdkind) :: lower,upper
-
-
-%%%% tree_node:
-# an internal tree node
-cut_dim integer
-#integer :: cut_dim
-# the dimension to cut
-cut_val real
-#real(kdkind) :: cut_val
-# where to cut the dimension
-cut_val_left real
-cut_val_right real
-#real(kdkind) :: cut_val_left, cut_val_right
-# improved cutoffs knowing the spread in child boxes.
-u integer
-l integer
-#integer :: l, u
-left _tree_node
-right _tree_node
-#type(tree_node), pointer :: left, right
-box(:) _interval
-#type(interval), pointer :: box(:) => null()
-# child pointers
-# Points included in this node are indexes[k] with k \in [l,u]
-
-
-%%%% kdtree2:
-# Global information about the tree, one per tree
-dimen integer /0/
-n integer /0/
-# dimensionality and total # of points
-the_data(:,:) _real
-#real(kdkind), pointer :: the_data(:,:) => null()
-# pointer to the actual data array
-#
-# IMPORTANT NOTE: IT IS DIMENSIONED the_data(1:d,1:N)
-# which may be opposite of what may be conventional.
-# This is, because in Fortran, the memory layout is such that
-# the first dimension is in sequential order. Hence, with
-# (1:d,1:N), all components of the vector will be in consecutive
-# memory locations. The search time is dominated by the
-# evaluation of distances in the terminal nodes. Putting all
-# vector components in consecutive memory location improves
-# memory cache locality, and hence search speed, and may enable
-# vectorization on some processors and compilers.
-ind(:) _integer
-#integer, pointer :: ind(:) => null()
-# permuted index into the data, so that indexes[l..u] of some
-# bucket represent the indexes of the actual points in that
-# bucket.
-# do we always sort output results?
-sort logical /.false./
-#logical :: sort = .false.
-rearrange logical /.false./
-#logical :: rearrange = .false.
-rearranged_data(:,:) _real
-#real(kdkind), pointer :: rearranged_data(:,:) => null()
-# if (rearrange .eqv. .true.) then rearranged_data has been
-# created so that rearranged_data(:,i) = the_data(:,ind(i)),
-# permitting search to use more cache-friendly rearranged_data, at
-# some initial computation and storage cost.
-root _tree_node
-#type(tree_node), pointer :: root => null()
-# root pointer of the tree
-
-
-%%%% tree_set:
-# This contains the objects that any given kD tree might wish to use.
-# Not all of these are being used all the time, but they only take memory
-# if they're initialized in python.
-tags(:) _integer # particle ID tags
-dist(:) _real # interparticle spacings
-nn_tags(:,:) _integer # for all particles at once, [nth neighbor, index]
-chunk_tags(:,:) _integer # for finding only a chunk of the nearest neighbors
-nn_dist(:,:) _real
-pos(3,:) _real
-dens(:) _real
-mass(:) _real
-qv(3) real
-qv_many(3,:) _real
-nparts integer
-nn integer
-nMerge integer # number of nearest neighbors used in chain merging
-start integer
-finish integer
-tree2 _kdtree2
-sort logical /.false./
-rearrange logical /.true./
-radius real # the unsquared radius for radius searches
-radius_n integer # the number of results to return
-nfound integer # number of neighbors within radius
-nfound_many(:) _integer # an array of number of neighbors within radius
-
-***** Subroutines:
-find_nn_nearest_neighbors subroutine
-create_tree(treeID:integer) subroutine
-add_tree(treeID:integer) subroutine
-free_tree(treeID:integer) subroutine
-find_all_nn_nearest_neighbors subroutine
-find_r_nearest subroutine
-find_many_r_nearest(treeID:integer) subroutine
-find_many_nn_nearest_neighbors subroutine
-find_chunk_nearest_neighbors subroutine
-chainHOP_tags_dens subroutine
This diff is so big that we needed to truncate the remainder.
https://bitbucket.org/yt_analysis/yt/commits/5c01666a7092/
Changeset: 5c01666a7092
Branch: yt-3.0
User: drudd
Date: 2014-07-11 17:01:13
Summary: Remove kdtree from Manifest.in
Affected #: 2 files
diff -r 560803d287f3e35963562d7ba1f0899e3a0e9f39 -r 5c01666a70922ab50c9597d237ddcb07372294fa MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -12,4 +12,3 @@
prune tests
graft yt/gui/reason/html/resources
exclude clean.sh .hgchurn
-recursive-include yt/utilities/kdtree *.f90 *.v Makefile LICENSE
diff -r 560803d287f3e35963562d7ba1f0899e3a0e9f39 -r 5c01666a70922ab50c9597d237ddcb07372294fa setup.py
--- a/setup.py
+++ b/setup.py
@@ -151,7 +151,6 @@
class my_build_src(build_src.build_src):
def run(self):
- self.run_command("build_forthon")
build_src.build_src.run(self)
https://bitbucket.org/yt_analysis/yt/commits/c21e369d1902/
Changeset: c21e369d1902
Branch: yt-3.0
User: drudd
Date: 2014-07-11 17:05:30
Summary: Remove reference to building kdtree from Parallel Hop documentation
Affected #: 1 file
diff -r 5c01666a70922ab50c9597d237ddcb07372294fa -r c21e369d1902b14164c686ad51d03e60fa69121f doc/source/analyzing/analysis_modules/running_halofinder.rst
--- a/doc/source/analyzing/analysis_modules/running_halofinder.rst
+++ b/doc/source/analyzing/analysis_modules/running_halofinder.rst
@@ -300,40 +300,11 @@
Therefore Parallel HOP is not a direct substitution for
normal HOP, but is very similar.
-.. _fkd_setup:
-
-Fortran kD Tree Setup
-^^^^^^^^^^^^^^^^^^^^^
-
-Parallel HOP will not build automatically with yt. Please follow the instructions
-below in order to setup Parallel HOP.
-
- #. Download `Forthon <http://hifweb.lbl.gov/Forthon/>`_. Extract the files
- (e.g. tar -zxvf Forthon.tgz) and cd into the new Forthon directory.
- Making sure you're using the same version of python you use with yt, invoke
- ``python setup.py install``.
- #. Change directory to your yt source. Starting from the top level, cd into
- ``yt/utilities/kdtree``.
- #. Inside that directory, you should see these files:
-
- .. code-block:: bash
-
- % ls
- Makefile fKD.f90 fKD_source.f90
- __init__.py fKD.v test.py
-
- #. Type ``make``. If that is successful, there should be a file in the
- directory named ``fKDpy.so``. If there are problems, please contact the
- `yt-users email list <http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org>`_.
- #. Go to the top level of the yt source directory, which from the ``kdtree``
- directory is three levels up ``cd ../../..``, and invoke
- ``python setup.py install``.
- #. Parallel HOP should now work.
-
-
Running Parallel HOP
^^^^^^^^^^^^^^^^^^^^
+Note: This is probably broken now that the Fortran kdtree has been removed.
+
In the simplest form, Parallel HOP is run very similarly to the other halo finders.
In the example below, Parallel HOP will be run on a dataset with all the default
values. Parallel HOP can be run in serial, but as mentioned above, it is
https://bitbucket.org/yt_analysis/yt/commits/6f312e4760d1/
Changeset: 6f312e4760d1
Branch: yt-3.0
User: drudd
Date: 2014-07-11 17:07:13
Summary: Add notice to parallel hop code that fortran kdtree was removed
Affected #: 1 file
diff -r c21e369d1902b14164c686ad51d03e60fa69121f -r 6f312e4760d13fd99d6cba8673d11519ad7f46c5 yt/analysis_modules/halo_finding/parallel_hop/parallel_hop_interface.py
--- a/yt/analysis_modules/halo_finding/parallel_hop/parallel_hop_interface.py
+++ b/yt/analysis_modules/halo_finding/parallel_hop/parallel_hop_interface.py
@@ -21,12 +21,14 @@
from yt.funcs import *
from yt.utilities.performance_counters import yt_counters, time_function
try:
+ # Note: This is now broken due to removing of kdtree (DHR 7/11/2014)
from yt.utilities.kdtree.api import \
chainHOP_tags_dens, \
create_tree, fKD, find_nn_nearest_neighbors, \
free_tree, find_chunk_nearest_neighbors
except ImportError:
- mylog.debug("The Fortran kD-Tree did not import correctly.")
+ mylog.debug("The Fortran kD-Tree did not import correctly. "
+ "It was removed as of 7/11/2014.")
from yt.utilities.spatial import cKDTree
https://bitbucket.org/yt_analysis/yt/commits/9abe969426fd/
Changeset: 9abe969426fd
Branch: yt-3.0
User: MatthewTurk
Date: 2014-07-12 16:27:56
Summary: Merged in drudd/yt/yt-3.0 (pull request #1008)
Remove Forthon and Fortran kD tree
Affected #: 14 files
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -12,4 +12,3 @@
prune tests
graft yt/gui/reason/html/resources
exclude clean.sh .hgchurn
-recursive-include yt/utilities/kdtree *.f90 *.v Makefile LICENSE
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 doc/source/analyzing/analysis_modules/running_halofinder.rst
--- a/doc/source/analyzing/analysis_modules/running_halofinder.rst
+++ b/doc/source/analyzing/analysis_modules/running_halofinder.rst
@@ -300,40 +300,11 @@
Therefore Parallel HOP is not a direct substitution for
normal HOP, but is very similar.
-.. _fkd_setup:
-
-Fortran kD Tree Setup
-^^^^^^^^^^^^^^^^^^^^^
-
-Parallel HOP will not build automatically with yt. Please follow the instructions
-below in order to setup Parallel HOP.
-
- #. Download `Forthon <http://hifweb.lbl.gov/Forthon/>`_. Extract the files
- (e.g. tar -zxvf Forthon.tgz) and cd into the new Forthon directory.
- Making sure you're using the same version of python you use with yt, invoke
- ``python setup.py install``.
- #. Change directory to your yt source. Starting from the top level, cd into
- ``yt/utilities/kdtree``.
- #. Inside that directory, you should see these files:
-
- .. code-block:: bash
-
- % ls
- Makefile fKD.f90 fKD_source.f90
- __init__.py fKD.v test.py
-
- #. Type ``make``. If that is successful, there should be a file in the
- directory named ``fKDpy.so``. If there are problems, please contact the
- `yt-users email list <http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org>`_.
- #. Go to the top level of the yt source directory, which from the ``kdtree``
- directory is three levels up ``cd ../../..``, and invoke
- ``python setup.py install``.
- #. Parallel HOP should now work.
-
-
Running Parallel HOP
^^^^^^^^^^^^^^^^^^^^
+Note: This is probably broken now that the Fortran kdtree has been removed.
+
In the simplest form, Parallel HOP is run very similarly to the other halo finders.
In the example below, Parallel HOP will be run on a dataset with all the default
values. Parallel HOP can be run in serial, but as mentioned above, it is
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 setup.py
--- a/setup.py
+++ b/setup.py
@@ -25,48 +25,6 @@
from distutils.core import Command
from distutils.spawn import find_executable
-def find_fortran_deps():
- return (find_executable("Forthon"),
- find_executable("gfortran"))
-
-class BuildForthon(Command):
-
- """Command for building Forthon modules"""
-
- description = "Build Forthon modules"
- user_options = []
-
- def initialize_options(self):
-
- """init options"""
-
- pass
-
- def finalize_options(self):
-
- """finalize options"""
-
- pass
-
- def run(self):
-
- """runner"""
- (Forthon_exe, gfortran_exe) = find_fortran_deps()
- if None in (Forthon_exe, gfortran_exe):
- sys.stderr.write(
- "fKDpy.so won't be built due to missing Forthon/gfortran\n"
- )
- return
-
- cwd = os.getcwd()
- os.chdir(os.path.join(cwd, 'yt/utilities/kdtree'))
- cmd = [Forthon_exe, "-F", "gfortran", "--compile_first",
- "fKD_source", "--no2underscores", "--fopt", "'-O3'", "fKD",
- "fKD_source.f90"]
- subprocess.check_call(cmd, shell=False)
- shutil.move(glob.glob('build/lib*/fKDpy.so')[0], os.getcwd())
- os.chdir(cwd)
-
REASON_FILES = []
REASON_DIRS = [
"",
@@ -193,21 +151,9 @@
class my_build_src(build_src.build_src):
def run(self):
- self.run_command("build_forthon")
build_src.build_src.run(self)
-class my_install_data(np_install_data.install_data):
- def run(self):
- (Forthon_exe, gfortran_exe) = find_fortran_deps()
- if None in (Forthon_exe, gfortran_exe):
- pass
- else:
- self.distribution.data_files.append(
- ('yt/utilities/kdtree', ['yt/utilities/kdtree/fKDpy.so'])
- )
- np_install_data.install_data.run(self)
-
class my_build_py(build_py):
def run(self):
# honor the --dry-run flag
@@ -277,8 +223,7 @@
configuration=configuration,
zip_safe=False,
data_files=REASON_FILES,
- cmdclass={'build_py': my_build_py, 'build_forthon': BuildForthon,
- 'build_src': my_build_src, 'install_data': my_install_data},
+ cmdclass={'build_py': my_build_py, 'build_src': my_build_src},
)
return
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 yt/analysis_modules/halo_finding/parallel_hop/parallel_hop_interface.py
--- a/yt/analysis_modules/halo_finding/parallel_hop/parallel_hop_interface.py
+++ b/yt/analysis_modules/halo_finding/parallel_hop/parallel_hop_interface.py
@@ -21,12 +21,14 @@
from yt.funcs import *
from yt.utilities.performance_counters import yt_counters, time_function
try:
+ # Note: This is now broken due to removing of kdtree (DHR 7/11/2014)
from yt.utilities.kdtree.api import \
chainHOP_tags_dens, \
create_tree, fKD, find_nn_nearest_neighbors, \
free_tree, find_chunk_nearest_neighbors
except ImportError:
- mylog.debug("The Fortran kD-Tree did not import correctly.")
+ mylog.debug("The Fortran kD-Tree did not import correctly. "
+ "It was removed as of 7/11/2014.")
from yt.utilities.spatial import cKDTree
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 yt/utilities/kdtree/LICENSE
--- a/yt/utilities/kdtree/LICENSE
+++ /dev/null
@@ -1,98 +0,0 @@
-
-The KDTREE2 software is licensed under the terms of the Academic Free
-Software License, listed herein. In addition, users of this software
-must give appropriate citation in relevant technical documentation or
-journal paper to the author, Matthew B. Kennel, Institute For
-Nonlinear Science, preferably via a reference to the www.arxiv.org
-repository of this document, {\tt www.arxiv.org e-print:
-physics/0408067}. This requirement will be deemed to be advisory and
-not mandatory as is necessary to permit the free inclusion of the
-present software with any software licensed under the terms of any
-version of the GNU General Public License, or GNU Library General
-Public License.
-
-
-Academic Free License
-Version 1.1
-
-This Academic Free License applies to any original work of authorship
-(the "Original Work") whose owner (the "Licensor") has placed the
-following notice immediately following the copyright notice for the
-Original Work: "Licensed under the Academic Free License version 1.1."
-
-Grant of License. Licensor hereby grants to any person obtaining a
-copy of the Original Work ("You") a world-wide, royalty-free,
-non-exclusive, perpetual, non-sublicenseable license (1) to use, copy,
-modify, merge, publish, perform, distribute and/or sell copies of the
-Original Work and derivative works thereof, and (2) under patent
-claims owned or controlled by the Licensor that are embodied in the
-Original Work as furnished by the Licensor, to make, use, sell and
-offer for sale the Original Work and derivative works thereof, subject
-to the following conditions.
-
-Right of Attribution. Redistributions of the Original Work must
-reproduce all copyright notices in the Original Work as furnished by
-the Licensor, both in the Original Work itself and in any
-documentation and/or other materials provided with the distribution of
-the Original Work in executable form.
-
-Exclusions from License Grant. Neither the names of Licensor, nor the
-names of any contributors to the Original Work, nor any of their
-trademarks or service marks, may be used to endorse or promote
-products derived from this Original Work without express prior written
-permission of the Licensor.
-
-WARRANTY AND DISCLAIMERS. LICENSOR WARRANTS THAT THE COPYRIGHT IN AND
-TO THE ORIGINAL WORK IS OWNED BY THE LICENSOR OR THAT THE ORIGINAL
-WORK IS DISTRIBUTED BY LICENSOR UNDER A VALID CURRENT LICENSE FROM THE
-COPYRIGHT OWNER. EXCEPT AS EXPRESSLY STATED IN THE IMMEDIATELY
-PRECEEDING SENTENCE, THE ORIGINAL WORK IS PROVIDED UNDER THIS LICENSE
-ON AN "AS IS" BASIS, WITHOUT WARRANTY, EITHER EXPRESS OR IMPLIED,
-INCLUDING, WITHOUT LIMITATION, THE WARRANTY OF NON-INFRINGEMENT AND
-WARRANTIES THAT THE ORIGINAL WORK IS MERCHANTABLE OR FIT FOR A
-PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
-WORK IS WITH YOU. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
-PART OF THIS LICENSE. NO LICENSE TO ORIGINAL WORK IS GRANTED HEREUNDER
-EXCEPT UNDER THIS DISCLAIMER.
-
-LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL
-THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE,
-SHALL THE LICENSOR BE LIABLE TO ANY PERSON FOR ANY DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING
-AS A RESULT OF THIS LICENSE OR THE USE OF THE ORIGINAL WORK INCLUDING,
-WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE,
-COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL
-DAMAGES OR LOSSES, EVEN IF SUCH PERSON SHALL HAVE BEEN INFORMED OF THE
-POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT
-APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH
-PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH
-LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR
-LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION
-AND LIMITATION MAY NOT APPLY TO YOU.
-
-License to Source Code. The term "Source Code" means the preferred
-form of the Original Work for making modifications to it and all
-available documentation describing how to access and modify the
-Original Work. Licensor hereby agrees to provide a machine-readable
-copy of the Source Code of the Original Work along with each copy of
-the Original Work that Licensor distributes. Licensor reserves the
-right to satisfy this obligation by placing a machine-readable copy of
-the Source Code in an information repository reasonably calculated to
-permit inexpensive and convenient access by You for as long as
-Licensor continues to distribute the Original Work, and by publishing
-the address of that information repository in a notice immediately
-following the copyright notice that applies to the Original Work.
-
-Mutual Termination for Patent Action. This License shall terminate
-automatically and You may no longer exercise any of the rights granted
-to You by this License if You file a lawsuit in any court alleging
-that any OSI Certified open source software that is licensed under any
-license containing this "Mutual Termination for Patent Action" clause
-infringes any patent claims that are essential to use that software.
-
-This license is Copyright (C) 2002 Lawrence E. Rosen. All rights
-reserved. Permission is hereby granted to copy and distribute this
-license without modification. This license may not be modified without
-the express written permission of its copyright owner.
-
-
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 yt/utilities/kdtree/Makefile
--- a/yt/utilities/kdtree/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# if you want to build this statically, you need to include fKD.f90 to the
-# compile line, so pick the first of the two below. Otherwise, eliminate it,
-# like the second, for a shared object.
-
-ifdef FORTHON_EXE
-FORTHON=$(FORTHON_EXE)
-else
-FORTHON=Forthon
-endif
-
-fKD: fKD.f90 fKD.v fKD_source.f90
-# Forthon --compile_first fKD_source --no2underscores -g fKD fKD.f90 fKD_source.f90
- @echo "Using $(FORTHON) ($(FORTHON_EXE))"
- $(FORTHON) -F gfortran --compile_first fKD_source --no2underscores --fopt "-O3" fKD fKD_source.f90
- mv build/lib*/fKDpy.so .
-
-clean:
- rm -rf build fKDpy.a fKDpy.so
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 yt/utilities/kdtree/api.py
--- a/yt/utilities/kdtree/api.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from .fKDpy import \
- chainHOP_tags_dens, \
- create_tree, \
- fKD, \
- find_nn_nearest_neighbors, \
- free_tree, \
- find_chunk_nearest_neighbors
-
-
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 yt/utilities/kdtree/fKD.f90
--- a/yt/utilities/kdtree/fKD.f90
+++ /dev/null
@@ -1,346 +0,0 @@
-subroutine create_tree(treeID)
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer, intent (in), optional :: treeID
-
- integer :: ID
-
- if (present(treeID)) then
- ID = treeID
- else
- ID = -1
- end if
-
- ! create a kd tree object
-
- if (ID == 1) then
- t1%tree2 => kdtree2_create(t1%pos,sort=t1%sort,rearrange=t1%rearrange)
- elseif (ID == 2) then
- t2%tree2 => kdtree2_create(t2%pos,sort=t2%sort,rearrange=t2%rearrange)
- else
- tree2 => kdtree2_create(pos,sort=sort,rearrange=rearrange)
- end if
-
- return
-
-end subroutine create_tree
-
-subroutine add_tree(treeID)
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: treeID
-
- if (treeID == 1) then
- t1 => Newtree_set()
- elseif (treeID == 2) then
- t2 => Newtree_set()
- end if
-
- return
-
-end subroutine add_tree
-
-subroutine find_nn_nearest_neighbors()
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
- !integer, parameter :: nn ! number of nearest neighbors found
-
- allocate(results(nn))
-
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
-
- dist = results%dis
- tags = results%idx
-
- !do k=1,nn
- ! print *, "k = ", k, " idx = ", tags(k)," dis = ", dist(k)
- ! print *, "x y z", pos(1,results(k)%idx), pos(2,results(k)%idx), pos(3,results(k)%idx)
- !enddo
-
-
- deallocate(results)
- return
-
-end subroutine find_nn_nearest_neighbors
-
-subroutine find_many_nn_nearest_neighbors()
- ! Given an input array of query vectors (qv_many), find their
- ! nearest neighbors.
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k, number
- type(kdtree2_result),allocatable :: results(:)
-
- allocate(results(nn))
-
- number = size(qv_many,2)
-
- do k=1, number
- qv(:) = qv_many(:,k)
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
- nn_tags(:, k) = results%idx
- end do
-
- deallocate(results)
- return
-
-end subroutine find_many_nn_nearest_neighbors
-
-subroutine find_r_nearest()
- ! Given an input array of a point (qv), find the number, fortran indices and
- ! squared distances to all neighbors within (radius) of (qv).
- ! The number of neighbors with indices and radius returned is set by
- ! (radius_n), and if this is smaller than (nfound) when returned,
- ! there are neighbors missing from the results.
- ! Store the results in (dist) and (tags).
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
-
- allocate(results(radius_n))
- nfound = 0
-
- ! do it.
- call kdtree2_r_nearest(tp=tree2,qv=qv,r2=radius,nfound=nfound,nalloc=radius_n,results=results)
-
- tags(:) = results%idx
- dist(:) = results%dis
-
- deallocate(results)
- return
-
-end subroutine find_r_nearest
-
-subroutine find_many_r_nearest(treeID)
- ! Given an input array of a points (qv_many), find the number, fortran indices and
- ! squared distances to all neighbors within (radius) of (qv).
- ! The number of neighbors with indices and radius returned is set by
- ! (radius_n), and if this is smaller than (nfound) when returned,
- ! there are neighbors missing from the results.
- ! Store the results in (dist) and (tags).
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer, intent (in), optional :: treeID
-
- integer :: ID
- integer :: k, number
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
-
-
- if (present(treeID)) then
- ID = treeID
- else
- ID = -1
- end if
-
- if (ID==1) then
- allocate(results(t1%radius_n))
- number = size(t1%qv_many,2)
- do k=1, number
- t1%qv(:) = t1%qv_many(:,k)
- t1%nfound = t1%nfound_many(k)
- call kdtree2_r_nearest(tp=t1%tree2,qv=t1%qv,r2=t1%radius,nfound=t1%nfound,nalloc=t1%radius_n,results=results)
- t1%nfound_many(k) = t1%nfound
- t1%nn_tags(:, k) = results%idx
- t1%nn_dist(:, k) = results%dis
- end do
- elseif (ID==2) then
- allocate(results(t2%radius_n))
- number = size(t2%qv_many,2)
- do k=1, number
- t2%qv(:) = t2%qv_many(:,k)
- t2%nfound = t2%nfound_many(k)
- call kdtree2_r_nearest(tp=t2%tree2,qv=t2%qv,r2=t2%radius,nfound=t2%nfound,nalloc=t2%radius_n,results=results)
- t2%nfound_many(k) = t2%nfound
- t2%nn_tags(:, k) = results%idx
- t2%nn_dist(:, k) = results%dis
- end do
- else
- allocate(results(radius_n))
- number = size(qv_many,2)
- do k=1, number
- qv(:) = qv_many(:,k)
- nfound = nfound_many(k)
- call kdtree2_r_nearest(tp=tree2,qv=qv,r2=radius,nfound=nfound,nalloc=radius_n,results=results)
- nfound_many(k) = nfound
- nn_tags(:, k) = results%idx
- nn_dist(:, k) = results%dis
- end do
- end if
-
- deallocate(results)
- return
-
-end subroutine find_many_r_nearest
-
-subroutine find_all_nn_nearest_neighbors()
- ! for all particles in pos, find their nearest neighbors and return the
- ! indexes and distances as big arrays
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
-
- allocate(results(nn))
-
- do k=1,nparts
- qv(:) = pos(:,k)
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
- nn_dist(:,k) = results%dis
- nn_tags(:,k) = results%idx
- end do
-
- deallocate(results)
- return
-
-end subroutine find_all_nn_nearest_neighbors
-
-subroutine find_chunk_nearest_neighbors()
- ! for a chunk of the full number of particles, find their nearest neighbors
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
- allocate(results(nn))
- do k=start,finish
- qv(:) = pos(:,k)
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
- chunk_tags(:,k - start + 1) = results%idx
-
- end do
-
- deallocate(results)
- return
-
-end subroutine find_chunk_nearest_neighbors
-
-subroutine chainHOP_tags_dens()
- ! for all particles in pos, find their nearest neighbors, and calculate
- ! their density. Return only nMerge nearest neighbors.
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer :: k, pj, i
- real :: ih2, fNorm, r2, rs
- integer, allocatable :: temp_tags(:)
- real, allocatable :: temp_dist(:)
- type(kdtree2_result),allocatable :: results(:) ! nearest neighbors
- allocate(results(nn))
- allocate(temp_tags(nn))
- allocate(temp_dist(nn))
-
- do k=1,nparts
- qv(:) = pos(:,k)
-
- call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
- temp_tags(:) = results%idx
- temp_dist(:) = results%dis
-
- ! calculate the density for this particle
- ih2 = 4.0/maxval(results%dis)
- fNorm = 0.5*sqrt(ih2)*ih2/3.1415926535897931
- do i=1,nn
- pj = temp_tags(i)
- r2 = temp_dist(i) * ih2
- rs = 2.0 - sqrt(r2)
- if (r2 < 1.0) then
- rs = (1.0 - 0.75*rs*r2)
- else
- rs = 0.25*rs*rs*rs
- end if
- rs = rs * fNorm
- dens(k) = dens(k) + rs * mass(pj)
- dens(pj) = dens(pj) + rs * mass(k)
- end do
-
- ! record only nMerge nearest neighbors, but skip the first one which
- ! is always the self-same particle
- ! nn_tags(:,k) = temp_tags(2:nMerge)
- end do
-
- deallocate(results)
- deallocate(temp_dist)
- deallocate(temp_tags)
- return
-
-end subroutine chainHOP_tags_dens
-
-subroutine free_tree(treeID)
- use kdtree2_module
- use fKD_module
- use tree_setmodule
- use kdtree2module
- use tree_nodemodule
- use intervalmodule
-
- integer, intent (in), optional :: treeID
-
- integer :: ID
-
- if (present(treeID)) then
- ID = treeID
- else
- ID = -1
- end if
-
- ! this releases memory for the tree BUT NOT THE ARRAY OF DATA YOU PASSED
- ! TO MAKE THE TREE.
- if (ID == 1) then
- call kdtree2_destroy(t1%tree2)
- elseif (ID == 2) then
- call kdtree2_destroy(t2%tree2)
- else
- call kdtree2_destroy(tree2)
- end if
-
- ! The data to make the tree has to be deleted in python BEFORE calling
- ! this!
-end subroutine free_tree
-
diff -r 1a9d7403db86e550e48793a21d2ef128b13b9100 -r 9abe969426fd2da259434ee4cbefceccce62a410 yt/utilities/kdtree/fKD.v
--- a/yt/utilities/kdtree/fKD.v
+++ /dev/null
@@ -1,139 +0,0 @@
-fKD
-
-****** fKD_module vars:
-t1 _tree_set
-t2 _tree_set
-# This contains the objects that any given kD tree might wish to use.
-# Not all of these are being used all the time, but they only take memory
-# if they're initialized in python.
-tags(:) _integer # particle ID tags
-dist(:) _real # interparticle spacings
-nn_tags(:,:) _integer # for all particles at once, [nth neighbor, index]
-chunk_tags(:,:) _integer # for finding only a chunk of the nearest neighbors
-nn_dist(:,:) _real
-pos(3,:) _real
-dens(:) _real
-mass(:) _real
-qv(3) real
-qv_many(3,:) _real
-nparts integer
-nn integer
-nMerge integer # number of nearest neighbors used in chain merging
-start integer
-finish integer
-tree2 _kdtree2
-sort logical /.false./
-rearrange logical /.true./
-radius real # the unsquared radius for radius searches
-radius_n integer # the number of results to return
-nfound integer # number of neighbors within radius
-nfound_many(:) _integer # an array of number of neighbors within radius
-
-%%%% interval:
-lower real
-upper real
-#real(kdkind) :: lower,upper
-
-
-%%%% tree_node:
-# an internal tree node
-cut_dim integer
-#integer :: cut_dim
-# the dimension to cut
-cut_val real
-#real(kdkind) :: cut_val
-# where to cut the dimension
-cut_val_left real
-cut_val_right real
-#real(kdkind) :: cut_val_left, cut_val_right
-# improved cutoffs knowing the spread in child boxes.
-u integer
-l integer
-#integer :: l, u
-left _tree_node
-right _tree_node
-#type(tree_node), pointer :: left, right
-box(:) _interval
-#type(interval), pointer :: box(:) => null()
-# child pointers
-# Points included in this node are indexes[k] with k \in [l,u]
-
-
-%%%% kdtree2:
-# Global information about the tree, one per tree
-dimen integer /0/
-n integer /0/
-# dimensionality and total # of points
-the_data(:,:) _real
-#real(kdkind), pointer :: the_data(:,:) => null()
-# pointer to the actual data array
-#
-# IMPORTANT NOTE: IT IS DIMENSIONED the_data(1:d,1:N)
-# which may be opposite of what may be conventional.
-# This is, because in Fortran, the memory layout is such that
-# the first dimension is in sequential order. Hence, with
-# (1:d,1:N), all components of the vector will be in consecutive
-# memory locations. The search time is dominated by the
-# evaluation of distances in the terminal nodes. Putting all
-# vector components in consecutive memory location improves
-# memory cache locality, and hence search speed, and may enable
-# vectorization on some processors and compilers.
-ind(:) _integer
-#integer, pointer :: ind(:) => null()
-# permuted index into the data, so that indexes[l..u] of some
-# bucket represent the indexes of the actual points in that
-# bucket.
-# do we always sort output results?
-sort logical /.false./
-#logical :: sort = .false.
-rearrange logical /.false./
-#logical :: rearrange = .false.
-rearranged_data(:,:) _real
-#real(kdkind), pointer :: rearranged_data(:,:) => null()
-# if (rearrange .eqv. .true.) then rearranged_data has been
-# created so that rearranged_data(:,i) = the_data(:,ind(i)),
-# permitting search to use more cache-friendly rearranged_data, at
-# some initial computation and storage cost.
-root _tree_node
-#type(tree_node), pointer :: root => null()
-# root pointer of the tree
-
-
-%%%% tree_set:
-# This contains the objects that any given kD tree might wish to use.
-# Not all of these are being used all the time, but they only take memory
-# if they're initialized in python.
-tags(:) _integer # particle ID tags
-dist(:) _real # interparticle spacings
-nn_tags(:,:) _integer # for all particles at once, [nth neighbor, index]
-chunk_tags(:,:) _integer # for finding only a chunk of the nearest neighbors
-nn_dist(:,:) _real
-pos(3,:) _real
-dens(:) _real
-mass(:) _real
-qv(3) real
-qv_many(3,:) _real
-nparts integer
-nn integer
-nMerge integer # number of nearest neighbors used in chain merging
-start integer
-finish integer
-tree2 _kdtree2
-sort logical /.false./
-rearrange logical /.true./
-radius real # the unsquared radius for radius searches
-radius_n integer # the number of results to return
-nfound integer # number of neighbors within radius
-nfound_many(:) _integer # an array of number of neighbors within radius
-
-***** Subroutines:
-find_nn_nearest_neighbors subroutine
-create_tree(treeID:integer) subroutine
-add_tree(treeID:integer) subroutine
-free_tree(treeID:integer) subroutine
-find_all_nn_nearest_neighbors subroutine
-find_r_nearest subroutine
-find_many_r_nearest(treeID:integer) subroutine
-find_many_nn_nearest_neighbors subroutine
-find_chunk_nearest_neighbors subroutine
-chainHOP_tags_dens subroutine
This diff is so big that we needed to truncate the remainder.
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list