22 integer(I4B) :: num_messages = 0
23 integer(I4B) :: max_messages = 1000
24 integer(I4B) :: max_exceeded = 0
25 integer(I4B) :: exp_messages = 100
26 character(len=MAXCHARLEN),
allocatable,
dimension(:) :: messages
43 this%max_messages = 1000
45 this%exp_messages = 100
49 function count(this)
result(nmessage)
51 integer(I4B) :: nmessage
53 if (
allocated(this%messages))
then
54 nmessage = this%num_messages
63 integer(I4B),
intent(in) :: imax
65 this%max_messages = imax
73 subroutine store(this, msg, substring)
76 character(len=*),
intent(in) :: msg
77 character(len=*),
intent(in),
optional :: substring
79 logical(LGP) :: inc_array
84 if (
allocated(this%messages))
then
85 if (this%num_messages <
size(this%messages))
then
90 call expandarray(this%messages, increment=this%exp_messages)
91 this%exp_messages = int(this%exp_messages * 1.1)
95 if (
present(substring))
then
96 do i = 1, this%num_messages
97 if (index(this%messages(i), substring) > 0)
return
103 n = this%num_messages + 1
104 if (n <= this%max_messages)
then
105 this%num_messages = n
106 this%messages(n) = msg
108 this%max_exceeded = this%max_exceeded + 1
122 character(len=*),
intent(in),
optional :: title
123 character(len=*),
intent(in),
optional :: kind
124 integer(I4B),
intent(in),
optional :: iunit
126 character(len=LINELENGTH) :: ltitle
127 character(len=LINELENGTH) :: lkind
128 character(len=LINELENGTH) :: errmsg
129 character(len=LINELENGTH) :: cerr
132 integer(I4B) :: isize
133 integer(I4B) :: iwidth
135 character(len=*),
parameter :: stdfmt =
"(/,A,/)"
138 if (
present(title))
then
143 if (
present(kind))
then
148 if (
present(iunit))
then
155 if (
allocated(this%messages))
then
156 isize = this%num_messages
160 write (cerr,
'(i0)') isize
161 iwidth = len_trim(cerr) + 1
164 if (trim(ltitle) /=
'')
then
175 text=this%messages(i), &
179 text=this%messages(i), &
185 if (this%max_exceeded > 0)
then
186 write (errmsg,
'(i0,3(1x,a))') &
187 this%max_exceeded,
'additional', trim(kind), &
188 'detected but not printed.'
190 call write_message(iunit=iu, text=trim(errmsg), fmt=
'(/,1x,a)')
200 if (
allocated(this%messages))
deallocate (this%messages)
209 skipbefore, skipafter, advance)
211 character(len=*),
intent(in) :: text
212 integer(I4B),
intent(in),
optional :: iunit
213 character(len=*),
intent(in),
optional :: fmt
214 integer(I4B),
intent(in),
optional :: skipbefore
215 integer(I4B),
intent(in),
optional :: skipafter
216 logical(LGP),
intent(in),
optional :: advance
218 character(len=3) :: cadvance
222 character(len=LENHUGELINE) :: simfmt
223 character(len=*),
parameter :: stdfmt =
'(a)'
224 character(len=*),
parameter :: emptyfmt =
'()'
226 if (
present(iunit))
then
233 ilen = len_trim(text)
236 if (
present(fmt))
then
245 if (
present(advance))
then
256 if (
present(skipbefore))
then
264 write (iu, trim(simfmt), advance=cadvance) text(1:ilen)
266 write (iu, trim(simfmt), advance=cadvance)
270 if (
present(skipafter))
then
285 skipbefore, skipafter)
287 character(len=*),
intent(in) :: text
288 integer(I4B),
intent(in),
optional :: iunit
289 integer(I4B),
intent(in),
optional :: icount
290 integer(I4B),
intent(in),
optional :: iwidth
291 integer(I4B),
intent(in),
optional :: skipbefore
292 integer(I4B),
intent(in),
optional :: skipafter
294 integer(I4B),
parameter :: len_line = 78
295 character(len=LENHUGELINE) :: amessage
296 character(len=len_line) :: line
297 character(len=16) :: cfmt
298 character(len=10) :: counter
299 character(len=5) :: fmt_first
300 character(len=20) :: fmt_cont
301 logical(LGP) :: include_counter
305 integer(I4B) :: len_str1
306 integer(I4B) :: len_str2
307 integer(I4B) :: len_message
312 if (
present(iunit))
then
319 if (len_trim(text) < 1)
return
328 include_counter = .false.
332 if (
present(skipbefore))
then
337 if (
present(skipafter))
then
345 if (
present(iwidth) .and.
present(icount))
then
346 include_counter = .true.
349 write (cfmt,
'(A,I0,A)')
'(1x,i', iwidth,
',".",1x)'
350 write (counter, cfmt) icount
353 len_str1 = len(trim(counter)) + 1
354 len_str2 = len_line - len_str1
357 write (fmt_cont,
'(a,i0,a)') &
358 '(', len(trim(counter)) + 1,
'x,a)'
362 len_message = len_trim(amessage)
367 if (jend >= len_message)
go to 100
368 do i = jend, j + 1, -1
369 if (amessage(i:i) .eq.
' ')
then
371 if (include_counter)
then
372 line = counter(1:len_str1)//amessage(j + 1:i)
374 line = amessage(j + 1:i)
380 line = adjustl(amessage(j + 1:i))
389 if (include_counter)
then
390 line = counter(1:len_str1)//amessage(j + 1:jend)
392 line = amessage(j + 1:jend)
398 line = amessage(j + 1:jend)
409 if (include_counter)
then
410 line = counter(1:len_str1)//amessage(j + 1:jend)
412 line = amessage(j + 1:jend)
416 skipbefore=isb, skipafter=isa)
418 line = amessage(j + 1:jend)
427 character(len=*),
intent(in) :: text
428 integer(I4B),
intent(in) :: linelen
429 integer(I4B),
intent(in),
optional :: iunit
431 character(len=linelen) :: line
432 character(len=linelen) :: blank
434 integer(I4B) :: len_message
440 if (
present(iunit))
then
448 len_message = len_trim(adjustl(text))
452 outer:
do while (.true.)
456 if (jend >= len_message)
then
458 line = text(j + 1:jend)
459 ipad = ((linelen - len_trim(line)) / 2)
464 do i = jend, j + 1, -1
465 if (text(i:i) .eq.
' ')
then
467 ipad = ((linelen - len_trim(line)) / 2)
474 line = text(j + 1:jend)
475 ipad = ((linelen - len_trim(line)) / 2)
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenhugeline
maximum length of a huge line
integer(i4b), parameter maxcharlen
maximum length of char string
@ vsummary
write summary output
real(dp), parameter done
real constant 1
This module defines variable data types.
Store and issue logging messages to output units.
subroutine, public write_message_centered(text, linelen, iunit)
Write horizontally centered text, left-padding as needed.
subroutine, public write_message(text, iunit, fmt, skipbefore, skipafter, advance)
Write a message to an output unit.
subroutine store(this, msg, substring)
Add a message to storage.
subroutine write_all(this, title, kind, iunit)
Write all stored messages to standard output.
subroutine deallocate(this)
@ brief Deallocate message storage.
subroutine, public write_message_counter(text, iunit, icount, iwidth, skipbefore, skipafter)
Write a message with configurable indentation and numbering.
subroutine set_max(this, imax)
Set the maximum number of messages.
integer(i4b) function count(this)
Return the number of messages currently stored.
This module contains simulation variables.
integer(i4b) istdout
unit number for stdout
Container for related messages.