! This is a function. ! We probably have to declare this before the main program. function foo(x) result(y) integer, intent(in) :: x integer :: y y = x + 1 end function ! This is the main program. program MAIN ! let's try to call a function. integer :: foo ! We have to declare the return type of the function. character(len = 4) :: str integer :: z str = 'Bond' print *, str z = foo(41) print *,z print *,foo(007) stop end program