- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I have a console application compiled using Intel Visual Fortran Compiler XE 12.0.5.221 [IA-32].
I have attached unit 6 to a file through an open command. When I do
write(6,*) 'This should go to the file'
write(*,*) 'This should go the screen'
both messages are written to the file. This only happens in release mode and only when I compile using IVF not when I compile the same code using CVF (compaq visual fortran).
It was my understanding that even though unit 6 per default represents the screen and can be changed, then * should always represent the screen (when written to).
I have made a simple test program to reproduce the behaviour, but I cannot reproduce the error suggesting that it may be my application that changes the default behaviour of write(*,*). My applicationitselfis to large to append to this thread.
I have spent hours trying to figure out why my program behaves as it does - so I thought I would seek your help. Does anybody have any idea asto what I should be looking for?
Regards
Lars
I have a console application compiled using Intel Visual Fortran Compiler XE 12.0.5.221 [IA-32].
I have attached unit 6 to a file through an open command. When I do
write(6,*) 'This should go to the file'
write(*,*) 'This should go the screen'
both messages are written to the file. This only happens in release mode and only when I compile using IVF not when I compile the same code using CVF (compaq visual fortran).
It was my understanding that even though unit 6 per default represents the screen and can be changed, then * should always represent the screen (when written to).
I have made a simple test program to reproduce the behaviour, but I cannot reproduce the error suggesting that it may be my application that changes the default behaviour of write(*,*). My applicationitselfis to large to append to this thread.
I have spent hours trying to figure out why my program behaves as it does - so I thought I would seek your help. Does anybody have any idea asto what I should be looking for?
Regards
Lars
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The help (see Logical Devices) seems to imply that * and 6 are treatedas distinct but your experience wouldindicate that this is not so. * always to the screen and 6 to the screen unless attached to a file.
Having said that though,the general advice (e.g. the concensus on comp.lang.fortran)for unit numbers for file output is to use numbers > 9
Les
Having said that though,the general advice (e.g. the concensus on comp.lang.fortran)for unit numbers for file output is to use numbers > 9
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is is possible that in your large application you mix I/O operations between Fortran, C and OS calls?
Units * and 6 are initially the same -- an unspecified standard output device. Whether that device is the screen, card punch, printer, plotter, etc. is up to the operating system to select in conjunction with, possibly, environmental variables. Some operating systems allow redirection of output to a different device than the default device.
Unit 6 may be associated with a non-default device using an OPEN statement. Unit * cannot be treated this way. From the Fortran point of view, Unit * guarantees output to the standard output device. However, the output can be diverted at the OS level. Similarly, a C program or a utility program could run your Fortran program with the standard devices reassigned/reconnected to other devices.
Units * and 6 are initially the same -- an unspecified standard output device. Whether that device is the screen, card punch, printer, plotter, etc. is up to the operating system to select in conjunction with, possibly, environmental variables. Some operating systems allow redirection of output to a different device than the default device.
Unit 6 may be associated with a non-default device using an OPEN statement. Unit * cannot be treated this way. From the Fortran point of view, Unit * guarantees output to the standard output device. However, the output can be diverted at the OS level. Similarly, a C program or a utility program could run your Fortran program with the standard devices reassigned/reconnected to other devices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks the input.
I found the cause to be the F2003 semantics compiler setting (properties -> fortran -> Language).
When turned off it works as I intended.
Somehow I got itenabled in the release version and not in the debug version.
The behaviour can be seen by this small test program
Regards
Lars
I found the cause to be the F2003 semantics compiler setting (properties -> fortran -> Language).
When turned off it works as I intended.
Somehow I got itenabled in the release version and not in the debug version.
The behaviour can be seen by this small test program
[bash]program WriteToUnit6 open(unit=6,file='MyOutPut.txt') write(6,*) ' This should go in the file ' write(*,*) ' This should go to the screen' close(6) end program WriteToUnit6[/bash]If F2003 semantics is turned on it will write both lines to the file.
Regards
Lars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The option that changes this behavior is /assume:[no]old_unit_star. The default is noold_unit_star which specifies that unit * and unit 6 are distinct. If /assume:old_unit_star is in effect, then writes to unit * and 6 are treated the same. So I would guess that the release configuration of your project changes this option. As there is no project property for it, look on the Command Line property page under Additional Options.
If you can't figure it out, attach the .vfproj file only and I'll take a look.
If you can't figure it out, attach the .vfproj file only and I'll take a look.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
I do not have any Additional Options set (please see attached .vfproj) file.
As I wrote earlier,if I enable F2003 semmanticsthe outcomebecomes identical to your description of /assume:old_unit_starand if I disable F2003 semmantics I get /assume:[no]old_unit_star - is that to be expected?
Regards
Lars
I do not have any Additional Options set (please see attached .vfproj) file.
As I wrote earlier,if I enable F2003 semmanticsthe outcomebecomes identical to your description of /assume:old_unit_starand if I disable F2003 semmantics I get /assume:[no]old_unit_star - is that to be expected?
Regards
Lars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok - you have the F2003 semantics option different in the debug and release configurations.
If /assume:old_unit_star is in effect, unit * and units 5/6 are distinct.
If /assume:noold_unit_star is in effect, unit * is the same as 5/6
/standard-semantics implies /assume:noold_unit_star
The F2003 standard requires that unit * be the same as INPUT_UNIT and OUTPUT_UNIT from ISO_FORTRAN_ENV.
The default, if you say nothing, is old_unit_star - the documentation is incorrect in saying that it is noold_unit_star and I will have that corrected.
If /assume:old_unit_star is in effect, unit * and units 5/6 are distinct.
If /assume:noold_unit_star is in effect, unit * is the same as 5/6
/standard-semantics implies /assume:noold_unit_star
The F2003 standard requires that unit * be the same as INPUT_UNIT and OUTPUT_UNIT from ISO_FORTRAN_ENV.
The default, if you say nothing, is old_unit_star - the documentation is incorrect in saying that it is noold_unit_star and I will have that corrected.
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