- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I used to put some "write(*,*)" in my code when I want quick and easy checks of what is happening.
Today I encountered an error while doing this with ifort :
Here the sample program :
program test implicit none write(*,*) func(),func() contains function func() real(8) :: func func=0.d0 write(*,*) "Inside func" end function func
And the output:
forrtl: severe (40): recursive I/O operation, unit -1, file unknown
I guess, someway the compiler get lost with a write to * inside a write to *.
Indeed if I change write(*,*) "Inside func" to write(6,*) "Inside func" (6 being preconnected to the default output), the error disappears.
Changing to
write(*,*) func() write(*,*) func()
in the main part is ok too.
Am I missing something in write mechanism that should forbide me to use it this way ?
Gfortran compile and execute without error the code.
Ifort version 14.0.2
Simon.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The standard does not allow you to start an I/O operation on a unit while another operation is already in progress. In ifort, by default, unit * and unit 6 are not the same unit. gfortran apparently has an extension to allow you to do this, but it is an extension.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The standard does not allow you to start an I/O operation on a unit while another operation is already in progress. In ifort, by default, unit * and unit 6 are not the same unit. gfortran apparently has an extension to allow you to do this, but it is an extension.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thanks for the answer, I didn't know that but It makes sense.
I suppose that even if the second change (only one write(*,*) func() per line) works fine, it is incorrect and should not be used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Technically, that is also not allowed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For tracing purposes, you could call the appropriate C runtime library routine directly (after formatting to "internal file"/text variable).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Jim.
I'm not certain to well understand your suggestion.
Can you develop a little more ?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page