anchor.diff:  
          map_seed_to_elem(nd_min)=0
   
  -    ENDIF
  +    endif
   
       INTERNAL=.FALSE.
       COUNT=0
  -    DO WHILE(.NOT.INTERNAL.AND.COUNT.LT.2)
  +    do while(.NOT.INTERNAL.and.COUNT.lt.2)
          candidate_xyz(1:3) = node_xyz(1:3,np)
          !                  call CHECK_POINT_INTERNAL(IBT,Ido,INP,NBJ,NDLIST,NEELEM, &
          !                       NEP,NHOST,NKJE,np,np1,NPF,NPNE,NVJE,elem_cnct,SE,XA, &
          !                       XE,XIP,XP,candidate_xyz,data_xyz,INTERNAL,.FALSE.)
  -       internal=.TRUE.
  -       IF(.NOT.internal)THEN
  +       internal=.true.
  +       if(.not.internal)then
             length = distance_between_points(node_xyz(1,np1),node_xyz(1,np))
  -          !          node_xyz(1:3,np) = node_xyz(1:3,np1)+0.5_dp*length*elem_direction(1:3,np)
  +!          node_xyz(1:3,np) = node_xyz(1:3,np1)+0.5_dp*length*elem_direction(1:3,np)
             node_xyz(1:3,np) = node_xyz(1:3,np1)+0.5_dp*length*elem_direction(1:3,ne)
  -          CALL reduce_branch_angle(np1,np2,np,candidate_xyz,0.5_dp) ! reduces the branch angle by a half
  -       ENDIF
  +          call reduce_branch_angle(np1,np2,np,candidate_xyz,0.5_dp) ! reduces the branch angle by a half
  +       endif
          COUNT=COUNT+1
  -    ENDDO !while
  -    IF(.NOT.INTERNAL)THEN
  +    enddo !while
  +    if(.NOT.INTERNAL)then
          !...............Remove the branch from the list of next generation parents
          offset=0
  -       DO nes=1,num_next_parents
  -          IF(local_parent_temp(nes).EQ.ne) offset=1
  +       do nes=1,num_next_parents
  +          if(local_parent_temp(nes).eq.ne) offset=1
             local_parent_temp(nes)=local_parent_temp(nes+offset)
  -       ENDDO
  +       enddo
          num_next_parents=num_next_parents-1
          num_terminal=num_terminal+1
          !...............Remove the closest data point to the end of the branch
  
positive.code:     w = mesh_a_x_eq_b(A,VECTOR)
      vector_for_angle_limit = unit_vector(W)
  
    END FUNCTION vector_for_angle_limit
  
  
    !###############################################################
  
  END MODULE growtree
  
  !###############################################################
  
negative.code: !!! check whether the centre of mass and the parent start & end branches
  !!! are co-linear. if so, will need to use 'aunt' branch for split
      colinear = check_colinear_points(P,Q,R)
      if(colinear) R(1:3) = node_xyz(1:3,np3) !split based on parent and aunt
      call make_plane_from_3points(NORML,1,P,Q,R) !calculate plane
  
      NPOINTS=0
      DAT1=0
      DAT2=0
      ND1_1ST=0
      ND2_1ST=0
      do nd=1,num_data
         nsp=map_seed_to_elem(nd) !space # that random point belongs to
         if(nsp.eq.ne1)then !random point belongs to this element space
            NPOINTS=NPOINTS+1
            dist = -scalar_product_3(norml,data_xyz(1,nd)) - norml(4) ! distance between two planes
            if(dist.ge.0.0_dp)then
               if(dat1.eq.0) nd1_1st = nd
               DAT1=DAT1+1
               map_seed_to_elem(nd)=ne+1
            else if(DIST.lt.0.0_dp)then
               if(DAT2.eq.0) ND2_1ST=nd
               DAT2=DAT2+1
               map_seed_to_elem(nd)=ne+2
            endif
         endif
      enddo !nd
  
      if(dat1.eq.0.and.dat2.eq.0)then
         enough_points = .false.
         write(*,'('' Zero seed points associated with parent'',I6)') ne1
         read(*,*)
      else
         if(dat1.eq.0)then
            map_seed_to_elem(nd2_1st) = ne+1
            dat1 = dat1+1
            dat2 = dat2-1
         elseif(dat2.eq.0)then
            map_seed_to_elem(nd1_1st) = ne+2
            dat2 = dat2+1
            dat1 = dat1-1
         endif
  
         enough_points = .true.
      endif
  
      call enter_exit(sub_name,2)
  
    end subroutine split_seed_points
  
  
    !###############################################################
  