Skip to content

Commit 6192f4e

Browse files
certikbonachea
authored andcommitted
Remove submodule
1 parent 873f48d commit 6192f4e

File tree

2 files changed

+69
-79
lines changed

2 files changed

+69
-79
lines changed

src/assert/assert_subroutine_m.F90

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
!
88
#include "assert_macros.h"
99

10+
#include "assert_features.h"
11+
1012
module assert_subroutine_m
1113
!! summary: Utility for runtime enforcement of logical assertions.
1214
!! usage: error-terminate if the assertion fails:
@@ -87,4 +89,71 @@ pure module subroutine assert_always(assertion, description)
8789

8890
end interface
8991

92+
contains
93+
94+
module procedure assert
95+
96+
toggle_assertions: &
97+
if (enforce_assertions) then
98+
call assert_always(assertion, description)
99+
end if toggle_assertions
100+
101+
end procedure
102+
103+
module procedure assert_always
104+
character(len=:), allocatable :: message
105+
integer me
106+
107+
check_assertion: &
108+
if (.not. assertion) then
109+
110+
#if ASSERT_MULTI_IMAGE
111+
# if ASSERT_PARALLEL_CALLBACKS
112+
me = assert_this_image()
113+
# else
114+
me = this_image()
115+
# endif
116+
message = 'Assertion failure on image ' // string(me) // ':' // description
117+
#else
118+
message = 'Assertion failure: ' // description
119+
me = 0 ! avoid a harmless warning
120+
#endif
121+
122+
#if ASSERT_PARALLEL_CALLBACKS
123+
call assert_error_stop(message)
124+
#else
125+
error stop message, QUIET=.false.
126+
#endif
127+
128+
end if check_assertion
129+
130+
contains
131+
132+
pure function string(numeric) result(number_as_string)
133+
!! Result is a string represention of the numeric argument
134+
class(*), intent(in) :: numeric
135+
integer, parameter :: max_len=128
136+
character(len=max_len) :: untrimmed_string
137+
character(len=:), allocatable :: number_as_string
138+
139+
select type(numeric)
140+
type is(complex)
141+
write(untrimmed_string, *) numeric
142+
type is(integer)
143+
write(untrimmed_string, *) numeric
144+
type is(logical)
145+
write(untrimmed_string, *) numeric
146+
type is(real)
147+
write(untrimmed_string, *) numeric
148+
class default
149+
error stop "Internal error in subroutine 'assert': unsupported type in function 'string'."
150+
end select
151+
152+
number_as_string = trim(adjustl(untrimmed_string))
153+
154+
end function string
155+
156+
end procedure
157+
90158
end module assert_subroutine_m
159+

src/assert/assert_subroutine_s.F90

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

0 commit comments

Comments
 (0)