Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28593 Discussions

Formatted OPEN don't work in Linux?

likeuclinux
Beginner
1,794 Views
Here is my code, work in windows but not in linux:

program circle
CHARACTER*1 A
INTEGER IOS

OPEN(UNIT = 789,
& FILE= 'charlie.dem',
& FORM = 'FORMATTED',
& ACCESS = 'DIRECT',
& RECL = 1,
& STATUS = 'OLD',
& ERR = 93)

READ(789, REC = 1) A
READ(789, REC = 3, IOSTAT=IOS) A
write (*,*) 'IOS=',IOS,' A=',A
93 write (*,*) 'you have passed...'

stop
end

The file charlie.dem is normal text file you can create by youself.
But in linux I get following error:

forrtl: severe (257): formatted I/O to unit open for unformatted transfers, unit 789, file /home/rong/carmenrt_building/aermap/430/charlie.dem
Image PC Routine Line Source
debugme 080948AF Unknown Unknown Unknown
debugme 08093ECF Unknown Unknown Unknown
debugme 08076F76 Unknown Unknown Unknown
debugme 08069C92 Unknown Unknown Unknown
debugme 0806992D Unknown Unknown Unknown
debugme 080533EA Unknown Unknown Unknown
debugme 08049C3C Unknown Unknown Unknown
debugme 08049B31 Unknown Unknown Unknown
libc.so.6 00740AD4 Unknown Unknown Unknown
debugme 08049A61 Unknown&n bsp; Unknown Unknown

Build this program using: ifort -o debug.exe debug.for.

Please help!!!

0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,794 Views
The error message is backwards - it should say "unformatted I/O to unit open for formatted transfers". You opened unit 789 FORMATTED but are doing unformatted READs from it. Can't do that. My suggestion is that you probably wanted the OPEN to say UNFORMATTED.
0 Kudos
Steven_L_Intel1
Employee
1,794 Views
By the way, it doesn't work on Windows either.
0 Kudos
likeuclinux
Beginner
1,794 Views
Thanks, I solve this in Linux by:

  program circle
CHARACTER*1 A
INTEGER IOS

OPEN(UNIT = 789,
& FILE= 'charlie.dem',
& FORM = 'FORMATTED',
& ACCESS = 'DIRECT',
& RECL = 1,
& STATUS = 'OLD',
& ERR = 93)

READ(789, 6, REC = 1) A
6 format(a1) ---- specify format
READ(789, 7, REC = 3, IOSTAT=IOS) A
7 format(a1) ----- specify format
write (*,*) 'IOS=',IOS,' A=',A
93 write (*,*) 'you have passed...'

stop
end

But the old code do work in windows, I build with compaq virtual fortran 6.6, here it is output
in windows:
D:aermap_testcase430 un>circle.exe
IOS= 0 A=c
you have passed...
0 Kudos
Steven_L_Intel1
Employee
1,794 Views
Ok. It does not work using Intel Fortran on Windows.
0 Kudos
likeuclinux
Beginner
1,794 Views
Maybe that means inter-compiler is more strong-typed than microsoft compiler...:)
0 Kudos
Reply