44
45
46 class(TableTermType) :: this
47 character(len=*), intent(in) :: tag
48 integer(I4B), intent(in) :: width
49 integer(I4B), intent(in), optional :: alignment
50
51 character(len=LINELENGTH) :: string
52 character(len=LINELENGTH) :: tstring
53 character(len=LINELENGTH), allocatable, dimension(:) :: words
54 integer(I4B) :: nwords
55 integer(I4B) :: ilen
56 integer(I4B) :: i
57 integer(I4B) :: j
58
59
60
61 call this%allocate_scalars()
62
63
64 this%tag = tag
65
66 if (present(alignment)) then
67 this%alignment = alignment
68 else
69 this%alignment = tabcenter
70 end if
71
72 this%width = width
73
74
75 call parseline(tag, nwords, words, 0)
76
77
78
79 do i = 1, nwords
80 ilen = len(trim(words(i)))
81 if (ilen > width) then
82 words(i) (width:width) = '.'
83 do j = width + 1, ilen
84 words(i) (j:j) = ' '
85 end do
86 end if
87 end do
88
89
90 i = 0
91 do
92 i = i + 1
93 if (i > nwords) then
94 exit
95 end if
96 string = trim(adjustl(words(i)))
97 tstring = string
98 do j = i + 1, nwords
99 if (len(trim(adjustl(string))) > 0) then
100 tstring = trim(adjustl(tstring))//' '//trim(adjustl(words(j)))
101 else
102 tstring = trim(adjustl(words(j)))
103 end if
104 ilen = len(trim(adjustl(tstring)))
105 if (ilen == 0) then
106 continue
107 else if (ilen <= width) then
108 words(j) = ' '
109 string = tstring
110 else
111 exit
112 end if
113 end do
114 words(i) = string
115 end do
116
117
118 do i = 1, nwords
119 ilen = len(trim(adjustl(words(i))))
120 if (ilen > 0) then
121 this%nheader_lines = this%nheader_lines + 1
122 end if
123 end do
124
125
126 allocate (this%initial_lines(this%nheader_lines))
127 do i = 1, this%nheader_lines
128 this%initial_lines(i) = words(i) (1:width)
129 end do
130
131
132 deallocate (words)
133
134
135 return
136