Re: Write position



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
.



Relevant Pages

  • Re: Write position
    ... non-contiguous physical storage of Fortran direct access disk files, ... For IBM OS/360 and successor systems Fortran direct access files are ... stored one record per physical disk block. ...
    (comp.lang.fortran)
  • Re: detecting end of a direct access file
    ... access method that a program might use on a file. ... direct access, why should the known end of the file suddenly ... RecNum = RecNum + I ... based on the size of the file on the disk. ...
    (comp.lang.fortran)
  • Re: Hey Class, this is me again, dont you see?
    ... Suppose they are Word files or pictures. ... In the example the cDoc1-Type (which stores ... different Document-File-representation on disk. ... a more direct access (maybe specifying the FileName as ...
    (microsoft.public.vb.general.discussion)
  • Help - Problems with Chkdsk
    ... This is a Toshiba Tecra 9000 with a XP Pro upgrade over a ... message "Cannot open volume for direct access". ... Is there a way to force the check disk to take place. ...
    (microsoft.public.windowsxp.general)
  • Re: detecting end of a direct access file
    ... sequential or direct access, and that is a favorite way to ... in the first record, such as the number of records in the file. ... based on the size of the file on the disk. ...
    (comp.lang.fortran)