Skip to content

Commit e230a25

Browse files
committed
error_stop: remove incorrect/obsolete code
I originally authored this routine, which is updated for supported compilers. The logic selecting it in CMake was no longer relevant.
1 parent 9856a79 commit e230a25

File tree

6 files changed

+38
-93
lines changed

6 files changed

+38
-93
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ endif()
4545
# --- compiler feature checks
4646
include(CheckFortranSourceCompiles)
4747
include(CheckFortranSourceRuns)
48-
check_fortran_source_runs("i=0; error stop i; end" f18errorstop SRC_EXT f90)
48+
check_fortran_source_runs("i=0; error stop i; end" f18errorstop)
4949
check_fortran_source_compiles("real, allocatable :: array(:, :, :, :, :, :, :, :, :, :); end" f03rank SRC_EXT f90)
50-
check_fortran_source_runs("use, intrinsic :: iso_fortran_env, only : real128; real(real128) :: x; x = x+1; end" f03real128)
50+
# check_fortran_source_runs("use, intrinsic :: iso_fortran_env, only : real128; real(real128) :: x; x = x+1; end" f03real128)
5151

5252
if(NOT DEFINED CMAKE_MAXIMUM_RANK)
5353
set(CMAKE_MAXIMUM_RANK 4 CACHE STRING "Maximum array rank for generated procedures")

src/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(fppFiles
1414
stdlib_sorting.fypp
1515
stdlib_sorting_ord_sort.fypp
1616
stdlib_sorting_sort.fypp
17-
stdlib_sorting_sort_index.fypp
17+
stdlib_sorting_sort_index.fypp
1818
stdlib_stats.fypp
1919
stdlib_stats_corr.fypp
2020
stdlib_stats_cov.fypp
@@ -68,12 +68,6 @@ target_include_directories(${PROJECT_NAME} PUBLIC
6868
$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}>
6969
)
7070

71-
if(f18errorstop)
72-
target_sources(${PROJECT_NAME} PRIVATE f18estop.f90)
73-
else()
74-
target_sources(${PROJECT_NAME} PRIVATE f08estop.f90)
75-
endif()
76-
7771
add_subdirectory(tests)
7872

7973
install(TARGETS ${PROJECT_NAME}

src/Makefile.manual

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ SRCFYPP =\
3030
stdlib_stats_distribution_PRNG.fypp \
3131
stdlib_string_type.fypp
3232

33-
SRC = f18estop.f90 \
34-
stdlib_error.f90 \
33+
SRC = stdlib_error.f90 \
3534
stdlib_specialfunctions.f90 \
3635
stdlib_specialfunctions_legendre.f90 \
3736
stdlib_io.f90 \
@@ -66,7 +65,6 @@ $(SRCGEN): %.f90: %.fypp common.fypp
6665
fypp $(FYPPFLAGS) $< $@
6766

6867
# Fortran module dependencies
69-
f18estop.o: stdlib_error.o
7068
stdlib_ascii.o: stdlib_kinds.o
7169
stdlib_bitsets.o: stdlib_kinds.o
7270
stdlib_bitsets_64.o: stdlib_bitsets.o

src/f08estop.f90

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/f18estop.f90

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/stdlib_error.f90

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,44 @@ module stdlib_error
66
implicit none
77
private
88

9-
interface ! f{08,18}estop.f90
10-
module subroutine error_stop(msg, code)
11-
!! version: experimental
12-
!!
13-
!! Provides a call to `error stop` and allows the user to specify a code and message
14-
!! ([Specification](..//page/specs/stdlib_error.html#description_1))
15-
character(*), intent(in) :: msg
16-
integer, intent(in), optional :: code
17-
end subroutine error_stop
18-
end interface
19-
209
public :: check, error_stop
2110

2211
contains
2312

13+
14+
subroutine error_stop(msg, code)
15+
!! version: experimental
16+
!!
17+
!! Provides a call to `error stop` and allows the user to specify a code and message
18+
!! ([Specification](..//page/specs/stdlib_error.html#description_1))
19+
!!
20+
!! Aborts the program with nonzero exit code.
21+
!! The "stop <character>" statement generally has return code 0.
22+
!! To allow non-zero return code termination with character message,
23+
!! error_stop() uses the statement "error stop", which by default
24+
!! has exit code 1 and prints the message to stderr.
25+
!! An optional integer return code "code" may be specified.
26+
!!
27+
!!##### Examples
28+
!!
29+
!!```fortran
30+
!! call error_stop("Invalid argument")
31+
!!```
32+
!!```fortran
33+
!! call error_stop("Invalid argument", 123)
34+
!!```
35+
36+
character(*), intent(in) :: msg
37+
integer, intent(in), optional :: code
38+
39+
if(.not.present(code)) error stop msg
40+
41+
write(stderr, '(a)') msg
42+
error stop code
43+
44+
end subroutine error_stop
45+
46+
2447
subroutine check(condition, msg, code, warn)
2548
!! version: experimental
2649
!!

0 commit comments

Comments
 (0)