@@ -87,7 +87,7 @@ pure subroutine assert(assertion, description)
87
87
88
88
end subroutine
89
89
90
- pure module subroutine assert_always(assertion, description)
90
+ pure subroutine assert_always (assertion , description )
91
91
! ! Same as above but always enforces the assertion (regardless of ASSERTIONS)
92
92
implicit none
93
93
logical , intent (in ) :: assertion
@@ -104,7 +104,11 @@ pure module subroutine assert_always(assertion, description)
104
104
# else
105
105
me = this_image()
106
106
# endif
107
- message = ' Assertion failure on image ' // string (me) // ' :' // description
107
+ block
108
+ character (len= 128 ) image_number
109
+ write (image_number, * ) me
110
+ message = ' Assertion failure on image ' // trim (adjustl (image_number)) // ' :' // description
111
+ end block
108
112
#else
109
113
message = ' Assertion failure: ' // description
110
114
me = 0 ! avoid a harmless warning
@@ -118,32 +122,6 @@ pure module subroutine assert_always(assertion, description)
118
122
119
123
end if check_assertion
120
124
121
- contains
122
-
123
- pure function string (numeric ) result(number_as_string)
124
- ! ! Result is a string represention of the numeric argument
125
- class(* ), intent (in ) :: numeric
126
- integer , parameter :: max_len= 128
127
- character (len= max_len) :: untrimmed_string
128
- character (len= :), allocatable :: number_as_string
129
-
130
- select type (numeric)
131
- type is (complex )
132
- write (untrimmed_string, * ) numeric
133
- type is (integer )
134
- write (untrimmed_string, * ) numeric
135
- type is (logical )
136
- write (untrimmed_string, * ) numeric
137
- type is (real )
138
- write (untrimmed_string, * ) numeric
139
- class default
140
- error stop " Internal error in subroutine 'assert': unsupported type in function 'string'."
141
- end select
142
-
143
- number_as_string = trim (adjustl (untrimmed_string))
144
-
145
- end function string
146
-
147
125
end subroutine
148
126
149
127
end module assert_subroutine_m
0 commit comments