Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 4th, 2011  |  syntax: Fortran  |  size: 0.79 KB  |  views: 153  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. module Mod
  2.     implicit none
  3.  
  4.         TYPE derivedtype
  5.  
  6.             integer::i
  7.             procedure(procInterface),POINTER,PASS::f=> NULL()
  8.    
  9.         END TYPE derivedtype
  10.  
  11.  
  12.         ABSTRACT INTERFACE
  13.        
  14.             subroutine procInterface(A)
  15.            
  16.                 import derivedtype            
  17.                 class(derivedtype),intent(inout)::A
  18.  
  19.             end subroutine
  20.  
  21.         END INTERFACE
  22.  
  23.     contains
  24.  
  25.    
  26.         subroutine proc1(A)
  27.             implicit none
  28.             type(derivedType),intent(inout)::A
  29.  
  30.                 A%i=999
  31.  
  32.         end subroutine
  33.  
  34. end module Mod
  35.  
  36.  
  37.  
  38. program Test1
  39.  
  40.     use Mod
  41.     implicit none
  42.  
  43.     type(derivedtype)::T
  44.  
  45.     T%i=123
  46.     T%f => proc1
  47.  
  48.     call T%f()
  49.  
  50.     print*,T%i
  51.  
  52. end program
clone this paste RAW Paste Data