Most Standard-y way to stop with error with PGI?

All,

A simple question: if you wanted to do something like an bash/csh “exit 4” with Fortran and PGI, how would you?

Now some old code I have uses “call exit(4)” which, of course, is not part of the Standard but a GNU extension that I think nearly every compiler supports.

Looking through my Fortran books, I thought that “error stop 4” might be the best pure Fortran alternative, but it looks like that is a Fortran 2008 statement that PGI does not yet support, probably because it seems to have coarray properties? (Intel 15 and GCC 5.1 seem to allow…or will compile/run code that is coarray free.)

Which, I guess, makes ‘stop 4’ be the best, but the Standard seems to say that ‘stop’ is for “normal” termination but ‘error stop’ is for “error” termination. My guess is is that ‘stop’ strings go to OUTPUT_UNIT but ‘error stop’ goes to ERROR_UNIT?

Just wondering what everyone out there thought.

Matt

I’m assuming the most important thing is to return a status that the shell can check. So, stop works fine.

%> cat stop.f90
stop 4
end
%> pgfortran stop.f90
%> ./a.out
4
%> echo $?
4

There are a few different ways to get around the program printing “4” if you don’t want that.