Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ! This program just uses the interface defined in the module
  2. program ifce
  3.     use something
  4.     implicit none
  5.     real :: a
  6.     double precision :: b
  7.     integer :: c
  8.  
  9.     a=do_something(a)
  10.     b=do_something(b)
  11.     c=do_something(c)
  12. end program ifce
  13.  
  14. module something
  15.     interface do_something
  16.         module procedure do_something_i
  17.         module procedure do_something_r
  18.         module procedure do_something_d
  19.     end interface do_something
  20. contains
  21.     function do_something_i(i) result(ii)
  22.         integer :: i, ii
  23.         print *, "I'm an integer"
  24.     end function do_something_i
  25.     function do_something_r(r) result(rr)
  26.         real :: r, rr
  27.         print *, "I'm a real"
  28.     end function do_something_r
  29.     function do_something_d(d) result(dd)
  30.         double precision :: d, dd
  31.         print *, "I'm a double"
  32.     end function do_something_d
  33. end module something
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement