Compatibility between Compaq Visual Fortran and gfortran
Paul Thomas
paulthomas2@wanadoo.fr
Fri Feb 18 21:58:00 GMT 2005
Jens,
Having been doing Disneyland with my daughter - hence the slow reply. I
strongly suggest that you spend some time with a good introductory text on
fortran. However, taking my last rendition:
program read_character
implicit none
character(len=4) :: ch(8)
integer, dimension(10) :: nbuf
integer, dimension(10, 20) :: npar
integer :: i
!
! This next statement "overlaps" the third member of the integer array NBUF
with the character array CH.
!
equivalence (ch,nbuf(3))
open (unit = 10, file = 'test.par', status = 'old')
do i = 1, 20
!
! We now read the data as 2 integers and 8 character*4s
!
read (10, '(2I3, 2X, 8A4)') nbuf(1:2), ch(1:8)
!
! Transfer the integer buffer, which contains the ASCII character codes
!
npar(:, i) = nbuf
end do
close(10)
!
! Printing the last 8 integers in hex brings out the ASCII code for "TEST" ;
54 53 45 54
!
write (*,'(2i3,8z8)') npar !check read is correct
end program read_character
More information about the Fortran
mailing list