- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I am trying to switch from Open Watcom Fortran (OWF) to Intel Visual Fortran (IVF) and I came across the following problem: the same code, hopefully conforming the Fortran 77 standard, works well in OWF, but causes a runtime reading error in IVF. The code tries to read a file (created by VC++):
OPEN ( 99,FILE=finame, ACCESS='DIRECT', STATUS='OLD',
+ RECL=2000, IOSTAT=iocheck, SHARE='DENYWR' )
READ( 99,REC=1,IOSTAT=ios)txcsl,txx,month,year,vermod,
+ revmod,vercad,(ide(i),i=1,160),(rde(i),i=1,160),
+ (lode(i),i=1,65),empty1,empty2
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=2, IOSTAT=ios ) cx0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=3, IOSTAT=ios ) cy0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=4, IOSTAT=ios ) cz0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=5, IOSTAT=ios ) dx0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=6, IOSTAT=ios ) dy0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=7, IOSTAT=ios ) dz0
if ( ios.ne.0 ) rd = .false.
where particular variables are defined in a common block as:
integer*4 mdi
character*55 txcsl, txx
real*4 rde, month, year, vermod, revmod, vercad
integer*4 ide
logical*4 lode
real*4 dx0, dy0, dz0, cx0, cy0, cz0
character*55 empty1
character*275 empty2
parameter ( mdi=500 )
common /original_arrays/ dx0(mdi), dy0(mdi), dz0(mdi),
+ cx0(mdi), cy0(mdi), cz0(mdi)
common /data/ rde(160), ide(160), lode(65)
The first record is read correctly, the second one seems so too (ios equals 0), but I know that values in cx0 are wrong and different from the correct ones, and reading the third record ends up with ios equal to 36 which I found to be "severe (36): Attempt to access non-existent record".
I counted bytes in the first record to make sure they sum up to 2000 (55+55+5*4+(160+160+65)*4+55+275), I sought any clues on Internet, but did not find anything. I am also sure that I have this problem with the same file which is read by OWF without any problems.
Would you please let me know what I am doing wrong? Thank you in advance.
I am trying to switch from Open Watcom Fortran (OWF) to Intel Visual Fortran (IVF) and I came across the following problem: the same code, hopefully conforming the Fortran 77 standard, works well in OWF, but causes a runtime reading error in IVF. The code tries to read a file (created by VC++):
OPEN ( 99,FILE=finame, ACCESS='DIRECT', STATUS='OLD',
+ RECL=2000, IOSTAT=iocheck, SHARE='DENYWR' )
READ( 99,REC=1,IOSTAT=ios)txcsl,txx,month,year,vermod,
+ revmod,vercad,(ide(i),i=1,160),(rde(i),i=1,160),
+ (lode(i),i=1,65),empty1,empty2
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=2, IOSTAT=ios ) cx0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=3, IOSTAT=ios ) cy0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=4, IOSTAT=ios ) cz0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=5, IOSTAT=ios ) dx0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=6, IOSTAT=ios ) dy0
if ( ios.ne.0 ) rd = .false.
if ( rd ) READ ( 99, REC=7, IOSTAT=ios ) dz0
if ( ios.ne.0 ) rd = .false.
where particular variables are defined in a common block as:
integer*4 mdi
character*55 txcsl, txx
real*4 rde, month, year, vermod, revmod, vercad
integer*4 ide
logical*4 lode
real*4 dx0, dy0, dz0, cx0, cy0, cz0
character*55 empty1
character*275 empty2
parameter ( mdi=500 )
common /original_arrays/ dx0(mdi), dy0(mdi), dz0(mdi),
+ cx0(mdi), cy0(mdi), cz0(mdi)
common /data/ rde(160), ide(160), lode(65)
The first record is read correctly, the second one seems so too (ios equals 0), but I know that values in cx0 are wrong and different from the correct ones, and reading the third record ends up with ios equal to 36 which I found to be "severe (36): Attempt to access non-existent record".
I counted bytes in the first record to make sure they sum up to 2000 (55+55+5*4+(160+160+65)*4+55+275), I sought any clues on Internet, but did not find anything. I am also sure that I have this problem with the same file which is read by OWF without any problems.
Would you please let me know what I am doing wrong? Thank you in advance.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran follows the DEC Fortran convention of using 4-byte units for RECL of unformatted files. Add /assume:byterecl to get the RECL unit to be bytes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your code is far from "conforming to Fortran 77 standard," but that isn't your biggest problem. You must bear in mind that no C++ supports Fortran direct access files, nor did any Fortran standard ever specify that direct access files could be made compiler independent. These are among the reasons for STREAM files in current Fortran. Nor is there any high level interoperability between CHARACTER data type and C file formats, except as specified by the C interoperability feature of current Fortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, thank you, it of course helped and the file is read without any errors now.
I must admit that I have been writing and updating the code in Watcom Fortran for many years without considering the Fortran 77 standard, so I'd rather not have mentioned it in my previous post :-[
I and my colleagues have been dealing with the data exchange between C++ and Fortran programs for quite a long time, but it has always been Fortran 77 and its extensions. I am now adjusting the (huge) code to be able to compile it with Intel Visual Fortran and add some new features. So, I will consider also rewriting the I/O file operations.
I must admit that I have been writing and updating the code in Watcom Fortran for many years without considering the Fortran 77 standard, so I'd rather not have mentioned it in my previous post :-[
I and my colleagues have been dealing with the data exchange between C++ and Fortran programs for quite a long time, but it has always been Fortran 77 and its extensions. I am now adjusting the (huge) code to be able to compile it with Intel Visual Fortran and add some new features. So, I will consider also rewriting the I/O file operations.
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