error stop

error stop

This is a query about error stop.

As I understand it, it can be called anywhere in the Fortran code and will immediately close all threads and stop.

Is this correct or is there more to it than this? I ask because this is not the behaviour I am seeing.

17 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Could you be more specific? Do you mean Fortran 2008 ERROR STOP, presumably in an environment where you expect co-array images to be implemented as threads? If this is what you mean, it wouldn't surprise me if improvements in quality of implementation might be desired.
I don't think there's any specification of what ERROR STOP should do under OpenMP, which is what comes to mind first when you talk about threading.
No Fortran compiler claims to be a full implementation of Fortran 2008. Filing feature requests might help prioritize introduction of F2008 facilities.

Apologies - that really was a rather vague posting from me. I am using coarrays in Fortran using the latest version of the Intel XE Composer. Calling error stop almost always does not kill all the threads which is quite frustrating.

Which exact compiler version are you using? I'm not aware of a current problem with ERROR STOP. Can you show a simple example?

Retired 12/31/2016

I am using the latest compiler. When I construct a simple example to demonstrate the problem, it works fine!

I'm back with problems with 'error stop' in Fortran using the latest compiler.

The following code doesn't behave as I expect:

if (this_image() == 1) then
error stop ' Error stop called'

Gives the output line 'Error stop called' on the Commad Prompt window, but kills no threads not even thread 1. Is there a workaround? All I want to do is stop all the threads and quit.

A simple example doesn't do this.
Has anyone else found this problem? It's hard to reproduce

I have managed to create a simple example. This program is a running test program, but on line 28 I have put an 'error stop' command. The program continues to use all available processors but hangs at this point.


Downloadapplication/octet-stream average.f901.2 KB

Thanks - I can reproduce this and will pass it on to the developers. Issue ID is DPD200239636.

Retired 12/31/2016

Thanks Steve. Is there a work-around using OPenMP or something else that you know of?


If you want to completely rewrite the program to use OpenMP, you can, but that seems somewhat drastic. does your program call ERROR STOP in its normal course of operation?

I've tried some alternatives and can't get them to do anything. Very strange. If I learn of a workaround I will let you know.

Retired 12/31/2016

The program I am working on is a commercial product (PolySNAP) which is used for data processing and classification. Because it's a commercial product, lots of testing and checking of both user choices and the correct functioning of the software are made. Problems and errors are flgged and the program stops if the errors are severe, so I need 'error stop' in a lot of places in the program.

>>Is there a work-around using

Create an coarray error status

integer :: ErrorStatus [*]
! near top
ErrorStatus[this_image()] = 0
Then any image on error can set ErrorStatus .AND. ErrorStatus[1]

In appropriate places you can test ErrorStatus[1], if not 0, exit loop (appropriately), exit subroutine/function (appropriately)
Then in main level, should you (each thread) notice ErrorStatus[1] not 0, then it can issue STOP

You can conditionalize this code such that when the "exit stop 'msg'" is fixed, that you can easily change the conditional compile variable to use exit stop (leave alternate code in until you are certain exit stop is fixed +additional compiler version).

Jim Dempsey

It turns out that this bug was already fixed in our code, but the fix was not put into the 13.0 stream because it was considered too risky. I will ask the developers to reconsider.

Retired 12/31/2016

This would be invaluable; without an easy way of stopping all threads and quitting, I have serious problems in delivering my code on time as per contract! What would be the timescale?
Jim Dempseys's work-round; can this be put into a simple subroutine that will emulate error stop? I need to think about it. (Most of the time I have just one image running; it's only in a very compute intensive portion of the code that I switch to multiple images, and this part does not need error stop.)

I tested the following and it works. Just call this instead of using ERROR STOP.

  subroutine my_error_stop

  use kernel32

  use, intrinsic :: iso_c_binding


  abstract interface

    subroutine mpi_abort_int (comm, status) bind(C)

      integer, value :: comm, status

    end subroutine mpi_abort_int

  end interface

  procedure(mpi_abort_int), pointer :: mpi_abort
    call c_f_procpointer( &

        transfer( &

            GetProcAddress( &

                GetModuleHandle("impimt"//C_NULL_CHAR), &

                "MPI_Abort"//C_NULL_CHAR &

                ), &

            C_NULL_FUNPTR &

            ), &

  if (.not. associated(mpi_abort)) error stop ("Can't find MPI_Abort - must CTRLC program")
  call mpi_abort (MPI_COMM_WORLD, 0)

  end subroutine my_error_stop

Retired 12/31/2016

It works! I'm very grateful for this, thanks.


Glad to hear it! For reference, the original issue ID is DPD200233617. This will be the ID mentioned in bug fix lists.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today