Helper routine for print_abort_message()
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | message | |||
integer, | intent(in) | :: | pos | |||
integer, | intent(in) | :: | rowlen |
FUNCTION next_linebreak(message, pos, rowlen) RESULT(ibreak) !! Helper routine for print_abort_message() CHARACTER(LEN=*), INTENT(IN) :: message INTEGER, INTENT(IN) :: pos, rowlen INTEGER :: ibreak INTEGER :: i, n n = LEN_TRIM(message) IF (n - pos <= rowlen) THEN ibreak = n ! remaining message shorter than line ELSE i = INDEX(message(pos + 1:pos + 1 + rowlen), " ", BACK=.TRUE.) IF (i == 0) THEN ibreak = pos + rowlen - 1 ! no space found, break mid-word ELSE ibreak = pos + i ! break at space closest to rowlen END IF END IF END FUNCTION next_linebreak