Silverfrost Forums

Welcome to our forums

reading files > 4Gb

25 May 2016 10:52 #17512

Are there any plans for the @ functions (e.g. FPOS@) to support full 8-byte positioning?

K

25 May 2016 2:07 #17513

No but if you can give me a list of the relevant functions then it would not be a major task.

25 May 2016 2:26 #17514

OK,

I envisage as a minimum:

FPOS8@ RFPOS8@

And possibly:

READF8@ WRITEF8@

That'll do for starters!

tks

K

27 May 2016 8:35 #17521

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
30 May 2016 5:54 #17522

Kenny and John: Thanks for the feedback.

6 Jun 2016 9:52 #17553

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.

19 Dec 2018 11:53 #23037

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

20 Dec 2018 10:32 #23039

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
22 Jan 2019 10:11 #23161

I forgot to thank you Paul for the quick fix. I can confirm that the calls are there now. Thanks again

Please login to reply.