anchor.diff:      end do read_number_of_nodes
       
   !!!allocate memory to arrays that require node number
  -    if(.not.allocated(nodes_2d)) allocate(nodes_2d(num_nodes_2d))
  -    if(.not.allocated(node_xyz_2d)) allocate(node_xyz_2d(4,10,16,num_nodes_2d))
  -    if(.not.allocated(node_versn_2d)) allocate(node_versn_2d(num_nodes_2d))
  +    if(allocated(nodes_2d))then ! deallocate
  +       deallocate(nodes_2d)
  +       deallocate(node_xyz_2d)
  +       deallocate(node_versn_2d)
  +    endif
  +    allocate(nodes_2d(num_nodes_2d))
  +    allocate(node_xyz_2d(4,10,3,num_nodes_2d))
  +    allocate(node_versn_2d(num_nodes_2d))
       
       !.....read the coordinate, derivative, and version information for each node. 
       np=0
  
positive.code:     if(allocated(data_weight)) deallocate(data_weight)
      allocate(data_weight(3,num_data))
      data_weight(:,1:num_data) = 1.0_dp
      if(offset .gt. 0.0_dp)then
  !!! return the triangles to their original size and location
         forall (i=1:3) vertex_xyz(1:3,i) = (vertex_xyz(1:3,i) - &
              translate(1:3))/scale_mesh
      endif
      
      if(to_export)then
  !!! export vertices as nodes
         writefile = trim(filename)//'.exnode'
         open(10, file = writefile, status='replace')
         !**    write the group name
         write(10,'( '' Group name: '',A)') trim(groupname)
         !*** Exporting Geometry
         !*** Write the field information
         write(10,'( '' #Fields=1'' )')
         write(10,'('' 1) coordinates, coordinate, rectangular cartesian, '',&
              &''#Components=3'')')
         do nj=1,3
            if(nj.eq.1) write(10,'(2X,''x.  '')',advance="no")
            if(nj.eq.2) write(10,'(2X,''y.  '')',advance="no")
            if(nj.eq.3) write(10,'(2X,''z.  '')',advance="no")
            write(10,'(''Value index='',I2,'', #Derivatives='',I1)', &
                 advance="no") nj,0
            write(10,'()')
         enddo
         do i = 1,num_vertices
            !***    write the node
            write(10,'(1X,''Node: '',I12)') i
            write(10,'(2x,3(f12.6))') vertex_xyz(:,i)
         enddo
         close(10)
         
  !!! export the triangles as surface elements
         writefile = trim(filename)//'.exelem'
         open(10, file=writefile, status='replace')
         !**     write the group name
         write(10,'( '' Group name: '',a10)') groupname
         !**     write the lines
         write(10,'( '' Shape. Dimension=1'' )')
         nline=0
         do ne = 1,num_triangles
            write(10,'( '' Element: 0 0 '',I5)') nline+1
            write(10,'( '' Element: 0 0 '',I5)') nline+2
            write(10,'( '' Element: 0 0 '',I5)') nline+3
            nline=nline+3
         enddo !ne
         
         !**        write the elements
         write(10,'( '' Shape. Dimension=2, line*line'' )')
         write(10,'( '' #Scale factor sets=1'' )')
         write(10,'( '' l.Lagrange*l.Lagrange, #Scale factors=4'' )')
         write(10,'( '' #Nodes= '',I2 )') 4
         write(10,'( '' #Fields=1'' )')
         write(10,'( '' 1) coordinates, coordinate, rectangular cartesian, #Components=3'')')
         
         do nj=1,3
            if(nj==1) char1='x'; if(nj==2) char1='y'; if(nj==3) char1='z';
            write(10,'(''  '',A2,''. l.Lagrange*l.Lagrange, no modify, standard node based.'')') char1
            write(10,'( ''   #Nodes=4'')')
            do nn=1,4
               write(10,'(''   '',I1,''. #Values=1'')') nn
               write(10,'(''     Value indices: '',I4)') 1
               write(10,'(''     Scale factor indices: '',I4)') nn
            enddo !nn
         enddo !nj
         
         nline=0
         do ne=1,num_triangles
            !**         write the element
            write(10,'(1X,''Element: '',I12,'' 0 0'' )') ne
            !**          write the faces
            WRITE(10,'(3X,''Faces: '' )')
            WRITE(10,'(5X,''0 0'',I6)') nline+1
            WRITE(10,'(5X,''0 0'',I6)') nline+2
            WRITE(10,'(5X,''0 0'',I6)') nline+3
            WRITE(10,'(5X,''0 0'',I6)') 0
            nline=nline+3
            !**          write the nodes
            write(10,'(3X,''Nodes:'' )')
            write(10,'(4X,4(1X,I12))') triangle(:,ne),triangle(3,ne)
            !**          write the scale factors
            write(10,'(3X,''Scale factors:'' )')
            write(10,'(4X,4(1X,E12.5))') 1.0_dp,1.0_dp,1.0_dp,1.0_dp
         enddo
         close(10)
      endif
      
      deallocate(triangle)
      deallocate(vertex_xyz)
      
      call enter_exit(sub_name,2)
      
    end subroutine make_data_grid
  
negative.code:     allocate(data_weight(3,num_data))
      
  !!! read the data point information
      open(10, file=readfile, status='old')
      read(unit=10, fmt="(a)", iostat=ierror) buffer
      
      !set the counted number of data points to zero
  