Re: Write position
- From: Dave Allured <nospom@xxxxxxxxxx>
- Date: Mon, 09 Feb 2009 10:18:20 -0700
Glen Herrmannsfeldt wrote:
Dave Allured wrote:
(snip)
I suppose that systems where the assumption breaks down, such as
non-contiguous physical storage of Fortran direct access disk files,
might make an interesting footnote here. I know of one such system from
the 60's, nothing since. My experience range is limited.
For IBM OS/360 and successor systems Fortran direct access files are
stored one record per physical disk block. The disk tracks are
formatted with the appropriate record length (between 1 and the
track length) when the file is first opened. You can't easily
switch between direct access and sequential access.
How are plain text files (sequential formatted) stored on the 360
family? Is it easy to know or enquire the length of a physical disk
block? Given this information, would it not be simple to write a
system-dependent program that would re-write the first few characters of
a very large text file, without changing the rest of the file?
This is not something I recommend as best practice for general
applications. However, this may be the cleanest solution when the
requirements are very large text files and a critical need to update
some header information at the start of each file. For efficiency it
beats using a temp file, hands down.
--Dave
program write_first_line
implicit none
integer, parameter :: block_len = 1024 ! system dependent
character block1*(block_len)
character(*), parameter :: outfile = 'test.dat'
character blank_line_1*40 ! adjust length as needed
integer ncount, n
real result(10000)
open (99, file=outfile, access='sequential')
blank_line_1 = ' '
write (99, *) blank_line_1
ncount = 0
do n = 1, 1000000000, 1
ncount = ncount + 1
result(n) = sqrt (float (n)) ! some calculations
write (99, *) result(n)
if (result(n) > 10.) exit
enddo
close (99)
open (99, file=outfile, access='direct', recl=block_len, &
status='old', action='readwrite')
read (99,rec=1) block1
write (block1(1:10), '(i0)') ncount ! count string
write (99, rec=1) block1
close (99)
end program write_first_line
.
- Follow-Ups:
- Re: Write position
- From: Glen Herrmannsfeldt
- Re: Write position
- From: nmm1
- Re: Write position
- References:
- Write position
- From: Bokgae
- Re: Write position
- From: glen herrmannsfeldt
- Re: Write position
- From: Arjen Markus
- Re: Write position
- From: Bokgae
- Re: Write position
- From: Clive Page
- Re: Write position
- From: Dave Allured
- Re: Write position
- From: Richard Maine
- Re: Write position
- From: Dave Allured
- Re: Write position
- From: Glen Herrmannsfeldt
- Write position
- Prev by Date: Re: Write position
- Next by Date: Re: Write position
- Previous by thread: Re: Write position
- Next by thread: Re: Write position
- Index(es):
Relevant Pages
|