CONGEN 5.0
Configuration generation for SCATCI
Loading...
Searching...
No Matches
congen_pagecontrol.f90
Go to the documentation of this file.
1! Copyright 2019
2!
3! For a comprehensive list of the developers that contributed to these codes
4! see the UK-AMOR website.
5!
6! This file is part of UKRmol-in (UKRmol+ suite).
7!
8! UKRmol-in is free software: you can redistribute it and/or modify
9! it under the terms of the GNU General Public License as published by
10! the Free Software Foundation, either version 3 of the License, or
11! (at your option) any later version.
12!
13! UKRmol-in is distributed in the hope that it will be useful,
14! but WITHOUT ANY WARRANTY; without even the implied warranty of
15! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16! GNU General Public License for more details.
17!
18! You should have received a copy of the GNU General Public License
19! along with UKRmol-in (in source/COPYING). Alternatively, you can also visit
20! <https://www.gnu.org/licenses/>.
21!> \brief Page control.
22!>
23!> Set of routines for pagination of the text output from the program.
24!> Every couple of lines a page header is produced.
25!>
27
28 implicit none
29
30 ! subroutines used from other modules
31 public addl
32 public ctlpg1
33 public newpg
34 public space
35 public taddl
36 public taddl1
37
38contains
39
40 !> \brief Add blank lines to output
41 !>
42 !> Increments the output line counter by the given number of lines. If the result exceeds the built-in
43 !> limit, a new page header is printed. Note that the lines are virtual, none is actually printed if
44 !> the pagination threshold is not reached.
45 !>
46 !> This function is mostly used before writing a known number of lines, so that all lines to be written
47 !> appear on the same page.
48 !>
49 subroutine addl (lines)
50
51 use global_utils, only : getin
52 use congen_data, only : head, lppr, lppmax, npage, nftw
53
54 integer, intent(in) :: lines
55
56 lppr = lppr + lines
57
58 if (lppr > lppmax) then
59 lppr = lines
60 npage = mod(npage + 1, 1000)
61
62 ! JMC this is putting the max. 3-digit number npage into the last 3 elements of HEAD
63 call getin (npage, 3, head(size(head) - 2), 1)
64 write(nftw, '("1",132A1,/)') head
65 end if
66
67 end subroutine addl
68
69
70 !> \brief Controls page layout and counting
71 !>
72 subroutine ctlpg1 (lpp, h1, nh1, h2, nh2)
73
74 use congen_data, only : head, lppr, lppmax, npage
75
76 integer :: lpp, nh1, nh2
77 character(len=1), dimension(nh1) :: h1
78 character(len=1), dimension(nh2) :: h2
79 intent (in) h1, h2, lpp, nh1, nh2
80
81 character(len=1) :: blank = ' '
82 integer :: i, il, im, ip
83 character(len=1), dimension(4) :: page = (/ 'P', 'A', 'G', 'E' /)
84
85 lppmax = lpp
86 if (lpp <= 0 .or. lpp > 60) lppmax = 60 ! JMC this line sets the default value for LPPMAX (see item LPP in the documentation)
87 lppr = lppmax
88 npage = 0
89 do i = 1, size(head)
90 head(i) = blank
91 end do
92
93 im = min(nh1, 120)
94 head(1:im) = h1(1:im)
95
96 if (im /= 120) then
97 il = im + 1
98 im = min(im + nh2, 120)
99 ip = 0
100 do i = il, im
101 ip = ip + 1
102 head(i) = h2(ip)
103 end do
104 end if
105
106 im = size(head) - 8 ! JMC changing from 124, as the last 8 elements of HEAD will contain 'PAGE' then ' ' then a 3-digit number
107
108 do i = 1, 4
109 im = im + 1
110 head(im) = page(i)
111 end do
112
113 end subroutine ctlpg1
114
115
116 !> \brief Start new page of output
117 !>
118 !> Resets the line counter, increments the page counter and prints the page header on standard output.
119 !>
120 subroutine newpg
121
122 use global_utils, only : getin
123 use congen_data, only : head, lppr, npage, nftw
124
125 lppr = 0
126 npage = mod(npage + 1, 1000)
127
128 ! JMC this is putting the max. 3-digit number npage into the last 3 elements of HEAD
129 call getin (npage, 3, head(size(head) - 2), 1)
130
131 write(nftw, '("1",132A1,/)') head
132
133 end subroutine newpg
134
135
136 !> \brief Add blank lines to output
137 !>
138 !> Increments the global line counter by the given number of lines. If the pagination limit is not reached,
139 !> it will actually write those empty lines (containing one space each) to output.
140 !>
141 !> \param lines Number of blank lines
142 !>
143 subroutine space (lines)
144
145 use congen_data, only : lppr, lppmax, nftw
146
147 integer, intent(in) :: lines
148
149 integer :: j
150
151 lppr = lppr + lines
152
153 if (lppr < lppmax) then
154 do j = 1, lines
155 write(nftw, '(" ")')
156 end do
157 end if
158
159 end subroutine space
160
161
162 !> \brief Add blank lines to output
163 !>
164 !> Advance the internal output line counter and check if pagination limit has been hit.
165 !>
166 !> \param lines Number of lines to add
167 !> \param lt Output status: 0 for no lines added (would overflow page), 1 for all lines added.
168 !>
169 subroutine taddl (lines, lt)
170
171 use congen_data, only : lppr, lppmax
172
173 integer, intent(in) :: lines
174 integer, intent(out) :: lt
175
176 lt = 0
177 if (lppr + lines <= lppmax) then
178 lppr = lppr + lines
179 lt = 1
180 end if
181
182 end subroutine taddl
183
184
185 !> \brief Check available lines.
186 !>
187 !> Checks if the given number of lines fits to page.
188 !>
189 !> \param lines Number of lines to test.
190 !> \param lt On return 0 if lines do not fit on page, 1 if they do.
191 !>
192 subroutine taddl1 (lines, lt)
193
194 use congen_data, only : lppr, lppmax
195
196 integer :: lines, lt
197 intent (in) lines
198 intent (out) lt
199
200 lt = 0
201 if (lppr + lines > lppmax) return
202 lt = 1
203
204 end subroutine taddl1
205
206
207end module
Module containing parameters / data required throughout the CONGEN program.
integer lppmax
Pagination limit - how many lines between two headers.
character(len=1), dimension(132) head
String with output page number and user-specific header text.
integer lppr
Global output line counter – number of lines on current page.
integer npage
Page counter, currently limited to 3 digits (see congen_pagecontrol::addl).
integer nftw
Unit number for printing; may be changed via the STATE namelist so not a parameter.
subroutine, public taddl1(lines, lt)
Check available lines.
subroutine, public ctlpg1(lpp, h1, nh1, h2, nh2)
Controls page layout and counting.
subroutine, public newpg
Start new page of output.
subroutine, public space(lines)
Add blank lines to output.
subroutine, public addl(lines)
Add blank lines to output.
subroutine, public taddl(lines, lt)
Add blank lines to output.