Skip to content

Commit 2e94eaa

Browse files
committed
Add doc for plan
1 parent 9f3029d commit 2e94eaa

File tree

1 file changed

+77
-3
lines changed

1 file changed

+77
-3
lines changed

fortran/solver/src/plan.f90

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ module plan_mod
22
use step_mod, only: step_t
33
implicit none
44
private
5-
type :: plan_t
6-
integer :: current = 1
7-
type(step_t), allocatable :: steps(:)
5+
6+
!> @brief plan to explore the labyrinth
7+
ype :: plan_t
8+
integer :: current = 1 !< current step to add; only for internal usage
9+
type(step_t), allocatable :: steps(:) !< array of steps
810
contains
911
procedure :: init
1012
procedure :: inited
@@ -15,19 +17,52 @@ module plan_mod
1517
procedure :: plan_assignment
1618
generic :: assignment(=) => plan_assignment
1719
end type plan_t
20+
1821
public :: plan_t
1922
contains
23+
24+
!>
25+
!> @brief initialise plan_t
26+
!>
27+
!> @param[in,out] plan - plan_t object
28+
!> @param[in] n_steps - number of steps in plan, 6 * n_rooms or 9 * n_rooms, usually
29+
!>
30+
!> @author foxtran
31+
!> @date Sep 8, 2025
32+
!>
2033
subroutine init(plan, n_steps)
2134
class(plan_t), intent(inout) :: plan
2235
integer, intent(in) :: n_steps
2336
if (allocated(plan%steps)) deallocate(plan%steps)
2437
plan%current = 1
2538
allocate(plan%steps(n_steps))
2639
end subroutine init
40+
41+
!>
42+
!> @brief check if plan was initialised
43+
!>
44+
!> @param[in] plan - plan_t object
45+
!> @return - was the plan_t object initialised
46+
!>
47+
!> @author foxtran
48+
!> @date Sep 8, 2025
49+
!>
2750
logical function inited(plan)
2851
class(plan_t), intent(in) :: plan
2952
inited = allocated(plan%steps)
3053
end function inited
54+
55+
!>
56+
!> @brief add step after exploration
57+
!>
58+
!> @param[in,out] plan - plan_t object
59+
!> @param[in] room_out - room from which guys exited
60+
!> @param[in] door_out - door from which guys exited
61+
!> @param[in] room_in - room to which guys entered
62+
!>
63+
!> @author foxtran
64+
!> @date Sep 8, 2025
65+
!>
3166
subroutine add_step(plan, room_out, door_out, room_in)
3267
class(plan_t), intent(inout) :: plan
3368
integer(1), intent(in) :: room_out, door_out, room_in
@@ -36,10 +71,30 @@ subroutine add_step(plan, room_out, door_out, room_in)
3671
plan%steps(plan%current)%room_in = room_in
3772
plan%current = plan%current + 1
3873
end subroutine add_step
74+
75+
!>
76+
!> @brief resets initialisation of plan
77+
!>
78+
!> @param[in,out] plan - plan_t object
79+
!>
80+
!> @author foxtran
81+
!> @date Sep 8, 2025
82+
!>
3983
subroutine reset(plan)
4084
class(plan_t), intent(inout) :: plan
4185
plan%current = 1
4286
end subroutine reset
87+
88+
!>
89+
!> @brief generates new plan to explore
90+
!>
91+
!> @details at the first step the most efficient way is to shuffle array containing the equal number of numbers from 0 to 5
92+
!>
93+
!> @param[in,out] plan - plan_t object
94+
!>
95+
!> @author foxtran
96+
!> @date Sep 8, 2025
97+
!>
4398
subroutine generate(plan, kind)
4499
use random_mod, only: shuffle
45100
class(plan_t), intent(inout) :: plan
@@ -63,13 +118,32 @@ subroutine generate(plan, kind)
63118
plan%steps(i)%door_out = steps(i)
64119
end do
65120
end subroutine generate
121+
122+
!>
123+
!> @brief prints structure of plan_t to stdout
124+
!>
125+
!> @param[in] plan - plan_t object
126+
!>
127+
!> @author foxtran
128+
!> @date Sep 8, 2025
129+
!>
66130
subroutine show(plan)
67131
class(plan_t), intent(in) :: plan
68132
integer :: i
69133
do i = 1, size(plan%steps)
70134
call plan%steps(i)%show()
71135
end do
72136
end subroutine show
137+
138+
!>
139+
!> @brief allows assignment without compiler bugs
140+
!>
141+
!> @param[out] lhs - plan_t object for initialisation
142+
!> @param[in] rhs - plan_t object with data
143+
!>
144+
!> @author foxtran
145+
!> @date Sep 8, 2025
146+
!>
73147
subroutine plan_assignment(lhs, rhs)
74148
class(plan_t), intent(out) :: lhs
75149
class(plan_t), intent(in) :: rhs

0 commit comments

Comments
 (0)