4 use iso_fortran_env,
only : output_unit
12 logical (c_bool),
parameter ::
true = .
true._c_bool
38 integer (c_int),
intent(in) :: array_vals(:)
39 integer (c_int),
intent(in) :: array_index
40 logical (c_bool) :: bounds_ok
44 if ( lbound(array_vals,1) <= array_index &
45 .and. ubound(array_vals,1) >= array_index ) bounds_ok =
true
53 real (c_float),
intent(in) :: array_vals(:)
54 integer (c_int),
intent(in) :: array_index
55 logical (c_bool) :: bounds_ok
59 if ( lbound(array_vals,1) <= array_index &
60 .and. ubound(array_vals,1) >= array_index ) bounds_ok =
true
68 real (c_double),
intent(in) :: array_vals(:)
69 integer (c_int),
intent(in) :: array_index
70 logical (c_bool) :: bounds_ok
74 if ( lbound(array_vals,1) <= array_index &
75 .and. ubound(array_vals,1) >= array_index ) bounds_ok =
true
82 array_index2 )
result(bounds_ok)
84 integer (c_int),
intent(in) :: array_vals(:,:)
85 integer (c_int),
intent(in) :: array_index1
86 integer (c_int),
intent(in) :: array_index2
87 logical (c_bool) :: bounds_ok
91 if ( lbound(array_vals,1) <= array_index1 &
92 .and. ubound(array_vals,1) >= array_index1 &
93 .and. lbound(array_vals,2) <= array_index2 &
94 .and. ubound(array_vals,2) >= array_index2 ) bounds_ok =
true
101 array_index2 )
result(bounds_ok)
103 real (c_float),
intent(in) :: array_vals(:,:)
104 integer (c_int),
intent(in) :: array_index1
105 integer (c_int),
intent(in) :: array_index2
106 logical (c_bool) :: bounds_ok
110 if ( lbound(array_vals,1) <= array_index1 &
111 .and. ubound(array_vals,1) >= array_index1 &
112 .and. lbound(array_vals,2) <= array_index2 &
113 .and. ubound(array_vals,2) >= array_index2 ) bounds_ok =
true
120 array_index2 )
result(bounds_ok)
122 real (c_double),
intent(in) :: array_vals(:,:)
123 integer (c_int),
intent(in) :: array_index1
124 integer (c_int),
intent(in) :: array_index2
125 logical (c_bool) :: bounds_ok
129 if ( lbound(array_vals,1) <= array_index1 &
130 .and. ubound(array_vals,1) >= array_index1 &
131 .and. lbound(array_vals,2) <= array_index2 &
132 .and. ubound(array_vals,2) >= array_index2 ) bounds_ok =
true
138 subroutine die(sMessage, sModule, iLine, sHints, sCalledBy, iCalledByLine )
140 character (len=*),
intent(in) :: smessage
141 character (len=*),
intent(in),
optional :: smodule
142 integer (c_int),
intent(in),
optional :: iline
143 character (len=*),
intent(in),
optional :: shints
144 character (len=*),
intent(in),
optional :: scalledby
145 integer (c_int),
intent(in),
optional :: icalledbyline
150 character (len=6) :: slinenum
156 call logs%write(
"error condition: "//trim(smessage), itab=12, ilinesbefore=1 )
158 if (
present( scalledby ) ) &
159 call logs%write(
"called by: "//trim(scalledby), itab=18 )
161 if (
present(icalledbyline))
then
162 write(slinenum, fmt=
"(i0)") icalledbyline
163 call logs%write(
"line number: "//trim(slinenum), itab=16 )
166 if (
present(smodule)) &
167 call logs%write(
"module: "//trim(smodule), itab=21 )
169 if (
present(iline))
then
170 write(slinenum, fmt=
"(i0)") iline
171 call logs%write(
"line number: "//trim(slinenum), itab=16 )
174 if (
present(shints))
then
175 if ( len_trim(shints) > 0 ) &
176 call logs%write(
"==> "//trim(shints), itab=12 )
179 call logs%write(
"", ilinesafter=1)
182 call logs%write(
"** ERROR -- PROGRAM EXECUTION HALTED **", ilinesbefore=1, ilinesafter=1 )
193 character (len=6) :: snumwarnings
194 character (len=6) :: smaxwarnings
195 character (len=6) :: sindex
196 integer (c_int) :: iindex
197 character (len=10) :: sbigs
198 character (len=1) :: slittles
214 call logs%write(
"** "//trim(adjustl(snumwarnings))//
" FATAL WARNING"//trim(sbigs) &
215 //
" DETECTED IN INPUT **", ilinesbefore=1, ilinesafter=1 )
217 call logs%write(
"# Summary of fatal warning"//trim(slittles)//
" #" )
218 call logs%write(
"-------------------------------", ilinesafter=1 )
222 write(unit=sindex, fmt=
"(i0)") iindex
223 call logs%write( trim(adjustl(sindex))//
": "//trim(
warning_text(iindex)), ilinesbefore=1)
229 call logs%write(
"*There were more than "//trim(adjustl(smaxwarnings))//
" fatal warnings. " &
230 //
" Only a partial list of warnings is shown above.*", ilinesbefore=1, ilinesafter=1, itab=2 )
233 call die( smessage=
"Fatal warning"//trim(slittles)//
" associated with input.", &
234 shints=
"Address the problem"//trim(slittles)//
" listed above and try again." )
242 subroutine warn(sMessage, sModule, iLine, sHints, lFatal, iLogLevel, lEcho)
244 character (len=*),
intent(in) :: smessage
245 character (len=*),
intent(in),
optional :: smodule
246 integer (c_int),
intent(in),
optional :: iline
247 character (len=*),
intent(in),
optional :: shints
248 logical (c_bool),
intent(in),
optional :: lfatal
249 integer (c_int),
intent(in),
optional :: iloglevel
250 logical (c_bool),
intent(in),
optional :: lecho
254 character (len=32) :: sbuf
256 if (
present( iloglevel ) )
call logs%set_loglevel( iloglevel )
257 if (
present( lecho ) )
call logs%set_echo( lecho )
259 if (
present(lfatal))
then
262 call logs%write(
" ** WARNING fatal error: **", itab=6, ilinesbefore=1)
263 call logs%write( trim(smessage), itab=16 )
268 call logs%write(
" ** WARNING **", itab=10, ilinesbefore=1)
269 call logs%write( trim(smessage), itab=16 )
272 call logs%write(
" ** WARNING **", itab=10, ilinesbefore=1)
273 call logs%write( trim(smessage), itab=16 )
276 if (
present(smodule)) &
277 call logs%write(
"module: "//trim(smodule), itab=18 )
279 if (
present(iline))
then
280 write(sbuf, fmt=
"(i0)") iline
281 call logs%write(
"line no: "//trim(sbuf), itab=18 )
284 if (
present(shints))
then
285 if ( len_trim(shints) > 0 ) &
286 call logs%write(
" ==> "//trim(shints), itab=9, ilinesbefore=1 )
289 call logs%write(
"", ilinesafter=1)
295 subroutine assert_1bit(lCondition, sMessage, sModule, iLine, sCalledBy, iCalledByLine, sHints )
297 logical (c_bool),
intent(in) :: lCondition
298 character (len=*),
intent(in) :: sMessage
299 character (len=*),
intent(in),
optional :: sHints
300 character (len=*),
intent(in),
optional :: sCalledBy
301 integer (c_int),
intent(in),
optional :: iCalledByLine
302 character (len=*),
intent(in),
optional :: sModule
303 integer (c_int),
intent(in),
optional :: iLine
305 character (len=256) :: sHints_l
307 if (.not. lcondition)
then
309 if (
present( shints ) )
then
310 shints_l = trim( shints )
315 if (
present( scalledby ) .and.
present( icalledbyline ) &
316 .and.
present(smodule) .and.
present(iline) )
then
317 call die( smessage=smessage, scalledby=scalledby, icalledbyline=icalledbyline, &
318 smodule=smodule, iline=iline, shints=shints_l )
319 elseif (
present(smodule) .and.
present(iline) )
then
320 call die( smessage=smessage, smodule=smodule, iline=iline, shints=shints_l )
321 elseif (
present(smodule) )
then
322 call die( smessage=smessage, smodule=smodule, shints=shints_l )
324 call die( smessage=smessage, shints=shints_l )
333subroutine assert_4bit(lCondition, sMessage, sModule, iLine, sCalledBy, iCalledByLine, sHints )
335 logical (4),
intent(in) :: lCondition
336 character (len=*),
intent(in) :: sMessage
337 character (len=*),
intent(in),
optional :: sHints
338 character (len=*),
intent(in),
optional :: sCalledBy
339 integer (c_int),
intent(in),
optional :: iCalledByLine
340 character (len=*),
intent(in),
optional :: sModule
341 integer (c_int),
intent(in),
optional :: iLine
343 character (len=256) :: sHints_l
345 if (.not. lcondition)
then
347 if (
present( shints ) )
then
348 shints_l = trim( shints )
353 if (
present( scalledby ) .and.
present( icalledbyline ) &
354 .and.
present(smodule) .and.
present(iline) )
then
355 call die( smessage=smessage, scalledby=scalledby, icalledbyline=icalledbyline, &
356 smodule=smodule, iline=iline, shints=shints_l )
357 elseif (
present(smodule) .and.
present(iline) )
then
358 call die( smessage=smessage, smodule=smodule, iline=iline, shints=shints_l )
359 elseif (
present(smodule) )
then
360 call die( smessage=smessage, smodule=smodule, shints=shints_l )
362 call die( smessage=smessage, shints=shints_l )
integer(c_int), parameter max_fatal_warnings
subroutine, public check_for_fatal_warnings()
integer(c_int), public number_of_fatal_warnings
logical(c_bool) function bounds_check_double_2d(array_vals, array_index1, array_index2)
logical(c_bool) function bounds_check_integer_2d(array_vals, array_index1, array_index2)
subroutine assert_4bit(lcondition, smessage, smodule, iline, scalledby, icalledbyline, shints)
logical(c_bool), public halt_upon_fatal_error
logical(c_bool), parameter false
character(len=256), dimension(max_fatal_warnings) warning_text
subroutine, public warn(smessage, smodule, iline, shints, lfatal, iloglevel, lecho)
subroutine assert_1bit(lcondition, smessage, smodule, iline, scalledby, icalledbyline, shints)
logical(c_bool) function bounds_check_double_1d(array_vals, array_index)
logical(c_bool) function bounds_check_float_2d(array_vals, array_index1, array_index2)
logical(c_bool) function bounds_check_float_1d(array_vals, array_index)
logical(c_bool) function bounds_check_integer_1d(array_vals, array_index)
logical(c_bool), parameter true
subroutine, public die(smessage, smodule, iline, shints, scalledby, icalledbyline)
type(logfile_t), public logs