Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7056 Discussions

Recursive I/O operation

Beginner
724 Views
Hello!
I'm coding pretty big program on cluster, and in one of the subroutines (big_one) I have 2 external routines (their codes are in the end of my message) for computing max eigenvalue. When I'm using one of them, program works. When I'm using another one program exits with error:
`forrtl: severe (40): recursive I/O operation, unit -1, file unknown`
I don't understand logic of error's appearence. It connected somehow with operators sort of "write(*,*) .... ", but why there is recursive operation, I don't know. By throwing out such operators I can delay error, but eventually it happens around such operator. Maybe, deleting all of them will help, but I'd like to understand what's happening. I'll be grateful for any suggestions and advice.

1) routine, which works:

...

END SUBROUTINE big_one

real*8 function maxermeig(N,A) !ne uchityvaetsa symmetrichnost'
!computes maximal eigenvalue of (A+A*)/2
implicit none

integer, intent (in) :: N
real*8 RWORK(N), eig_max
complex*16, intent (in) :: A(N,N)
complex*16 VL(1,1), VR(1,1), W(N), WORK(3*N)
integer INFO, LDA, LDVL, LDVR, LWORK, i

LDA=N
LDVL=1
LDVR=1
LWORK=3*N

call ZGEEV('N','N',N,(A+conjg(transpose(A)))/2.d0,LDA,W,vL,LDVL,VR,LDVR,WORK,LWORK,RWORK,INFO)
if (INFO.ne.0) then
write(*,*) 'maxermeig warning, info=',INFO
endif

eig_max=-4.D+100
do i=1,N
if (dble(w(i)).gt.eig_max) then
eig_max=dble(w(i))
endif
enddo

maxermeig=eig_max

end function maxermeig

2) routine, which crushes program:

Unfortunately, cluster has gone down and I don't have its code right now. The thing is - matrix is symmetric, so I wanted to use this and find it's eigenvalue by proper routines. I used zhetrd to reduce matrix and dsterg to solve problem.

2 Replies
Honored Contributor III
724 Views
The error is probably in the part of the code that you did not show. If you have a WRITE statement in which the I/O list contains an expression with a reference to the function maxermeig, and the variable INFO happens to have such a value as to attempt to do I/O in that function, then you will have a situation of recursive I/O, which will either give you a run-time error or mysterious crashes.

The cure is simple. Instead of coding

write(..,..) aa,bb,maxermeig(...),...

do

tmpvar = maxermeig(...)
write(...,...) aa,bb,tmpvar,...
Beginner
724 Views
Yes, when I googled about this problem, I found that advice, and now there are no such writings in my code, but it still crushes. Also I found post on some forum, where one man had this error occured when OMP_NUM_THREADS was greater than 1. I use OMP, usually with OMP_NUM_THREADS=2, and I've tried to set it to 1 - program still crushed with the same error.
But anyway thanks for reply, mecej4.