- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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
링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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
