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)
201 this%num_messages = 0
202 this%max_exceeded = 0
211 skipbefore, skipafter, advance)
213 character(len=*),
intent(in) :: text
214 integer(I4B),
intent(in),
optional :: iunit
215 character(len=*),
intent(in),
optional :: fmt
216 integer(I4B),
intent(in),
optional :: skipbefore
217 integer(I4B),
intent(in),
optional :: skipafter
218 logical(LGP),
intent(in),
optional :: advance
220 character(len=3) :: cadvance
224 character(len=LENHUGELINE) :: simfmt
225 character(len=*),
parameter :: stdfmt =
'(a)'
226 character(len=*),
parameter :: emptyfmt =
'()'
228 if (
present(iunit))
then
235 ilen = len_trim(text)
238 if (
present(fmt))
then
247 if (
present(advance))
then
258 if (
present(skipbefore))
then
266 write (iu, trim(simfmt), advance=cadvance) text(1:ilen)
268 write (iu, trim(simfmt), advance=cadvance)
272 if (
present(skipafter))
then
287 skipbefore, skipafter)
289 character(len=*),
intent(in) :: text
290 integer(I4B),
intent(in),
optional :: iunit
291 integer(I4B),
intent(in),
optional :: icount
292 integer(I4B),
intent(in),
optional :: iwidth
293 integer(I4B),
intent(in),
optional :: skipbefore
294 integer(I4B),
intent(in),
optional :: skipafter
296 integer(I4B),
parameter :: len_line = 78
297 character(len=LENHUGELINE) :: amessage
298 character(len=len_line) :: line
299 character(len=16) :: cfmt
300 character(len=10) :: counter
301 character(len=5) :: fmt_first
302 character(len=20) :: fmt_cont
303 logical(LGP) :: include_counter
307 integer(I4B) :: len_str1
308 integer(I4B) :: len_str2
309 integer(I4B) :: len_message
314 if (
present(iunit))
then
321 if (len_trim(text) < 1)
return
330 include_counter = .false.
334 if (
present(skipbefore))
then
339 if (
present(skipafter))
then
347 if (
present(iwidth) .and.
present(icount))
then
348 include_counter = .true.
351 write (cfmt,
'(A,I0,A)')
'(1x,i', iwidth,
',".",1x)'
352 write (counter, cfmt) icount
355 len_str1 = len(trim(counter)) + 1
356 len_str2 = len_line - len_str1
359 write (fmt_cont,
'(a,i0,a)') &
360 '(', len(trim(counter)) + 1,
'x,a)'
364 len_message = len_trim(amessage)
369 if (jend >= len_message)
go to 100
370 do i = jend, j + 1, -1
371 if (amessage(i:i) .eq.
' ')
then
373 if (include_counter)
then
374 line = counter(1:len_str1)//amessage(j + 1:i)
376 line = amessage(j + 1:i)
382 line = adjustl(amessage(j + 1:i))
391 if (include_counter)
then
392 line = counter(1:len_str1)//amessage(j + 1:jend)
394 line = amessage(j + 1:jend)
400 line = amessage(j + 1:jend)
411 if (include_counter)
then
412 line = counter(1:len_str1)//amessage(j + 1:jend)
414 line = amessage(j + 1:jend)
418 skipbefore=isb, skipafter=isa)
420 line = amessage(j + 1:jend)
429 character(len=*),
intent(in) :: text
430 integer(I4B),
intent(in) :: linelen
431 integer(I4B),
intent(in),
optional :: iunit
433 character(len=linelen) :: line
434 character(len=linelen) :: blank
436 integer(I4B) :: len_message
442 if (
present(iunit))
then
450 len_message = len_trim(adjustl(text))
454 outer:
do while (.true.)
458 if (jend >= len_message)
then
460 line = text(j + 1:jend)
461 ipad = ((linelen - len_trim(line)) / 2)
466 do i = jend, j + 1, -1
467 if (text(i:i) .eq.
' ')
then
469 ipad = ((linelen - len_trim(line)) / 2)
476 line = text(j + 1:jend)
477 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.