Skip to content

Commit 4524fad

Browse files
committed
Fix linting issues after rebase
1 parent e01dc14 commit 4524fad

File tree

4 files changed

+71
-39
lines changed

4 files changed

+71
-39
lines changed

src/poisson/main.f90

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ program main
33

44
implicit none
55

6-
integer :: num_nodes, num_elements, num_boundary_points, element_to_node(3,mxe), vb_index(mxe), boundary_node_num(2,mxb), num_side_nodes(4,mxb)
6+
integer :: num_nodes, num_elements, num_boundary_points, element_to_node(3,mxe), vb_index(mxe), &
7+
boundary_node_num(2,mxb), num_side_nodes(4,mxb)
78
real :: coordinates(2, mxp), nodal_value_of_f(mxp), vb1(mxc), vb2(mxc), vb(3,mxc)
89
integer :: fname_io = 100, fname_out_io = 101
910

@@ -37,12 +38,14 @@ program main
3738
!!
3839
!! *** Reads the triangular mesh and problem constants: Kx,Ky,Q,fp,q
3940
!!
40-
call read_input_file(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates,boundary_node_num,num_side_nodes,vb,vb1,vb2,fname_io)
41+
call read_input_file(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates,boundary_node_num, &
42+
num_side_nodes,vb,vb1,vb2,fname_io)
4143

4244
!!
4345
!! *** Assembles and solves the system of equations
4446
!!
45-
call pcg(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates,boundary_node_num,num_side_nodes,vb,vb1,vb2,nodal_value_of_f)
47+
call pcg(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates,boundary_node_num,num_side_nodes,vb, &
48+
vb1,vb2,nodal_value_of_f)
4649

4750
!!
4851
!! *** Writes the computed solution

src/poisson/poisson.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ end subroutine read_input_file
244244
!! method. *
245245
!! *
246246
!!-----------------------------------------------------------------------------*
247-
subroutine pcg(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates,boundary_node_num,num_side_nodes,vb,vb1,vb2,nodal_value_of_f)
247+
subroutine pcg(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates,boundary_node_num, &
248+
num_side_nodes,vb,vb1,vb2,nodal_value_of_f)
248249
implicit none
249250

250251
real, parameter :: eps = 1.e-04
@@ -456,7 +457,7 @@ subroutine pcg(num_nodes,num_elements,num_boundary_points,element_to_node,vb_ind
456457
is_converged = res<=rh0*tol
457458
if(is_converged) then
458459
! write(*,'(a,i4)') ' *** PCG converged: iterations = ',it
459-
exit
460+
exit nit_loop
460461
endif
461462
end do nit_loop
462463

testing/test-drive/test_poisson.f90

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module test_drive_poisson
55

66
implicit none
77

8+
public
9+
810
!> Scalar values which define a mesh
911
type :: mesh_scalars_t
1012
integer :: num_nodes, num_elements, num_boundary_points, num_sets, num_dirichlet_boundary_conditions, &
@@ -50,7 +52,7 @@ module test_drive_poisson
5052
contains
5153

5254
!> Collect all test in this module into a single test suite
53-
!!
55+
!!
5456
!! @param testsuite - An array of unittest_types in which to store this suite's tests
5557
subroutine collect_poisson_testsuite(testsuite)
5658
type(unittest_type), allocatable, intent(out) :: testsuite(:)
@@ -64,11 +66,12 @@ end subroutine collect_poisson_testsuite
6466
!> Define the values of a mesh with box_size = 10 and edge_size = 5
6567
subroutine get_15_05_mesh_values(data_filename, mesh_scalars, mesh_vectors)
6668
implicit none
67-
character(len=:), allocatable :: data_filename
69+
character(len=:), allocatable, intent(inout) :: data_filename
6870
type(mesh_scalars_t), intent(out) :: mesh_scalars
6971
type(mesh_vectors_t), intent(out) :: mesh_vectors
70-
71-
character(len=100) :: data_filename_fixed = "testing/data/square_mesh_15_5"
72+
73+
character(len=100) :: data_filename_fixed
74+
data_filename_fixed = "testing/data/square_mesh_15_5"
7275

7376
allocate(character(len(trim(data_filename_fixed))) :: data_filename)
7477
data_filename = trim(data_filename_fixed)
@@ -81,8 +84,12 @@ subroutine get_15_05_mesh_values(data_filename, mesh_scalars, mesh_vectors)
8184
mesh_scalars%num_neumann_boundary_conditions = 0
8285

8386
mesh_vectors%element_to_node(1,1:mesh_scalars%num_elements) = [1, 2, 3, 1, 2, 3, 5, 6, 7, 5, 6, 7, 9, 10, 11, 9, 10, 11]
84-
mesh_vectors%element_to_node(2,1:mesh_scalars%num_elements) = [2, 3, 4, 6, 7, 8, 6, 7, 8, 10, 11, 12, 10, 11, 12, 14, 15, 16]
85-
mesh_vectors%element_to_node(3,1:mesh_scalars%num_elements) = [6, 7, 8, 5, 6, 7, 10, 11, 12, 9, 10, 11, 14, 15, 16, 13, 14, 15]
87+
mesh_vectors%element_to_node(2,1:mesh_scalars%num_elements) = [ &
88+
2, 3, 4, 6, 7, 8, 6, 7, 8, 10, 11, 12, 10, 11, 12, 14, 15, 16 &
89+
]
90+
mesh_vectors%element_to_node(3,1:mesh_scalars%num_elements) = [ &
91+
6, 7, 8, 5, 6, 7, 10, 11, 12, 9, 10, 11, 14, 15, 16, 13, 14, 15 &
92+
]
8693
mesh_vectors%vb_index(1:mesh_scalars%num_elements) = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
8794
mesh_vectors%boundary_node_num(1,1:mesh_scalars%num_boundary_points) = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
8895
mesh_vectors%boundary_node_num(2,1:mesh_scalars%num_boundary_points) = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
@@ -94,8 +101,12 @@ subroutine get_15_05_mesh_values(data_filename, mesh_scalars, mesh_vectors)
94101
mesh_vectors%vb(1:3,mesh_scalars%num_sets) = [1, 1, 1]
95102
mesh_vectors%vb1(1:mesh_scalars%num_dirichlet_boundary_conditions) = 0
96103
mesh_vectors%vb1(1:mesh_scalars%num_neumann_boundary_conditions) = 0
97-
mesh_vectors%coordinates(1,1:mesh_scalars%num_nodes) = [1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0]
98-
mesh_vectors%coordinates(2,1:mesh_scalars%num_nodes) = [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]
104+
mesh_vectors%coordinates(1,1:mesh_scalars%num_nodes) = [ &
105+
1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0 &
106+
]
107+
mesh_vectors%coordinates(2,1:mesh_scalars%num_nodes) = [ &
108+
1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0 &
109+
]
99110
end subroutine get_15_05_mesh_values
100111

101112
!> Verification code for the read_input_file subroutine
@@ -107,12 +118,14 @@ subroutine verify_inp(error, inputs, expected_outputs)
107118

108119
integer :: actual_num_nodes, actual_num_elements, actual_num_boundary_points, &
109120
actual_element_to_node(3,mxp), actual_vb_index(mxe), actual_boundary_node_num(2,mxb), &
110-
actual_num_side_nodes(4,mxb), file_io = 123, i, j
111-
real :: actual_vb(3,mxc), actual_vb1(mxc), actual_vb2(mxc), actual_coordinates(2, mxp)
121+
actual_num_side_nodes(4,mxb), file_io, i, j
122+
real :: actual_vb(3,mxc), actual_vb1(mxc), actual_vb2(mxc), actual_coordinates(2, mxp), threshold
112123
character(len=200) :: failure_message
113-
real :: threshold = 1e-06
124+
125+
threshold = 1e-06
114126

115127
! Open the file ready to be read
128+
file_io = 123
116129
call open_file(inputs%data_filename, 'old', file_io)
117130

118131
call read_input_file( &
@@ -141,54 +154,65 @@ subroutine verify_inp(error, inputs, expected_outputs)
141154

142155
do i = 1, expected_outputs%mesh_scalars%num_elements
143156
do j = 1, 3
144-
write(failure_message,'(a,i1,a,i1,a,i2,a,i2)') "Unexpected value for element_to_node(", j, ",", i, "), got ", actual_element_to_node(j, i), " expected ", expected_outputs%mesh_vectors%element_to_node(j, i)
145-
call check(error, actual_element_to_node(j, i), expected_outputs%mesh_vectors%element_to_node(j, i), failure_message)
157+
write(failure_message,'(a,i1,a,i1,a,i2,a,i2)') "Unexpected value for element_to_node(", j, ",", i, "), got ", &
158+
actual_element_to_node(j, i), " expected ", expected_outputs%mesh_vectors%element_to_node(j, i)
159+
call check(error, actual_element_to_node(j, i), expected_outputs%mesh_vectors%element_to_node(j, i), &
160+
failure_message)
146161
if (allocated(error)) return
147-
end do
162+
end do
148163

149-
write(failure_message,'(a,i1,a,i2,a,i2)') "Unexpected value for vb_index(", i, "), got ", actual_vb_index(i), " expected ", expected_outputs%mesh_vectors%vb_index(i)
164+
write(failure_message,'(a,i1,a,i2,a,i2)') "Unexpected value for vb_index(", i, "), got ", &
165+
actual_vb_index(i), " expected ", expected_outputs%mesh_vectors%vb_index(i)
150166
call check(error, actual_vb_index(i), expected_outputs%mesh_vectors%vb_index(i), failure_message)
151167
if (allocated(error)) return
152168
end do
153169

154170
do i = 1, expected_outputs%mesh_scalars%num_nodes
155171
do j = 1, 2
156-
write(failure_message,'(a,i1,a,i1,a,f5.2,a,f5.2)') "Unexpected value for coordinates(", j, ",", i, "), got ", actual_coordinates(j, i), " expected ", expected_outputs%mesh_vectors%coordinates(j, i)
157-
call check(error, actual_coordinates(j, i), expected_outputs%mesh_vectors%coordinates(j, i), failure_message, thr=threshold)
172+
write(failure_message,'(a,i1,a,i1,a,f5.2,a,f5.2)') "Unexpected value for coordinates(", j, ",", i, "), got ", &
173+
actual_coordinates(j, i), " expected ", expected_outputs%mesh_vectors%coordinates(j, i)
174+
call check(error, actual_coordinates(j, i), expected_outputs%mesh_vectors%coordinates(j, i), &
175+
failure_message, thr=threshold)
158176
if (allocated(error)) return
159-
end do
177+
end do
160178
end do
161179

162180
do i = 1, expected_outputs%mesh_scalars%num_boundary_points
163181
do j = 1, 2
164-
write(failure_message,'(a,i1,a,i1,a,i2,a,i2)') "Unexpected value for boundary_node_num(", j, ",", i, "), got ", actual_boundary_node_num(j, i), " expected ", expected_outputs%mesh_vectors%boundary_node_num(j, i)
165-
call check(error, actual_boundary_node_num(j, i), expected_outputs%mesh_vectors%boundary_node_num(j, i), failure_message)
182+
write(failure_message,'(a,i1,a,i1,a,i2,a,i2)') "Unexpected value for boundary_node_num(", j, ",", i, "), got ", &
183+
actual_boundary_node_num(j, i), " expected ", expected_outputs%mesh_vectors%boundary_node_num(j, i)
184+
call check(error, actual_boundary_node_num(j, i), expected_outputs%mesh_vectors%boundary_node_num(j, i), &
185+
failure_message)
166186
if (allocated(error)) return
167-
end do
187+
end do
168188

169189
do j = 1, 4
170-
write(failure_message,'(a,i1,a,i1,a,i2,a,i2)') "Unexpected value for num_side_nodes(", j, ",", i, "), got ", actual_num_side_nodes(j, i), " expected ", expected_outputs%mesh_vectors%num_side_nodes(j, i)
190+
write(failure_message,'(a,i1,a,i1,a,i2,a,i2)') "Unexpected value for num_side_nodes(", j, ",", i, "), got ", &
191+
actual_num_side_nodes(j, i), " expected ", expected_outputs%mesh_vectors%num_side_nodes(j, i)
171192
call check(error, actual_num_side_nodes(j, i), expected_outputs%mesh_vectors%num_side_nodes(j, i), failure_message)
172193
if (allocated(error)) return
173194
end do
174195
end do
175196

176197
do i = 1, expected_outputs%mesh_scalars%num_sets
177198
do j = 1, 3
178-
write(failure_message,'(a,i1,a,i1,a,f5.2,a,f5.2)') "Unexpected value for vb(", j, ",", i, "), got ", actual_vb(j, i), " expected ", expected_outputs%mesh_vectors%vb(j, i)
199+
write(failure_message,'(a,i1,a,i1,a,f5.2,a,f5.2)') "Unexpected value for vb(", j, ",", i, "), got ", &
200+
actual_vb(j, i), " expected ", expected_outputs%mesh_vectors%vb(j, i)
179201
call check(error, actual_vb(j, i), expected_outputs%mesh_vectors%vb(j, i), failure_message, thr=threshold)
180202
if (allocated(error)) return
181203
end do
182204
end do
183205

184206
do i = 1, expected_outputs%mesh_scalars%num_dirichlet_boundary_conditions
185-
write(failure_message,'(a,i1,a,f5.2,a,f5.2)') "Unexpected value for vb1(", i, "), got ", actual_vb1(i), " expected ", expected_outputs%mesh_vectors%vb1(i)
207+
write(failure_message,'(a,i1,a,f5.2,a,f5.2)') "Unexpected value for vb1(", i, "), got ", &
208+
actual_vb1(i), " expected ", expected_outputs%mesh_vectors%vb1(i)
186209
call check(error, actual_vb1(i), expected_outputs%mesh_vectors%vb1(i), failure_message, thr=threshold)
187210
if (allocated(error)) return
188211
end do
189212

190213
do i = 1, expected_outputs%mesh_scalars%num_neumann_boundary_conditions
191-
write(failure_message,'(a,i1,a,f5.2,a,f5.2)') "Unexpected value for vb2(", i, "), got ", actual_vb2(i), " expected ", expected_outputs%mesh_vectors%vb2(i)
214+
write(failure_message,'(a,i1,a,f5.2,a,f5.2)') "Unexpected value for vb2(", i, "), got ", &
215+
actual_vb2(i), " expected ", expected_outputs%mesh_vectors%vb2(i)
192216
call check(error, actual_vb2(i), expected_outputs%mesh_vectors%vb2(i), failure_message, thr=threshold)
193217
if (allocated(error)) return
194218
end do
@@ -214,12 +238,13 @@ subroutine verify_pcg(error, inputs, expected_outputs)
214238

215239
type(pcg_inputs_t), intent(in) :: inputs
216240
type(pcg_expected_outputs_t), intent(in) :: expected_outputs
217-
218-
real :: actual_nodal_value_of_f(mxp)
241+
242+
real :: actual_nodal_value_of_f(mxp), threshold
219243
character(len=200) :: failure_message
220-
real :: threshold = 1e-06
221244
integer :: i
222245

246+
threshold = 1e-06
247+
223248
call pcg(&
224249
inputs%mesh_scalars%num_nodes, &
225250
inputs%mesh_scalars%num_elements, &
@@ -237,7 +262,8 @@ subroutine verify_pcg(error, inputs, expected_outputs)
237262

238263
! verify outputs
239264
do i = 1, inputs%mesh_scalars%num_nodes
240-
write(failure_message,'(a,i3,a,f9.7,a,f9.7)') "Unexpected value for coordinates(", i, "), got ", actual_nodal_value_of_f(i), " expected ", expected_outputs%nodal_value_of_f(i)
265+
write(failure_message,'(a,i3,a,f9.7,a,f9.7)') "Unexpected value for coordinates(", i, "), got ", &
266+
actual_nodal_value_of_f(i), " expected ", expected_outputs%nodal_value_of_f(i)
241267
call check(error, actual_nodal_value_of_f(i), expected_outputs%nodal_value_of_f(i), failure_message, thr=threshold)
242268
if (allocated(error)) return
243269
end do
@@ -252,10 +278,12 @@ subroutine test_pcg_15_05(error)
252278
type(pcg_expected_outputs_t) :: expected_outputs
253279

254280
call get_15_05_mesh_values(inputs%data_filename, inputs%mesh_scalars, inputs%mesh_vectors)
255-
expected_outputs%nodal_value_of_f(1:inputs%mesh_scalars%num_nodes) = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.407407, 0.481481, 0.518518, 0.592592]
281+
expected_outputs%nodal_value_of_f(1:inputs%mesh_scalars%num_nodes) = [ &
282+
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.407407, 0.481481, 0.518518, 0.592592 &
283+
]
256284

257285
call verify_pcg(error, inputs, expected_outputs)
258286

259287
deallocate(inputs%data_filename)
260288
end subroutine test_pcg_15_05
261-
end module
289+
end module test_drive_poisson

testing/veggies/test_poisson_given_when_then.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function check_num_nodes(input) result(result_)
133133
class default
134134
result_ = fail("Didn't get load_data_file_result_t")
135135
end select
136-
end function
136+
end function check_num_nodes
137137

138138
function check_num_elements(input) result(result_)
139139
implicit none
@@ -147,7 +147,7 @@ function check_num_elements(input) result(result_)
147147
class default
148148
result_ = fail("Didn't get load_data_file_result_t")
149149
end select
150-
end function
150+
end function check_num_elements
151151

152152
function check_num_boundary_points(input) result(result_)
153153
implicit none
@@ -161,7 +161,7 @@ function check_num_boundary_points(input) result(result_)
161161
class default
162162
result_ = fail("Didn't get load_data_file_result_t")
163163
end select
164-
end function
164+
end function check_num_boundary_points
165165

166166
function check_element_to_node(input) result(result_)
167167
implicit none

0 commit comments

Comments
 (0)