4 use iso_fortran_env,
only : output_unit
12 logical (c_bool),
parameter ::
true = .
true._c_bool
39 integer (c_int),
intent(in) :: array_vals(:)
40 integer (c_int),
intent(in) :: array_index
41 logical (c_bool) :: bounds_ok
45 if ( lbound(array_vals,1) <= array_index &
46 .and. ubound(array_vals,1) >= array_index ) bounds_ok =
true
54 real (c_float),
intent(in) :: array_vals(:)
55 integer (c_int),
intent(in) :: array_index
56 logical (c_bool) :: bounds_ok
60 if ( lbound(array_vals,1) <= array_index &
61 .and. ubound(array_vals,1) >= array_index ) bounds_ok =
true
69 real (c_double),
intent(in) :: array_vals(:)
70 integer (c_int),
intent(in) :: array_index
71 logical (c_bool) :: bounds_ok
75 if ( lbound(array_vals,1) <= array_index &
76 .and. ubound(array_vals,1) >= array_index ) bounds_ok =
true
83 array_index2 )
result(bounds_ok)
85 integer (c_int),
intent(in) :: array_vals(:,:)
86 integer (c_int),
intent(in) :: array_index1
87 integer (c_int),
intent(in) :: array_index2
88 logical (c_bool) :: bounds_ok
92 if ( lbound(array_vals,1) <= array_index1 &
93 .and. ubound(array_vals,1) >= array_index1 &
94 .and. lbound(array_vals,2) <= array_index2 &
95 .and. ubound(array_vals,2) >= array_index2 ) bounds_ok =
true
102 array_index2 )
result(bounds_ok)
104 real (c_float),
intent(in) :: array_vals(:,:)
105 integer (c_int),
intent(in) :: array_index1
106 integer (c_int),
intent(in) :: array_index2
107 logical (c_bool) :: bounds_ok
111 if ( lbound(array_vals,1) <= array_index1 &
112 .and. ubound(array_vals,1) >= array_index1 &
113 .and. lbound(array_vals,2) <= array_index2 &
114 .and. ubound(array_vals,2) >= array_index2 ) bounds_ok =
true
121 array_index2 )
result(bounds_ok)
123 real (c_double),
intent(in) :: array_vals(:,:)
124 integer (c_int),
intent(in) :: array_index1
125 integer (c_int),
intent(in) :: array_index2
126 logical (c_bool) :: bounds_ok
130 if ( lbound(array_vals,1) <= array_index1 &
131 .and. ubound(array_vals,1) >= array_index1 &
132 .and. lbound(array_vals,2) <= array_index2 &
133 .and. ubound(array_vals,2) >= array_index2 ) bounds_ok =
true
139 subroutine die(sMessage, sModule, iLine, sHints, sCalledBy, iCalledByLine )
141 character (len=*),
intent(in) :: smessage
142 character (len=*),
intent(in),
optional :: smodule
143 integer (c_int),
intent(in),
optional :: iline
144 character (len=*),
intent(in),
optional :: shints
145 character (len=*),
intent(in),
optional :: scalledby
146 integer (c_int),
intent(in),
optional :: icalledbyline
151 character (len=6) :: slinenum
157 call logs%write(
"error condition: "//trim(smessage), itab=12, ilinesbefore=1 )
159 if (
present( scalledby ) ) &
160 call logs%write(
"called by: "//trim(scalledby), itab=18 )
162 if (
present(icalledbyline))
then
163 write(slinenum, fmt=
"(i0)") icalledbyline
164 call logs%write(
"line number: "//trim(slinenum), itab=16 )
167 if (
present(smodule)) &
168 call logs%write(
"module: "//trim(smodule), itab=21 )
170 if (
present(iline))
then
171 write(slinenum, fmt=
"(i0)") iline
172 call logs%write(
"line number: "//trim(slinenum), itab=16 )
175 if (
present(shints))
then
176 if ( len_trim(shints) > 0 ) &
177 call logs%write(
"==> "//trim(shints), itab=12 )
180 call logs%write(
"", ilinesafter=1)
183 call logs%write(
"** ERROR -- PROGRAM EXECUTION HALTED **", ilinesbefore=1, ilinesafter=1 )
194 character (len=6) :: snumwarnings
195 character (len=6) :: smaxwarnings
196 character (len=6) :: sindex
197 integer (c_int) :: iindex
198 character (len=10) :: sbigs
199 character (len=1) :: slittles
215 call logs%write(
"** "//trim(adjustl(snumwarnings))//
" FATAL WARNING"//trim(sbigs) &
216 //
" DETECTED IN INPUT **", ilinesbefore=1, ilinesafter=1 )
218 call logs%write(
"# Summary of fatal warning"//trim(slittles)//
" #" )
219 call logs%write(
"-------------------------------", ilinesafter=1 )
223 write(unit=sindex, fmt=
"(i0)") iindex
224 call logs%write( trim(adjustl(sindex))//
": "//trim(
warning_text(iindex)), ilinesbefore=1)
225 call logs%write(
" ==> "//trim(
hint_text(iindex)), ilinesafter=2)
231 call logs%write(
"*There were more than "//trim(adjustl(smaxwarnings))//
" fatal warnings. " &
232 //
" Only a partial list of warnings is shown above.*", ilinesbefore=1, ilinesafter=1, itab=2 )
235 call die( smessage=
"Fatal warning"//trim(slittles)//
" associated with input.", &
236 shints=
"Address the problem"//trim(slittles)//
" listed above and try again." )
244 subroutine warn(sMessage, sModule, iLine, sHints, lFatal, iLogLevel, lEcho)
246 character (len=*),
intent(in) :: smessage
247 character (len=*),
intent(in),
optional :: smodule
248 integer (c_int),
intent(in),
optional :: iline
249 character (len=*),
intent(in),
optional :: shints
250 logical (c_bool),
intent(in),
optional :: lfatal
251 integer (c_int),
intent(in),
optional :: iloglevel
252 logical (c_bool),
intent(in),
optional :: lecho
256 character (len=32) :: sbuf
258 if (
present( iloglevel ) )
call logs%set_loglevel( iloglevel )
259 if (
present( lecho ) )
call logs%set_echo( lecho )
261 if (
present(lfatal))
then
264 call logs%write(
" ** WARNING fatal error: **", itab=6, ilinesbefore=1)
265 call logs%write( trim(smessage), itab=16 )
269 if (
present(shints))
then
275 call logs%write(
" ** WARNING **", itab=10, ilinesbefore=1)
276 call logs%write( trim(smessage), itab=16 )
279 call logs%write(
" ** WARNING **", itab=10, ilinesbefore=1)
280 call logs%write( trim(smessage), itab=16 )
283 if (
present(smodule)) &
284 call logs%write(
"module: "//trim(smodule), itab=18 )
286 if (
present(iline))
then
287 write(sbuf, fmt=
"(i0)") iline
288 call logs%write(
"line no: "//trim(sbuf), itab=18 )
291 if (
present(shints))
then
292 if ( len_trim(shints) > 0 ) &
293 call logs%write(
" ==> "//trim(shints), itab=9, ilinesbefore=1 )
296 call logs%write(
"", ilinesafter=1)
302 subroutine assert_1bit(lCondition, sMessage, sModule, iLine, sCalledBy, iCalledByLine, sHints )
304 logical (c_bool),
intent(in) :: lCondition
305 character (len=*),
intent(in) :: sMessage
306 character (len=*),
intent(in),
optional :: sHints
307 character (len=*),
intent(in),
optional :: sCalledBy
308 integer (c_int),
intent(in),
optional :: iCalledByLine
309 character (len=*),
intent(in),
optional :: sModule
310 integer (c_int),
intent(in),
optional :: iLine
312 character (len=256) :: sHints_l
314 if (.not. lcondition)
then
316 if (
present( shints ) )
then
317 shints_l = trim( shints )
322 if (
present( scalledby ) .and.
present( icalledbyline ) &
323 .and.
present(smodule) .and.
present(iline) )
then
324 call die( smessage=smessage, scalledby=scalledby, icalledbyline=icalledbyline, &
325 smodule=smodule, iline=iline, shints=shints_l )
326 elseif (
present(smodule) .and.
present(iline) )
then
327 call die( smessage=smessage, smodule=smodule, iline=iline, shints=shints_l )
328 elseif (
present(smodule) )
then
329 call die( smessage=smessage, smodule=smodule, shints=shints_l )
331 call die( smessage=smessage, shints=shints_l )
340subroutine assert_4bit(lCondition, sMessage, sModule, iLine, sCalledBy, iCalledByLine, sHints )
342 logical (4),
intent(in) :: lCondition
343 character (len=*),
intent(in) :: sMessage
344 character (len=*),
intent(in),
optional :: sHints
345 character (len=*),
intent(in),
optional :: sCalledBy
346 integer (c_int),
intent(in),
optional :: iCalledByLine
347 character (len=*),
intent(in),
optional :: sModule
348 integer (c_int),
intent(in),
optional :: iLine
350 character (len=256) :: sHints_l
352 if (.not. lcondition)
then
354 if (
present( shints ) )
then
355 shints_l = trim( shints )
360 if (
present( scalledby ) .and.
present( icalledbyline ) &
361 .and.
present(smodule) .and.
present(iline) )
then
362 call die( smessage=smessage, scalledby=scalledby, icalledbyline=icalledbyline, &
363 smodule=smodule, iline=iline, shints=shints_l )
364 elseif (
present(smodule) .and.
present(iline) )
then
365 call die( smessage=smessage, smodule=smodule, iline=iline, shints=shints_l )
366 elseif (
present(smodule) )
then
367 call die( smessage=smessage, smodule=smodule, shints=shints_l )
369 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)
character(len=256), dimension(max_fatal_warnings) hint_text
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