10.07.2015 Views

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Object Oriented ProgrammingHere is a simple program that adds values to a list and prints out the values. You can downloadthe complete list_mod and link_mod modules, which encapsulate the list and link objectsrespectively.program mainuse list_modimplicit noneinteger itype(list) :: my_listdo i=1, 10call my_list%add(i)enddocall my_list%add(1.23)call my_list%add('A')call my_list%add('B')call my_list%add('C')call my_list%printvalues()end program main% pgfortran -c list.f90% pgfortran -c link.f90% pgfortran -V main.f90 list.o link.o...% a.out123456789101.230000ABC7.4.5. Abstract Types and Deferred Bindings<strong>The</strong> example, Data Polymorphic Linked List, contained a list derived type that acted as the APIfor a linked list. Rather than employ one implementation for the list derived type, you couldchoose to define some of the components and type-bound procedures for a list object and requirethe user to define the rest. One way to do this is through an abstract type.An abstract type is a derived type that cannot be instantiated. Instead, it is extended and furtherdefined by another type. <strong>The</strong> type extension can also be declared abstract, but ultimately it mustbe extended by a non-abstract type if it ever is to be instantiated in a program.<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 145

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!