anchor.diff:      ! prepare print format
       numfor = '('//trim(nformat)//',A,$)'
       
  -    open (unit=1, file=filein, form='unformatted', access='stream')
  +    open (unit=1, file=filein, form='unformatted', access='stream', status='old')
       open (unit=2, file=fileout)
       
       ! read the File name: 1-4 and 9-12
  -    read (unit=1, pos=1) text4
  -    write (*,'(A, $)') text4
  -    read (unit=1, pos=9) text4
  -    write (*,'(A)') text4
  -
  +    read (unit=1, pos=1,err=99) text4
  +    read (unit=1, pos=9,err=99) text4b
  +    write (*,*) 'File name:', text4//text4b
  +
  +    
       ! read the Database name:     17-20 and 25-28
  -    read (unit=1, pos=17) text4
  -    write (*,'(A, $)') text4
  -    read (unit=1, pos=25) text4
  -    write (*,'(A)') text4
  +    read (unit=1, pos=17,err=99) text4
  +    read (unit=1, pos=25,err=99) text4b
  +    write (*,*) 'Database name:', text4//text4b
   
       
       ! read the File description : 33-36,41-44,...,185-188
       p=33
       l=1
  +    desc= '' 
       do i=1,20
  -        read (unit=1, pos=p) text4
  +        read (unit=1, pos=p,err=99) text4
           desc(l:l+4)= text4
           p=p+8
           l=l+4
       end do
  -    
  -    write (*,*) 'one line description: ', desc
  -    
  +    write (*,*) 'File description: ', desc
  +    
  +       
       ! Numeric date coded as 10000*year + 100*month + day: 193-200
  -    read (unit=1, pos=193) numcode
  -    write (*,'(A,I10)') 'Numeric date coded: ', int(numcode)
  +    read (unit=1, pos=193,err=99) numcode
  +    write (*,*) 'Numeric date coded: ', int(numcode)
   
       ! Total number of fields in the file (alpha fields are counted as the number of 4-byte blocks they occupy): 201-208 193-200
  -    read (unit=1, pos=201) nfield
  -    write (*,'(A,I10)') 'n fields: ', int(nfield)
  +    read (unit=1, pos=201,err=99) nfield
  +    write (*,'(A,I10)') 'Number of fields: ', int(nfield)
       
       ! Number of last page in the file: 209-216
  -    read (unit=1, pos=209) npages
  +    read (unit=1, pos=209,err=99) npages
       write (*,'(A,I10)') 'Number of last page in the file: ', int(npages)
       
       ! Number of last logical data record within the last page:     217-224
  -    read (unit=1, pos=217) nreclastpage
  +    read (unit=1, pos=217,err=99) nreclastpage
       write (*,'(A,I10)') 'Logical records in last page: ', int(nreclastpage)
  +    
       
       write (*,*) ''
       write (*,*) '*****************************************'
  
positive.code:             line = line+1
              do k=1, int(nfield)
                  ! if is a numeric field
                  if (vartype(k) == 'N') then
                      read (unit=1, pos=p) li
                      write (2,numfor) li, ','
                      p=p+8
                  end if 
                  ! if is string caracter
                  if (vartype(k)=='A') then
  					read (unit=1, pos=p) text4
  					write (2,'(A,A,$)',advance='no') text4, ','
  					p=p+8
                  end if 
              end do
              write (2,*) line
          end do
          p= i*4096+1 !next page position
      end do
      
      !read last page
      do j=1, int(nreclastpage)
          line = line+1
          do k=1, int(nfield)
              ! if is a numeric field
              if (vartype(k) == 'N') then
                  read (unit=1, pos=p) li
                  write (2,numfor) li, ','
                  p=p+8
              end if 
              ! if is string caracter
              if (vartype(k)=='A') then
                  do l=1, numofwords(i)
                      read (unit=1, pos=p) text4
                      write (2,'(A,A,$)',advance='no') text4, ','
                      p=p+8
                  end do 
              end if 
          end do
          write (2,*) line
      end do
  
negative.code:     close (unit =1)
      close (unit =2)
  
      return
      
      99 error=99 !'error in data file!'
  
      write (*,*) 'I/O error' 
      
      close (unit =1)
      close (unit =2)
      
  end subroutine dm2csv_ep
  