JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Wed Oct 27, 2010 1:36 am Post subject: |
|
|
Bill,
I'm not sure about the difference between achar and char for unusual characters. You could try the following program on both systems and see if there are any differences in either the file or the reading of the file. (The file may have changed when transferred ?) Code: | CHARACTER file_name*128, CMNAM*128, c
INTEGER*4 ic, iostat, count(0:256), n, nc, na, nz
EXTERNAL CMNAM
!
! Open the text file as transparent
!
file_name = CMNAM ()
open (unit =11, &
file =file_name, &
status='OLD', &
form ='UNFORMATTED', &
access='TRANSPARENT', &
iostat=iostat)
write (*,*) 'Opening file ',trim(file_name),' iostat =',iostat
!
! Read all characters
!
count = 0
n = 0
nc = 0
na = 0
nz = 0
!
do
read (unit=11, iostat=iostat) c
if (iostat /= 0) exit
!
n = n+1
ic = ichar(c)
count(ic) = count(ic)+1
select case (ic)
case (0:31)
nc = nc + 1 ! control characters
case (32:126)
na = na + 1 ! normal character
case (127:256)
nz = nz + 1 ! other character
case default
write (*,*) 'Unrecognised character : ichar =',ic
end select
end do
!
if (iostat == -1) then
write (*,*) n,' characters read from file ',trim(file_name)
else
write (*,*) 'end of file after',n,' characters : IOSTAT =',iostat
end if
write (*,*) nc, ' control characters'
write (*,*) na, ' normal characters'
write (*,*) nz, ' non-printable characters'
write (*,2001)
2001 format (/'Count of active characters'/ ' char Count')
2002 format (i5,i8)
do ic = 0,256
if (count(ic) < 1) cycle
if (ic >= 32 .and. ic <= 126) cycle
write (*,2002) ic, count(ic)
end do
end
|
|
|