SUBROUTINE DFTREE(INX,NX,VECT,NDIM,NVEC,INDLR,NCDIM) * * Pre-processing for multi-dimensional range search (INDLR(2,...)) * * The array VECT(NDIM,NVEC) is assumed to contain NVEC NDIM-dimensional * single precision key vectors. For example for NDIM=3 the first vector * is stored in elements VECT(1,1),VECT(2,1),VECT(3,1). * * The integer array INX(NX) contains the indices of the NX used * vector elements. * * The integer array INDLR(2,NVEC) (i.e. second dimension equal to * the number of vectors) contains at return pointer information necessary * and to be used in the functions NCTREE and ITREE. * * The range search results of the function NCTREE is stored in the * integer array INDC(.) in the common /CINDEX/. The default dimension * if the array INDC(.) is 100, sufficient for up to 100 indices found * in a range search. The user may use a larger INDC(.) array dimension * NCDIM, which has to be specified as the last argument in the call. * INTEGER INX(NX),INDLR(2,NVEC) ! index vector, tree pointer REAL VECT(NDIM,NVEC) ! table of keys LOGICAL LOWER PARAMETER (MINDC=100) ! default dimension of COMMON/CINDEX/NINDC,NTRY,ISTMAX,INDC(MINDC) ! result index common * ... NINDC=MAX(NCDIM,MINDC) ! actual dimension DO N=1,NVEC ! reset INDLR(1,N)=0 INDLR(2,N)=0 END DO I=1 ! initialize tree DO N=2,NVEC ! loop N start L=1 ! 1. component first I=1 ! treeinsert 10 J=I ! parent LOWER=VECT(INX(L),N).LT.VECT(INX(L),I) ! compare keys IF(LOWER) THEN I=INDLR(1,I) ELSE I=INDLR(2,I) END IF L=MOD(L,NX)+1 ! index of next component IF(I.NE.0) GOTO 10 I=N ! add new key INDLR(1,I)=0 INDLR(2,I)=0 IF(LOWER) THEN INDLR(1,J)=I ELSE INDLR(2,J)=I END IF END DO ! end loop N END