Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

write(*,*) in function called by another write(*,*)

$
0
0

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.


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>