File: recursive.f90

package info (click to toggle)
fortran-language-server 3.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,268 kB
  • sloc: python: 9,688; f90: 1,195; fortran: 30; makefile: 28; ansic: 20
file content (23 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module tree
    type tree_inode
        integer :: value = 0
        type (tree_inode), pointer :: left=>null()
        type (tree_inode), pointer :: right=>null()
        type (tree_inode), pointer :: parent=>null()
    end type tree_inode

contains
    recursive subroutine recursive_assign_descending(node, vector, current_loc)
        type(tree_inode), pointer, intent(in) :: node
        integer, dimension(:), intent(inout)  :: vector
        integer, intent(inout)                :: current_loc

        if (associated(node)) then
            call recursive_assign_descending(node%right, vector, current_loc)
            vector(current_loc) = node%value
            current_loc = current_loc + 1
            call recursive_assign_descending(node%left, vector, current_loc)
        end if
        return
    end subroutine recursive_assign_descending
end module tree