- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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
- Balises:
- Intel® Fortran Compiler
Lien copié
6 Réponses
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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.
Répondre
Options du sujet
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable