File: subroutines_09.f90

package info (click to toggle)
lfortran 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 46,332 kB
  • sloc: cpp: 137,068; f90: 51,260; python: 6,444; ansic: 4,277; yacc: 2,285; fortran: 806; sh: 524; makefile: 30; javascript: 15
file content (76 lines) | stat: -rw-r--r-- 1,497 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
module subroutines_09_tomlf_build_array
    implicit none
    private

    public :: get_value

    !> Getter functions to manipulate TOML arrays
    interface get_value
       module procedure :: get_elem_table
       module procedure :: get_elem_value_string
    end interface get_value


 contains


 subroutine get_elem_table(array, pos, ptr, stat)

    !> Instance of the TOML array
    integer, intent(inout) :: array

    !> Position in the array
    integer, intent(in) :: pos

    !> Pointer to child table
    integer, pointer, intent(out) :: ptr

    !> Status of operation
    logical, intent(out), optional :: stat

    nullify(ptr)

    stat = .true.

 end subroutine get_elem_table


 !> Retrieve TOML value as deferred-length character
 subroutine get_elem_value_string(array, pos, ptr, def, stat)

    !> Instance of the TOML array
    logical, intent(inout) :: array

    !> Position in the array
    integer, intent(in) :: pos

    !> Pointer to child table
    integer, pointer, intent(out) :: ptr

    !> Status of operation
    logical, intent(out), optional :: stat

    integer, intent(out), optional :: def

    nullify(ptr)

    stat = .true.

 end subroutine get_elem_value_string


 end module


 program main
    use subroutines_09_tomlf_build_array, only: get_value
    implicit none

    integer :: a = 10, pos
    integer, pointer :: ptr
    logical :: f = .false.

    call get_value(a, pos, ptr, stat=f)
    call get_value(f, pos, ptr, stat=f)

 end program main