Are there any plans for the @ functions (e.g. FPOS@) to support full 8-byte positioning?
K
Welcome to our forums
Are there any plans for the @ functions (e.g. FPOS@) to support full 8-byte positioning?
K
No but if you can give me a list of the relevant functions then it would not be a major task.
OK,
I envisage as a minimum:
FPOS8@ RFPOS8@
And possibly:
READF8@ WRITEF8@
That'll do for starters!
tks
K
Paul,
The following is taken from my interface to the salford file i/o routines, where I have updated the file position to integer8. The byte_size could also be integer8, should an individual record be larger than 2^31 bytes, although this is not as important. Also the file handle (lunit) and error_code are integer2, which could be changed to integer4. These routines provide all the functionality I use, apart from closef@, file_size8@ and erase@.
The changes, both needed and possible are: rfpos@ need I8:file_position fpos@ need I8:file_position
writef@ could have I8:byte_size readf@ could have I8: byte_size, bytes_read openrw@ could have I4:lunit, error_code doserr@ closef@ file_size8@ could have I8:file_size erase@
subroutine open_salford_io ( file_name, lunit, error_code )
!
! File I/O using Salford I/O library
!
character file_name*(*)
integer*2 lunit, error_code
!
lunit = -1
CALL openrw@ (file_name, lunit, error_code)
write ( *,*) 'OPEN : File = ', trim (file_name)
write ( *,*) 'OPEN : Handle =', lunit
write ( *,*) 'OPEN : Error code =', error_code
write (98,*) 'OPEN : File = ', trim (file_name)
write (98,*) 'OPEN : Handle =', lunit
write (98,*) 'OPEN : Error code =', error_code
if (error_code.ne.0) call doserr@ (error_code)
!
end subroutine open_salford_io
subroutine getpos_salford_io ( lunit, file_position )
!
! File I/O using Salford I/O library
!
integer*2 lunit, error_code
integer*8 file_position
!
call rfpos@ (lunit, file_position, error_code) ! get byte position, first is 0
if (error_code.ne.0) call doserr@ (error_code)
!
end subroutine getpos_salford_io
subroutine setpos_salford_io ( lunit, file_position )
!
! File I/O using Salford I/O library
!
integer*2 lunit, error_code
integer*8 file_position, new_position
!
call fpos@ (lunit, file_position, new_position, error_code) ! get byte position, first is 0
if (file_position.ne.new_position) write ( *,*) 'File position error', file_position, new_position
if (file_position.ne.new_position) write (98,*) 'File position error', file_position, new_position
if (error_code.ne.0) call doserr@ (error_code)
!
end subroutine setpos_salford_io
subroutine write_salford_io ( lunit, buffer, byte_size, file_position )
!
! File I/O using Salford I/O library
!
integer*2 lunit, error_code
integer*4 byte_size
integer*8 file_position
real*8 buffer(*)
!
if (file_position /= -1) call setpos_salford_io ( lunit, file_position )
!
call writef@ (buffer, lunit, byte_size, error_code)
if (error_code.ne.0) call doserr@ (error_code)
!
end subroutine write_salford_io
subroutine read_salford_io ( lunit, buffer, byte_size, file_position )
!
! File I/O using Salford I/O library
!
integer*2 lunit, error_code
integer*4 byte_size, bytes_read
integer*8 file_position
real*8 buffer(*)
!
if (file_position /= -1) call setpos_salford_io ( lunit, file_position )
!
call readf@ (buffer, lunit, byte_size, bytes_read, error_code)
if (bytes_read.ne.byte_size) write ( *,*) 'Bytes read error', byte_size, bytes_read
if (bytes_read.ne.byte_size) write (98,*) 'Bytes read error', byte_size, bytes_read
if (error_code.ne.0) call doserr@ (error_code)
!
end subroutine read_salford_io
Kenny and John: Thanks for the feedback.
The following undocumented Win32 routines have now been ported to 64 bits for the next release: FPOSLONG@, RFPOSLONG@ and FPOS_EOFLONG@. These are similar to FPOS@, RFPOS@ and FPOS_EOF@ but take INTEGER8 position arguments. Note that other arguments are still INTEGER2.
READFLONG@ and WRITEFLONG@ don't exist at the moment but hopefully are less urgent.
Would it be possible to now add also READFLONG@ and WRITEFLONG@? I checked in 8.40 and they don't seem to be there. Thanks
I have added these routines and a new DLL can be downloaded from here...
https://www.dropbox.com/s/ak5r1ghhiq0pml5/newDLLs29.zip?dl=0
Here is some sample code used for testing...
program main
implicit none
integer(4),parameter::N = 4294967296_4 !4GB
character(len=N) buffer
integer(2) handle,ierror
integer(4) bytes_read
call OPENR@('xxxxx', handle, ierror)
call READFLONG@(buffer, handle, N, bytes_read, ierror)
call CLOSEF@(handle, ierror)
call OPENW@('zzzzzz', handle, ierror)
call WRITEFLONG@(buffer, handle, bytes_read, ierror)
call CLOSEF@(handle, ierror)
end
I forgot to thank you Paul for the quick fix. I can confirm that the calls are there now. Thanks again