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
|