## Simple program in FORTRAN95

Code:
program iteration
real :: p
IMPLICIT NONE

end iteration

real :: a
a+2
end function add
It not working... Why?? I use PLATO IDE ( FORTRAN 95 )

I greet.
 What happens when you run it? Does it produce an error? I don't think you need to include the line call add(5), since add() is a function (and not a subroutine). The assignment statement below (p=add(5)) is sufficient. Try removing the line call add(5), and please provide the output or error message if it still does not work.
 Recognitions: Science Advisor There are so many things wrong here (at least five) that it suggests either you don't know Fortran at all, or you don't know how to interpret the messages you got when you tried to compile the code. The best answer to either problem is find a Fortran tutorial and work through it. This uses PLATO and Silverfrost: http://www.fortrantutorial.com/

## Simple program in FORTRAN95

Code:
program iteration

IMPLICIT NONE
call potega(5)

end iteration

real function potega(a)
real :: a
a+2
end function potega
And I have error:

Error: Statement not recognised
Warning: The result of FUNCTION POTEGA has never been set
Warning: n a call to POTEGA from another procedure, the first argument was of type INTEGER(KIND=3), it is now REAL(KIND=1)
 Dexter90: You really need to study just the basics...programming without knowing the syntax is just a guessing game. Code: program iteration IMPLICIT NONE real::a a = potega(5) write(*,*) a end iteration real function potega(a) real :: a potega = a+2 end function potega
 I have solid fundation in programming. Your code not woking, I was writing the same code
 o.k., I actually bother to compile now: Code: program iteration IMPLICIT NONE real::a, potega a = potega(5.0) write(*,*) a end program iteration real function potega(a) real :: a potega = a+2 end function potega Besides, I never said you did not have a solid foundation in progarmming, it just does not look like you are bothering to put a basic effort on reading fortran when you call the same function as a function as a subroutine in the same program. Good luck.
 Thank you, I was reading that the fortran functions are placed at the end, My mistake. I am sorry. I greet.
 Mentor Fortran distinguishes between FUNCTIONs and SUBROUTINEs. Your code mixed these two ideas, as you declared add/potega as a function, but used it as if it were a subroutine. The other major mistake that I saw was the expression 'a + 2' in the function body. Writing an expression rather than an assignment statement makes me question how solid your programming foundation is. That is not the kind of mistake that someone with experience makes.