How to return a value from a fortran function

How to return a value from a fortran function



I would like to return a value from a function and receive it in the main program. It gives two errors. Can you make the following fortran code work?


      program trial

      real*8 a,b,c




      call fn(a,b,c)


      if (fn.eq.1) write(*,*)


      end program trial





      function fn(a,b,c)

      real*8 a,b,c


      if ( return 0


      return 1

      end function fn

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I would suggest you avail yourself of a good Fortran reference or tutorial.

Seyhan Emre,

You posted the same question in an earlier thread: . Please read the responses that were given in that thread instead of reposting. I second Linda's advice above.

Leave a Comment

Please sign in to add a comment. Not a member? Join today