Suggestions on mimicing fgetc and fseek with F90
- From: m sutton <mws116@xxxxxxx>
- Date: Wed, 26 Oct 2005 01:30:49 GMT
Hi all,
I know that many compilers have hooks to the C routines fgetc and fseek. I' However, I was hoping to use standard F90 I/O to do this. I read data files that vary from 3MB to 45MB in size. So sometime the whole file is read to access data. Other times I seek into the file to pluck a few bytes out.
Would something like the following be practical
To mimic reading a file in a fgetc fashion
character(1) c1 character(100) text100 open(iunit, fname='foo', form='formatted',access='sequential')
do i =1,100 read(iunit,'(A1)',advance='no')c1 text100(i:i) = c1 end do
The to do a seek followed by a read I was thinking of something like the following that would read characters starting at the 300th character and stopping at the 399th character.
character(1) c1 character(100) text100 open(iunit, fname='foo', form='formatted',access='direct',recl=1)
j = 1 do i =300,399 read(iunit,rec=i)c1 text100(j:j) = c1 j = j +1 end do
Does this seem like a reasonable approach? Are there any known speed issues with this approach? Fgetc and fseek are working for me now, but I would like to removed the non-standard fortran calls.
Thanks in advance,
Mike Sutton
.
- Follow-Ups:
- Re: Suggestions on mimicing fgetc and fseek with F90
- From: Richard Maine
- Re: Suggestions on mimicing fgetc and fseek with F90
- Prev by Date: Re: Character String Operation
- Next by Date: Re: IMPLICIT NONE (F2k8+/-)
- Previous by thread: integer function with generic include file definition
- Next by thread: Re: Suggestions on mimicing fgetc and fseek with F90
- Index(es):
Relevant Pages
|