File: functions_36.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (46 lines) | stat: -rw-r--r-- 1,072 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


! Test circular dependencies when declaring interface and using it in the function constructing that same interface


module functions_36_mod
    real :: var
    interface generic  !>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Depends on both `f1` and `f2` to be declared 
      procedure :: f1
      procedure :: f2
    end interface
    
    contains
    
    pure function f1(vv) result(length)
    real, intent(in) :: vv
    integer :: rr(generic(vv, 2)) !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Depends on `f2` (but through interface) to be fully declared
    integer :: length
    length = size(rr)
    end function 
    
    pure function f2(rr, int) result(length)
    real, intent(in) :: rr
    integer, intent(in) :: int
    integer :: length
    length = int*2
    end function 
    
    subroutine maybe()
      character(10) :: string(generic(var)) 
      print *, size(string)
      if (size(string) /= 4) error stop
    end subroutine maybe
    
end module 
    
    
program functions_36
    use functions_36_mod
    var =1.5
    call maybe()
end program