Skip to content

Commit 9f3029d

Browse files
committed
Add doc for library
1 parent 798cdff commit 9f3029d

File tree

1 file changed

+69
-5
lines changed

1 file changed

+69
-5
lines changed

fortran/solver/src/library.f90

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ module library_mod
33
use plan_mod, only: plan_t
44
implicit none
55
private
6+
7+
!> @brief info about labyrinth
68
type :: library_t
7-
logical(1) :: inited = .false.
8-
type(room_t), allocatable :: rooms(:)
9-
type(plan_t), allocatable :: plans(:)
10-
integer :: current_plan = 1
9+
logical(1) :: inited = .false. !< was initialized
10+
type(room_t), allocatable :: rooms(:) !< rooms in labyrinth
11+
type(plan_t), allocatable :: plans(:) !< explored plans
12+
integer :: current_plan = 1 !< id of current plan; for internal usage
1113
contains
1214
procedure :: init
1315
procedure :: from_file
@@ -17,8 +19,20 @@ module library_mod
1719
procedure :: library_t_assignment
1820
generic :: assignment(=) => library_t_assignment
1921
end type library_t
22+
2023
public :: library_t
2124
contains
25+
26+
!>
27+
!> @brief initialise library_t
28+
!>
29+
!> @param[in,out] library - library_t object
30+
!> @param[in] n_rooms - number of rooms in labyrinth
31+
!> @param[in] n_plans - number of plans applied to labyrinth
32+
!>
33+
!> @author foxtran
34+
!> @date Sep 8, 2025
35+
!>
2236
subroutine init(library, n_rooms, n_plans)
2337
class(library_t), intent(inout) :: library
2438
integer, intent(in) :: n_rooms, n_plans
@@ -33,12 +47,35 @@ subroutine init(library, n_rooms, n_plans)
3347
end do
3448
library%current_plan = 1
3549
end subroutine init
50+
51+
!>
52+
!> @brief save extra plan
53+
!>
54+
!> @param[in,out] library - library_t object
55+
!> @param[in] n_rooms - number of rooms in labyrinth
56+
!> @param[in] n_plans - number of plans applied to labyrinth
57+
!>
58+
!> @author foxtran
59+
!> @date Sep 8, 2025
60+
!>
3661
subroutine add_plan(library, plan)
3762
class(library_t), intent(inout) :: library
3863
type(plan_t), intent(in) :: plan
3964
library%plans(library%current_plan) = plan
4065
library%current_plan = library%current_plan + 1
4166
end subroutine add_plan
67+
68+
!>
69+
!> @brief initialise library_t from file
70+
!>
71+
!> @note See examples/ about structure
72+
!>
73+
!> @param[in,out] library - library_t object
74+
!> @param[in] filename - file to load
75+
!>
76+
!> @author foxtran
77+
!> @date Sep 8, 2025
78+
!>
4279
subroutine from_file(library, filename)
4380
class(library_t), intent(inout) :: library
4481
character(len=*), intent(in) :: filename
@@ -55,7 +92,6 @@ subroutine from_file(library, filename)
5592
library%inited = .true.
5693

5794
open(newunit = lu, file = filename, status = "old", action = "read")
58-
5995
read(lu, *) n_rooms, n_plans, plans_length
6096

6197
call library%init(n_rooms, n_plans)
@@ -83,6 +119,15 @@ subroutine from_file(library, filename)
83119
call library%refine()
84120

85121
end subroutine from_file
122+
123+
!>
124+
!> @brief do some simple refinements based on knowledge about labyrinth
125+
!>
126+
!> @param[in,out] library - library_t object
127+
!>
128+
!> @author foxtran
129+
!> @date Sep 8, 2025
130+
!>
86131
subroutine refine(library)
87132
class(library_t), intent(inout) :: library
88133
integer :: plan_id, step_id, room_id, door_id, room_idx
@@ -127,6 +172,15 @@ subroutine refine(library)
127172
end associate
128173
end do
129174
end subroutine refine
175+
176+
!>
177+
!> @brief prints structure of library to stdout
178+
!>
179+
!> @param[in] library - library_t object
180+
!>
181+
!> @author foxtran
182+
!> @date Sep 8, 2025
183+
!>
130184
subroutine show(library)
131185
class(library_t), intent(in) :: library
132186
integer :: i
@@ -135,6 +189,16 @@ subroutine show(library)
135189
call library%rooms(i)%show()
136190
end do
137191
end subroutine show
192+
193+
!>
194+
!> @brief allows assignment without compiler bugs
195+
!>
196+
!> @param[out] lhs - library_t object for initialisation
197+
!> @param[in] rhs - library_t object with data
198+
!>
199+
!> @author foxtran
200+
!> @date Sep 8, 2025
201+
!>
138202
subroutine library_t_assignment(lhs, rhs)
139203
class(library_t), intent(out) :: lhs
140204
class(library_t), intent(in) :: rhs

0 commit comments

Comments
 (0)