@@ -2,6 +2,14 @@ module stdlib_experimental_error
2
2
use , intrinsic :: iso_fortran_env, only: stderr= >error_unit
3
3
implicit none
4
4
private
5
+
6
+ interface ! f{08,18}estop.f90
7
+ module subroutine error_stop (msg , code )
8
+ character (* ), intent (in ) :: msg
9
+ integer , intent (in ), optional :: code
10
+ end subroutine error_stop
11
+ end interface
12
+
5
13
public :: assert, error_stop
6
14
7
15
contains
@@ -23,31 +31,4 @@ subroutine assert(condition, code)
23
31
if (.not. condition) call error_stop(" Assert failed." , code)
24
32
end subroutine
25
33
26
- subroutine error_stop (msg , code )
27
- ! Aborts the program with nonzero exit code
28
- !
29
- ! The "stop <character>" statement generally has return code 0.
30
- ! To allow non-zero return code termination with character message,
31
- ! error_stop() uses the statement "error stop", which by default
32
- ! has exit code 1 and prints the message to stderr.
33
- ! An optional integer return code "code" may be specified.
34
- !
35
- ! Example
36
- ! -------
37
- !
38
- ! call error_stop("Invalid argument")
39
-
40
- character (len=* ) :: msg ! Message to print on stderr
41
- integer , intent (in ), optional :: code
42
-
43
- integer :: returncode
44
-
45
- if (present (code)) then
46
- write (stderr,* ) msg
47
- error stop code
48
- else
49
- error stop msg
50
- endif
51
- end subroutine
52
-
53
34
end module
0 commit comments