File: wasm1.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 (45 lines) | stat: -rw-r--r-- 954 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
program wasm1
    implicit none

    print *, sqr(5)
    print *, add(5, 4)
    print *, add64(4_8, 5_8)
    print *, computeCircleArea(5)
    print *, my_add(5, 4)

    contains

    function sqr(x) result(r)
        implicit none
        integer, intent(in):: x
        integer :: r
        r = x * x
    end function

    function add(x, y) result(r)
        implicit none
        integer, intent(in):: x, y
        integer :: r
        r = x + y
    end function

    function add64(x, y) result(r)
        implicit none
        integer(8), intent(in):: x, y
        integer(8) :: r
        r = x + y
    end function

    function computeCircleArea(radius) result(area)
        implicit none
        integer, intent(in):: radius
        integer :: PI, area
        PI = 3
        area = PI * sqr(radius)
    end function

    integer function my_add(a, b) result(c)
        integer, intent(in) :: a, b
        c = a + b
    end function
end program