The message may exceed 78 characters in length. Messages longer than 78 characters are written across multiple lines. After icount lines, subsequent lines are indented and numbered. Use skipbefore/after to configure the number of empty lines before/after the message.
288
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
295
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
304 integer(I4B) :: isb
305 integer(I4B) :: isa
306 integer(I4B) :: jend
307 integer(I4B) :: len_str1
308 integer(I4B) :: len_str2
309 integer(I4B) :: len_message
310 integer(I4B) :: i
311 integer(I4B) :: j
312 integer(I4B) :: iu
313
314 if (present(iunit)) then
315 iu = iunit
316 else
317 iu = istdout
318 end if
319
320
321 if (len_trim(text) < 1) return
322
323
324 amessage = text
325 counter = ''
326 fmt_first = '(A)'
327 fmt_cont = '(A)'
328 len_str1 = 0
329 len_str2 = len_line
330 include_counter = .false.
331 j = 0
332
333
334 if (present(skipbefore)) then
335 isb = skipbefore
336 else
337 isb = 0
338 end if
339 if (present(skipafter)) then
340 isa = skipafter
341 else
342 isa = 0
343 end if
344
345
346
347 if (present(iwidth) .and. present(icount)) then
348 include_counter = .true.
349
350
351 write (cfmt, '(A,I0,A)') '(1x,i', iwidth, ',".",1x)'
352 write (counter, cfmt) icount
353
354
355 len_str1 = len(trim(counter)) + 1
356 len_str2 = len_line - len_str1
357
358
359 write (fmt_cont, '(a,i0,a)') &
360 '(', len(trim(counter)) + 1, 'x,a)'
361 end if
362
363
364 len_message = len_trim(amessage)
365
366
3675 continue
368 jend = j + len_str2
369 if (jend >= len_message) go to 100
370 do i = jend, j + 1, -1
371 if (amessage(i:i) .eq. ' ') then
372 if (j == 0) then
373 if (include_counter) then
374 line = counter(1:len_str1)//amessage(j + 1:i)
375 else
376 line = amessage(j + 1:i)
377 end if
378 call write_message(text=line, iunit=iu, &
379 fmt=fmt_first, &
380 skipbefore=isb)
381 else
382 line = adjustl(amessage(j + 1:i))
383 call write_message(text=line, iunit=iu, &
384 fmt=fmt_cont)
385 end if
386 j = i
387 go to 5
388 end if
389 end do
390 if (j == 0) then
391 if (include_counter) then
392 line = counter(1:len_str1)//amessage(j + 1:jend)
393 else
394 line = amessage(j + 1:jend)
395 end if
396 call write_message(text=line, iunit=iu, &
397 fmt=fmt_first, &
398 skipbefore=isb)
399 else
400 line = amessage(j + 1:jend)
401 call write_message(text=line, iunit=iu, &
402 fmt=fmt_cont)
403 end if
404 j = jend
405 go to 5
406
407
408100 continue
409 jend = len_message
410 if (j == 0) then
411 if (include_counter) then
412 line = counter(1:len_str1)//amessage(j + 1:jend)
413 else
414 line = amessage(j + 1:jend)
415 end if
416 call write_message(text=line, iunit=iu, &
417 fmt=fmt_first, &
418 skipbefore=isb, skipafter=isa)
419 else
420 line = amessage(j + 1:jend)
421 call write_message(text=line, iunit=iu, fmt=fmt_cont, &
422 skipafter=isa)
423 end if