anchor.diff:      elem_symmetry(1:num_elems)=nodelem_temp(1:num_elems)
       deallocate(nodelem_temp) !deallocate the temporary array
       elem_symmetry(num_elems+1:num_elems_new)=1
  -    
  +
       allocate(enodes_temp2(-1:1,0:2,0:num_elems))
       enodes_temp2=elem_cnct
       deallocate(elem_cnct)
  
positive.code: !###################################################################################
  !
     
    subroutine reallocate_node_elem_arrays(num_elems_new,num_nodes_new)
      
      use arrays,only: num_nodes,nodes,num_elems,elem_nodes,elem_symmetry,node_field,&
  elem_direction,elems_at_node,expansile,elem_cnct,elem_field,elem_ordrs,dp,node_xyz,elems
      use indices,only:num_ne,num_nj,num_ord
      use diagnostics,only: enter_exit
  
      integer,intent(in) :: num_elems_new,num_nodes_new
      integer,allocatable :: nodelem_temp(:),enodes_temp(:,:),enodes_temp2(:,:,:)
      real(dp),allocatable :: xyz_temp(:,:),rnodes_temp(:,:)
      logical,allocatable :: exp_temp(:)
      character(len=60) :: sub_name
      
      ! ###########################################################################
      
      sub_name = 'reallocate_node_elem_arrays'
      call enter_exit(sub_name,1)
      
      allocate(nodelem_temp(num_nodes))
      nodelem_temp = nodes ! copy to temporary array
      deallocate(nodes) !deallocate initially allocated memory
      allocate(nodes(num_nodes_new))
      nodes(1:num_nodes)=nodelem_temp(1:num_nodes)
      deallocate(nodelem_temp) !deallocate the temporary array
      !write(*,*) 'number of nodes:',num_nodes,num_nodes_new    
      allocate(xyz_temp(3,num_nodes))
      xyz_temp=node_xyz
      deallocate(node_xyz)
      allocate(node_xyz(3,num_nodes_new))
      node_xyz(1:3,1:num_nodes)=xyz_temp(1:3,1:num_nodes)
      
      allocate(nodelem_temp(num_elems))
      nodelem_temp = elems ! copy to temporary array
      deallocate(elems) !deallocate initially allocated memory
      allocate(elems(num_elems_new))
      elems(1:num_elems)=nodelem_temp(1:num_elems)
      deallocate(nodelem_temp) !deallocate the temporary array
      !write(*,*) 'number of elems:',num_elems,num_elems_new
      allocate(enodes_temp(2,num_elems))
      enodes_temp=elem_nodes
      deallocate(elem_nodes)
      allocate(elem_nodes(2,num_elems_new))
      elem_nodes(1:2,1:num_elems)=enodes_temp(1:2,1:num_elems)
      deallocate(enodes_temp)
      !write(*,*) 'elem field:', elem_field
      !allocate(rnodes_temp(num_ne,num_elems))
      !rnodes_temp=elem_field
      !write(*,*) '1st', num_ne
      !deallocate(elem_field)
      !write(*,*) '2nd'
      !allocate(elem_field(num_ne,num_elems_new))
      !elem_field(1:num_ne,1:num_elems)=rnodes_temp(1:num_ne,1:num_elems)
      !deallocate(rnodes_temp)
      !elem_field(1:num_ne,num_elems+1:num_elems_new) = 0.0_dp
      
      allocate(rnodes_temp(3,num_elems))
      rnodes_temp=elem_direction
      deallocate(elem_direction)
  
negative.code:     expansile(num_elems+1:num_elems_new)=.false.
  
      call enter_exit(sub_name,2)
  
    end subroutine reallocate_node_elem_arrays
  
  !!!###############################################################
  
  