How to return a value from a fortran function

How to return a value from a fortran function

Hello,

 

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

      a=1.d0

      b=0.d0

     

      call fn(a,b,c)

     

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

  

      end program trial

     

     

     

     

      function fn(a,b,c)

      real*8 a,b,c

     

      if (a.gt.0) 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.

Linda

Seyhan Emre,

You posted the same question in an earlier thread: http://software.intel.com/en-us/forums/topic/382162 . 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