What is the difference between STOP and ERROR STOP?

Fortran has stopand error stop, both of which exit the program prematurely and may return an error code.

What is the difference between them and when should I use it? (Also, are there any problems with the implementation / compiler?)

I understand from the Intel documentation that stopthe program terminates, while it error stoplooks a bit bigger. This page is useful, but does not fully answer my question, because 1) it is too technical for me, and 2) I know that the Fortran standard leaves room for “artistic expression” among implementations, so I do not trust this page to completely comply with the standard.

I note that this question is related to What is the difference between “stop” and “exit” in Fortran? - actually my question was inspired by this answer to this question. While this question asks the difference between stopand exit, I specifically look at the significant differences between stopand error stop. My question here would be a useful complement to this question in retrospect, but since it is not, this is a separate question.

+5
source share
3 answers

Fortran has two types of completion: normal completion and error completion.

stop end program. error stop (, /, ).

, stop , error stop error stop .

, "".

( stop ) : , . ( ) . , . . "" .

, , , , () " ". , .

" ", , . ( ) Fortran . , error stop. coarray.

( ) , . , stop ( ). - error stop error stop, Fortran 2018 .

Intel, ifort .

, error stop , stop ( ) .

+7

Error stop (?), , stop , . stop end.

Error stop Fortran 2008 coarrays (), stop .

stop pure, Error stop ( Fortran 2008).

+6

@Vladimir F ,

error stop [ stop-code ]  ! stop-code is an integer or default character constant expression and has the same meaning as for the stop statement.

, stop. coarray (, ,...), , , , , , . , , . error stop , .

On the contrary, one operator stopstops only those images that have reached it, as far as I know, and used it in Coarray Fortran. Other images may check the status of a specific image or images that have failed (stopped) using

sync images([image numbers],stat=syncstat)
if (syncstat==stat_stopped_image) then
   ! do something appropriate
end if

The flag stat_stopped_imageis a constant accessible from the built-in module iso_fortran_envin Fortran 2008. Next.

+4
source

Source: https://habr.com/ru/post/1695497/


All Articles