@@ -523,7 +523,7 @@ subroutine format_output_string( self, unit, string, procedure_name, &
523
523
character (* ), intent (in ) :: procedure_name
524
524
character (* ), intent (in ) :: col_indent
525
525
526
- integer :: count, indent_len, index , iostat, length, remain
526
+ integer :: count, indent_len, index_ , iostat, length, remain
527
527
character (256 ) :: iomsg
528
528
529
529
length = len_trim (string)
@@ -544,27 +544,32 @@ subroutine format_output_string( self, unit, string, procedure_name, &
544
544
545
545
subroutine format_first_line ()
546
546
547
- if ( length <= self % max_width .or. self % max_width == 0 ) then
547
+ if ( self % max_width == 0 .or. &
548
+ ( length <= self % max_width .and. &
549
+ index ( string (1 :length), new_line(' a' )) == 0 ) ) then
548
550
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
549
551
string (1 :length)
550
552
remain = 0
551
553
return
552
554
else
553
555
554
- do index= self % max_width, 1 , - 1
555
- if ( string (index:index) == ' ' ) exit
556
- end do
556
+ index_ = index ( string (1 :min (length, self % max_width)), new_line(' a' ))
557
+ if ( index_ == 0 ) then
558
+ do index_= self % max_width, 1 , - 1
559
+ if ( string (index_:index_) == ' ' ) exit
560
+ end do
561
+ end if
557
562
558
- if ( index == 0 ) then
563
+ if ( index_ == 0 ) then
559
564
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
560
565
string (1 :self % max_width)
561
566
count = self % max_width
562
567
remain = length - count
563
568
return
564
569
else
565
570
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
566
- string (1 :index -1 )
567
- count = index
571
+ string (1 :index_ -1 )
572
+ count = index_
568
573
remain = length - count
569
574
return
570
575
end if
@@ -585,20 +590,24 @@ subroutine format_subsequent_line()
585
590
return
586
591
else
587
592
588
- do index= count+ self % max_width, count+1 , - 1
589
- if ( string (index:index) == ' ' ) exit
590
- end do
593
+ index_ = count + index ( string (count+1 :count+ self % max_width), &
594
+ new_line(' a' ))
595
+ if (index_ == count) then
596
+ do index_= count+ self % max_width, count+1 , - 1
597
+ if ( string (index_:index_) == ' ' ) exit
598
+ end do
599
+ end if
591
600
592
- if ( index == count ) then
601
+ if ( index_ == count ) then
593
602
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
594
603
string (count+1 :count+ self % max_width)
595
604
count = count + self % max_width
596
605
remain = length - count
597
606
return
598
607
else
599
608
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
600
- string (count+1 :index -1 )
601
- count = index
609
+ string (count+1 :index_ -1 )
610
+ count = index_
602
611
remain = length - count
603
612
return
604
613
end if
@@ -611,29 +620,35 @@ end subroutine format_subsequent_line
611
620
612
621
subroutine indent_format_subsequent_line ()
613
622
614
- if ( remain <= self % max_width - indent_len ) then
623
+ if ( index ( string (count+1 :length), new_line(' a' )) == 0 .and. &
624
+ remain <= self % max_width - indent_len ) then
615
625
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
616
626
col_indent // string (count+1 :length)
617
627
count = length
618
628
remain = 0
619
629
return
620
630
else
621
631
622
- do index= count+ self % max_width- indent_len, count+1 , - 1
623
- if ( string (index:index) == ' ' ) exit
624
- end do
632
+ index_ = count + index ( string (count+1 : &
633
+ min ( length, count+ self % max_width - indent_len) ), &
634
+ new_line(' a' ))
635
+ if (index_ == count) then
636
+ do index_= count+ self % max_width- indent_len, count+1 , - 1
637
+ if ( string (index_:index_) == ' ' ) exit
638
+ end do
639
+ end if
625
640
626
- if ( index == count ) then
641
+ if ( index_ == count ) then
627
642
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
628
- col_indent // &
643
+ col_indent // &
629
644
string (count+1 :count+ self % max_width- indent_len)
630
645
count = count + self % max_width - indent_len
631
646
remain = length - count
632
647
return
633
648
else
634
649
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
635
- col_indent // string (count+1 :index -1 )
636
- count = index
650
+ col_indent // string (count+1 :index_ -1 )
651
+ count = index_
637
652
remain = length - count
638
653
return
639
654
end if
0 commit comments