Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Help with fortran error outputting

jakin1
초급자
486 조회수
Hi,

I'm currently trying to debug some fortran code that I have, and to check whether there have been any errors in the execution of the code I have included the section:

IF (err /= 0) THEN
write(*,*) 'Error encountered'
ELSE
write(*,*) ' working'
END IF

at the end of the program. This is currently showing that there have been errors encountered in the execution of the code, but I don't actually know where - they aren't being output as they occur. Is there anyway to output what the errors are at the end of the program?

Cheers,
J
0 포인트
2 응답
jakin1
초급자
486 조회수
-
0 포인트
Les_Neilson
소중한 기여자 II
486 조회수

Well, the short answer is no.

The slightly longer answer is maybe.

The long answer :

Where is err set? Does it have different values depending on where it is set?
If so then you woulduse that value to indicate where and what kind of error had occured.

If not then you are left with the choice, either :
Set err with a different value that will enable you to identify where it was set and why,

or

Every time err is set non-zero also write a message saying where (eg name of subroutine) and why (eg "error reading a file", "error writing a file", "incorrect value calculated for ")

Do you test for err /= 0 throughout your code where it might be set?
call foo(err)
call bar(err)
If an error (setting err non-zero), occurs in subroutine foo it will be missed, especially if subroutine barinitialises err to zero at the start.

Les

0 포인트
응답