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 ProgrammingYou can also specify a different passed-object dummy argument using the PASS bindingattribute.For example, suppose that the sh dummy in our initialize subroutine did not appear asthe first argument. <strong>The</strong>n you must specify a PASS attribute, as illustrated in the following code:type shapeinteger :: colorlogical :: filledinteger :: xinteger :: ycontainsprocedure, pass(sh) :: initializeend type shapeIf you do not want to specify a passed-object dummy argument, you can do so using theNOPASS binding-attribute:type shapeinteger :: colorlogical :: filledinteger :: xinteger :: ycontainsprocedure, nopass :: initializeend type shapeWhen you specify NOPASS, you invoke the type-bound procedure the same way. <strong>The</strong> onlydifference is that the invoking object is not automatically assigned to a passed-object dummy inthe type-bound procedure. For example, if you were to specify NOPASS in the initializetype-bound procedure, then you would invoke it this way:type(shape) :: shp! declare an instance of shapecall shp%initialize(shp, 1, .true., 10, 20) ! initialize shapeYou explicitly specify shp for the first argument of initialize because it was declared NOPASS.7.2.6. Inheritance and Type-Bound ProceduresA child type inherits or reuses components from their parent or ancestor types. When dealingwith F2003 derived types, this inheritance applies to both data and procedures. In the followingexample, rectangle and square both inherit the initialize type-bound procedure fromshape.type shapeinteger :: colorlogical :: filledinteger :: xinteger :: ycontainsprocedure :: initializeend type shapetype, EXTENDS ( shape ) :: rectangleinteger :: lengthinteger :: widthend type rectangletype, EXTENDS ( rectangle ) :: squareend type square<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 129

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

Saved successfully!

Ooh no, something went wrong!