- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am using a staticfortran lib in c++ applications. The routines of the fortran lib write status messages via write(6,*). When linking the fortran lib to a console application everything works fine and the messages are passed to stdout of the c++ application. But linking the lib to a window gui application based on qt (trolltech) the following run-time error occured when calling the fortran routine:
"forrtl severe (38): error during write, unit 6, file CONOUT$"
Any suggestions?
Bruno
I am using a staticfortran lib in c++ applications. The routines of the fortran lib write status messages via write(6,*). When linking the fortran lib to a console application everything works fine and the messages are passed to stdout of the c++ application. But linking the lib to a window gui application based on qt (trolltech) the following run-time error occured when calling the fortran routine:
"forrtl severe (38): error during write, unit 6, file CONOUT$"
Any suggestions?
Bruno
Link Copied
12 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no stdout defined in a windows gui application. You can create one by calling AllocConsole() (a Win32 API routine.)
Previous versions of Intel Fortran would silently ignore writes to a non-existent console - this changed in 11.1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Bruno Arbter
Hi,
I am using a staticfortran lib in c++ applications. The routines of the fortran lib write status messages via write(6,*). When linking the fortran lib to a console application everything works fine and the messages are passed to stdout of the c++ application. But linking the lib to a window gui application based on qt (trolltech) the following run-time error occured when calling the fortran routine:
"forrtl severe (38): error during write, unit 6, file CONOUT$"
Any suggestions?
Bruno
I am using a staticfortran lib in c++ applications. The routines of the fortran lib write status messages via write(6,*). When linking the fortran lib to a console application everything works fine and the messages are passed to stdout of the c++ application. But linking the lib to a window gui application based on qt (trolltech) the following run-time error occured when calling the fortran routine:
"forrtl severe (38): error during write, unit 6, file CONOUT$"
Any suggestions?
Bruno
Hello
I think that the syntax :
write(6,IOSTAT=ioerr,*)
may solve the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, both, write(6,IOSTAT=ioerr) and AllocConsole() prevents the run-time error.
But how can I catch the messages in C++?
In the moment, within my GUI application, I redirect all my status (printf)-messages of the C functions from stdout to a log-file via freopen( "./test.log", "w", stdout ). (By the way, that worked without creating a console...) But (write)-messages from the fortran-lib are not catched, when using write(6,IOSTAT=ioerr), and are catched only to the created console using AllocConsole(). I want to have all messages in the log-file.
Any Idea?
Bruno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Bruno Arbter
Thanks, both, write(6,IOSTAT=ioerr) and AllocConsole() prevents the run-time error.
But how can I catch the messages in C++?
In the moment, within my GUI application, I redirect all my status (printf)-messages of the C functions from stdout to a log-file via freopen( "./test.log", "w", stdout ). (By the way, that worked without creating a console...) But (write)-messages from the fortran-lib are not catched, when using write(6,IOSTAT=ioerr), and are catched only to the created console using AllocConsole(). I want to have all messages in the log-file.
Any Idea?
Bruno
Mixing Fortran and C/C++ I/O to the same file - the simplest way is for the Fortran code to call a C/C++ function (instead of the write statement) with the string to be printed and let the C/C++ printf handle it (as you already have that).
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hei,
I have the same problem, but only in release configuration.
My main application is in C++ compiled by MSVC .NET 2003 and it links to fortran libraries compiled by Intel Fortran 8.1
By using freopen("myfile.txt", "w", stdout) in C++, all printouts from fortran go to my file in debug configuration, but not in release configuration. I guess that because the application has a console in debug, but not in release. Besides I understand that this behavior has changed in Intel fortran 11.1 and that the program may crash if there are no console!
As I have thousands of fortran prints, I can not change the fortran code.
Please advise how to fix this problem?
Ludovic
I have the same problem, but only in release configuration.
My main application is in C++ compiled by MSVC .NET 2003 and it links to fortran libraries compiled by Intel Fortran 8.1
By using freopen("myfile.txt", "w", stdout) in C++, all printouts from fortran go to my file in debug configuration, but not in release configuration. I guess that because the application has a console in debug, but not in release. Besides I understand that this behavior has changed in Intel fortran 11.1 and that the program may crash if there are no console!
As I have thousands of fortran prints, I can not change the fortran code.
Please advise how to fix this problem?
Ludovic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As Les Neilson has already pointed out, mixing C and Fortran output to the same channel has many chances of failing or not working correctly. Perhaps, this analogy may help to see why:
C and Fortran, in general, use different I/O subsystems. Think of C as writing to buffer CBuf, and Fortran writing to a separate buffer FBuf. The C runtime flushes CBuf based on its conscience, and Fortran does likewise with FBuf. The order in which lines of output appear in the composite output file at the end of the run is indeterminate.
C and Fortran, in general, use different I/O subsystems. Think of C as writing to buffer CBuf, and Fortran writing to a separate buffer FBuf. The C runtime flushes CBuf based on its conscience, and Fortran does likewise with FBuf. The order in which lines of output appear in the composite output file at the end of the run is indeterminate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With a current 11.1 version, writes to stdout without a console should not cause an error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply.
Actually mixing C and Fortran output to the same channel works perfectly well!
It works on Linuxin both debug and release configuration.
But it works on Windows onlyin debug configuration.
In release configuration on Windows, I get only outputfrom C++ to my file, not any longerfrom Fortran.
As I understand, Intel Fortran compiler just ignores outputsif it does not find any console. In my case, I don't need to output to a console but to a file.
Is there any option to force compiler tohandle outputs even if there is no console?
It may seem absurb to ask for such an option, but once again, when redirecting toa file there is no need to have a console.
Thanks,
Ludovic
Actually mixing C and Fortran output to the same channel works perfectly well!
It works on Linuxin both debug and release configuration.
But it works on Windows onlyin debug configuration.
In release configuration on Windows, I get only outputfrom C++ to my file, not any longerfrom Fortran.
As I understand, Intel Fortran compiler just ignores outputsif it does not find any console. In my case, I don't need to output to a console but to a file.
Is there any option to force compiler tohandle outputs even if there is no console?
It may seem absurb to ask for such an option, but once again, when redirecting toa file there is no need to have a console.
Thanks,
Ludovic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
do you think that my problem will be solved by using 11.1 version?
I quote a previous post: "Previous versions of Intel Fortran would silently ignore writes to a non-existent console - this changed in 11.1."
Ludovic
do you think that my problem will be solved by using 11.1 version?
I quote a previous post: "Previous versions of Intel Fortran would silently ignore writes to a non-existent console - this changed in 11.1."
Ludovic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you write to unit 6 without opening it to a file, and there is no console, the write will have no effect in current 11.1 versions.
If you know you will want the output to go to a file, open unit 6 to a file.
If you know you will want the output to go to a file, open unit 6 to a file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thanks.I will try topass the filename from C++ to Fortran at runtime and open unit 6 to it.
Ludovic
Ludovic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good answer. I can't find this or the error message below in the 11.1 Release Notes? I'm guessing AllocConsole can be called from Fortran or open CONOUT$?
For multi-user multi-threaded support, we concerned about closing CONOUT$
Intel Visual Fortran run-time error: forrtl: severe (38): error during write, unit 6, file CONOUT$
For multi-user multi-threaded support, we concerned about closing CONOUT$
![](/skins/images/8B6E2C8F64F54CBD7F7262AA46F575DA/responsive_peak/images/icon_anonymous_message.png)
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