Skip to content

Commit 0843dbe

Browse files
committed
give inp and out clearer names
1 parent e911eb2 commit 0843dbe

File tree

5 files changed

+30
-41
lines changed

5 files changed

+30
-41
lines changed

src/poisson/main.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ program main
3737
!!
3838
!! *** Reads the triangular mesh and problem constants: Kx,Ky,Q,fp,q
3939
!!
40-
call inp(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates,boundary_node_num,num_side_nodes,vb,vb1,vb2,fname_io)
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)
4141

4242
!!
4343
!! *** Assembles and solves the system of equations
@@ -47,5 +47,5 @@ program main
4747
!!
4848
!! *** Writes the computed solution
4949
!!
50-
call out(num_nodes,num_elements,element_to_node,coordinates,nodal_value_of_f,fname_out_io)
50+
call write_output_file(num_nodes,num_elements,element_to_node,coordinates,nodal_value_of_f,fname_out_io)
5151
end program main

src/poisson/poisson.f90

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ subroutine open_file(file_name, status, file_io)
116116
end if
117117
end subroutine open_file
118118

119-
!!-----------------------------------------------------------------------------*
120-
!! *
121-
!! "inp" reads the input data: triangular mesh and problem parameters. *
122-
!! *
123-
!!-----------------------------------------------------------------------------*
124-
subroutine inp(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates, &
119+
!!---------------------------------------------------------------------------------*
120+
!! *
121+
!! "read_input_file" reads the input data: triangular mesh and problem parameters. *
122+
!! *
123+
!!---------------------------------------------------------------------------------*
124+
subroutine read_input_file(num_nodes,num_elements,num_boundary_points,element_to_node,vb_index,coordinates, &
125125
boundary_node_num,num_side_nodes,vb,vb1,vb2,file_io)
126126
implicit none
127127

@@ -229,7 +229,7 @@ subroutine inp(num_nodes,num_elements,num_boundary_points,element_to_node,vb_ind
229229
read(file_io,*) num_side_nodes(1,ib),num_side_nodes(2,ib),num_side_nodes(3,ib),num_side_nodes(4,ib)
230230
end do
231231

232-
end subroutine inp
232+
end subroutine read_input_file
233233

234234
!!-----------------------------------------------------------------------------*
235235
!! *
@@ -460,9 +460,9 @@ subroutine pcg(num_nodes,num_elements,num_boundary_points,element_to_node,vb_ind
460460
end subroutine pcg
461461

462462
!!-----------------------------------------------------------------------------*
463-
!! "out" writes output results. *
463+
!! "write_output_file" writes output results. *
464464
!!-----------------------------------------------------------------------------*
465-
subroutine out(num_nodes,num_elements,element_to_node,coordinates,nodal_value_of_f,file_io)
465+
subroutine write_output_file(num_nodes,num_elements,element_to_node,coordinates,nodal_value_of_f,file_io)
466466
implicit none
467467

468468
integer, intent(in) :: num_nodes,num_elements,element_to_node(3,mxp), file_io
@@ -482,5 +482,5 @@ subroutine out(num_nodes,num_elements,element_to_node,coordinates,nodal_value_of
482482
end do
483483

484484
return
485-
end subroutine out
485+
end subroutine write_output_file
486486
end module poisson

testing/test-drive/test_poisson.f90

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module test_drive_poisson
22
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
33
use mesh_generator, only : calculate_mesh
4-
use poisson, only : open_file, inp, mxp, mxe, mxb, mxc, pcg
4+
use poisson, only : open_file, read_input_file, mxp, mxe, mxb, mxc, pcg, write_output_file
55

66
implicit none
77

@@ -17,12 +17,12 @@ module test_drive_poisson
1717
real :: vb(3,mxc), vb1(mxc), vb2(mxc), coordinates(2, mxp)
1818
end type mesh_vectors_t
1919

20-
!> inp test inputs
20+
!> read_input_file test inputs
2121
type :: inp_inputs_t
2222
character(len=:), allocatable :: data_filename
2323
end type inp_inputs_t
2424

25-
!> inp test expected outputs
25+
!> read_input_file test expected outputs
2626
type :: inp_expected_outputs_t
2727
type(mesh_scalars_t) :: mesh_scalars
2828
type(mesh_vectors_t) :: mesh_vectors
@@ -40,12 +40,12 @@ module test_drive_poisson
4040
real :: nodal_value_of_f(mxp)
4141
end type pcg_expected_outputs_t
4242

43-
!> out test inputs
44-
type :: out_inputs_t
43+
!> write_output_file test inputs
44+
type :: write_output_file_inputs_t
4545
type(mesh_scalars_t) :: mesh_scalars
4646
type(mesh_vectors_t) :: mesh_vectors
4747
real :: nodal_value_of_f(mxp)
48-
end type out_inputs_t
48+
end type write_output_file_inputs_t
4949

5050
contains
5151

@@ -98,7 +98,7 @@ subroutine get_15_05_mesh_values(data_filename, mesh_scalars, mesh_vectors)
9898
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]
9999
end subroutine get_15_05_mesh_values
100100

101-
!> Verification code for the inp subroutine
101+
!> Verification code for the read_input_file subroutine
102102
subroutine verify_inp(error, inputs, expected_outputs)
103103
implicit none
104104
type(error_type), allocatable, intent(out) :: error
@@ -115,7 +115,7 @@ subroutine verify_inp(error, inputs, expected_outputs)
115115
! Open the file ready to be read
116116
call open_file(inputs%data_filename, 'old', file_io)
117117

118-
call inp( &
118+
call read_input_file( &
119119
actual_num_nodes, &
120120
actual_num_elements, &
121121
actual_num_boundary_points, &
@@ -193,7 +193,7 @@ subroutine verify_inp(error, inputs, expected_outputs)
193193
if (allocated(error)) return
194194
end do
195195
end subroutine verify_inp
196-
!> A test for the inp subroutine with box_size = 10 and edge_size = 5
196+
!> A test for the read_input_file subroutine with box_size = 10 and edge_size = 5
197197
subroutine test_inp_15_05(error)
198198
implicit none
199199
type(error_type), allocatable, intent(out) :: error
@@ -258,15 +258,4 @@ subroutine test_pcg_15_05(error)
258258

259259
deallocate(inputs%data_filename)
260260
end subroutine test_pcg_15_05
261-
262-
subroutine verify_out(error, inputs, expected_outputs)
263-
implicit none
264-
type(error_type), allocatable, intent(out) :: error
265-
266-
type(inp_inputs_t), intent(in) :: inputs
267-
type(inp_expected_outputs_t), intent(in) :: expected_outputs
268-
269-
! Verification code for the out subroutine
270-
! This is a placeholder for the actual verification code
271-
end subroutine verify_out
272-
end module
261+
end module

testing/veggies/test_poisson.f90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module veggies_poisson
2-
use poisson, only : open_file, inp, mxp, mxe, mxb, mxc
2+
use poisson, only : open_file, read_input_file, mxp, mxe, mxb, mxc
33
use veggies, only: &
44
assert_equals, &
55
describe, &
@@ -14,7 +14,7 @@ module veggies_poisson
1414

1515
!! @class inp_test_t
1616
!!
17-
!! @brief A class to store the inputs and expected outputs of the inp function
17+
!! @brief A class to store the inputs and expected outputs of the read_input_file function
1818
type, extends(input_t) :: inp_test_data_t
1919
character(len=:), allocatable :: data_filename
2020
integer :: expected_num_nodes, &
@@ -81,7 +81,7 @@ function test_poisson() result(tests)
8181
tests = describe( &
8282
"poisson", &
8383
[ it( &
84-
"inp passes with valid inputs", &
84+
"read_input_file passes with valid inputs", &
8585
[ example_t(inp_test_data_t("testing/data/square_mesh_10_5", &
8686
num_nodes_10_5, &
8787
num_elements_10_5, &
@@ -102,7 +102,7 @@ function test_poisson() result(tests)
102102
])
103103
end function
104104

105-
!> A unit test for the inp subroutine with valid inputs.
105+
!> A unit test for the read_input_file subroutine with valid inputs.
106106
!!
107107
!! @param inputs - An instance of the inp_test_t containing function
108108
!! inputs and expected outputs.
@@ -130,7 +130,7 @@ function check_inp_valid_inputs(input) result(result_)
130130
! Open the file ready to be read
131131
call open_file(input%data_filename, 'old', file_io)
132132

133-
call inp( &
133+
call read_input_file( &
134134
actual_num_nodes, &
135135
actual_num_elements, &
136136
actual_num_boundary_points, &

testing/veggies/test_poisson_given_when_then.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module veggies_poisson_given_when_then
1010
transformation_failure_t, &
1111
transformed_t, &
1212
when
13-
use poisson, only : inp, mxp, mxe, mxb, mxc
13+
use poisson, only : read_input_file, mxp, mxe, mxb, mxc
1414
implicit none
1515

1616
integer :: expected_num_nodes = 9, &
@@ -53,7 +53,7 @@ function test_poisson_given_when_then() result(test)
5353
"the data file square_mesh_10_5 exists", &
5454
data_file_state_t(), &
5555
[ when( &
56-
"the data file is loaded with poisson::inp", &
56+
"the data file is loaded with poisson::read_input_file", &
5757
load_data_file, &
5858
[ then__("the file will be open", check_file_is_open) &
5959
, then__("num_nodes will be as expected", check_num_nodes) &
@@ -83,7 +83,7 @@ function load_data_file(input) result(output)
8383
select type (input)
8484
type is (data_file_state_t)
8585
! declare local variables needed to perform transformation
86-
call inp( &
86+
call read_input_file( &
8787
load_data_file_result%actual_num_nodes, &
8888
load_data_file_result%actual_num_elements, &
8989
load_data_file_result%actual_num_boundary_points, &

0 commit comments

Comments
 (0)