Skip to content

Using stderr and non-zero exit codes

Currently when there is some problem encountered, e.g. can't read parameters file, the programs writes some message with write(*,*), which ends up in stdout and exits with stop.

Exiting the program with just stop returns an exit code of zero, which basically signals that the program finished successfully so this should probably be changed to stop 1 or one could even define different error codes.

Similarly, it could make sense to write error messages to stderr. The Fortran2003 standard defines in the intrinsic module iso_fortran_env variables to write to stdout and stderr with write(output_unit,...) and write(error_unit,...).