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

STOP and ERROR STOP with variable stop codes


I'm trying to compile a program previously compiled with gfortran in Intel Fortran Compiler 18 and the first error I've stumbled across is when using variables for stop codes in `ERROR STOP` and `STOP` statements. E.g.,

integer :: int = 1
error stop int

This causes the error "Either a PAUSE, STOP or ERROR STOP statement has an invalid argument." Replacing `error stop int` with `error stop 1` makes the code work fine.


0 Kudos
4 Replies
Honored Contributor I

STOP and ERROR STOP with a variable instead of a constant value is a recent addition to the Fortran standard (F2018, if I am not mistaken). The Intel Fortran compiler you are using does not support that apparently (not sure which version, if any yet, does)


Thanks for your quick reply. Seems a strange thing to not have been part of the original standard when STOP and ERROR STOP were introduced - I wonder why it wasn't.

This is quite an issue for an error handling framework I have created ( The framework allows users to specify custom error codes and those error codes are used as the stop codes. I can't see a way around this without using a variable.

I think the Intel Fortran 18 compiler we have is the latest version of the compiler (which is included in Parallel Studio XE 2018), so I guess the answer is that no Intel compilers support that feature yet. 

Honored Contributor II

@Harrison, Sam:

Kudos on a great FOSS initiative with Fortran Error Handler framework over at GitHub.  The Fortran ecosystem surely needs a lot of such FOSS efforts and options for truly 'modern' approaches to error handling is surely one major area that many Fortranners can benefit from.

You may know Intel Fortran compiler does support features from soon-to-published Fortran 2018 standard revision, support for all of the enhanced interoperability with C from Fortran 2018 in Intel Fortran is a biggie:

  • Perhaps you will try to convince Intel Fortran team to soon add support for the ERROR STOP statement enhancements in Fortran 2018 as well.
  • I personally would be keen to see Intel Fortran team strive to support ALL of Fortran 2018 within the next year or so!  It will do the world of Fortran, but especially Intel Fortran users, a ton of good to have an up-to-date compiler.

Pending a few bug fixes (if I recall correctly!!), you may know gfortran already supports Fortran 2018 features for ERROR STOP.


Cheers @FortranFan, the framework is a bit of a work in progress but it's already proving very useful on a project I'm working on at the moment. FYI, I've created an "ifort" branch that has a work around for the ERROR STOP problem I describe (it basically stops with an error code of 1 and just outputs the user-defined code to the console as text). It works with Intel Fortran 18).