- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I need to know the size of a file. I cant use Win32 for this because the code needs to run on windows and vms. SoI need a fortran specific way...
Thanks in advance,
Markus
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The only way that would work across those two systems is to open the file, read all the records and sum the size. If it is a formatted file and you don't want to count record separators (Windows), then something like this would work (I think)
SIZE=0
DO
READ (1,'(Q)',IOSTAT=IOS) RSIZE
IF (IOS /= 0) EXIT
SIZE = SIZE + RSIZE
END DO
Q is an extension that causes the number of unread bytes remaining in the record to be assigned to the next variable in the I/O list. It is supported by DEC/Compaq Fortran on VMS and by Intel Fortran.
If it is an unformatted file, this is harder.
An alternative is to write a utility routine to get the file size and use conditional compilation in that routine to use an OS-specific method.
SIZE=0
DO
READ (1,'(Q)',IOSTAT=IOS) RSIZE
IF (IOS /= 0) EXIT
SIZE = SIZE + RSIZE
END DO
Q is an extension that causes the number of unread bytes remaining in the record to be assigned to the next variable in the I/O list. It is supported by DEC/Compaq Fortran on VMS and by Intel Fortran.
If it is an unformatted file, this is harder.
An alternative is to write a utility routine to get the file size and use conditional compilation in that routine to use an OS-specific method.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page