support for oop in fortran 90 and some 95 n.
Download
Skip this Video
Download Presentation
Support for OOP in Fortran (90 and some 95)

Loading in 2 Seconds...

play fullscreen
1 / 15

Support for OOP in Fortran (90 and some 95) - PowerPoint PPT Presentation


  • 72 Views
  • Uploaded on

Support for OOP in Fortran (90 and some 95). By Samuel Robinson. Support for OOP in Fortran(90). ~General Characteristics -Backwards compatible with Fortran 77 -Classes are supported (keyword: module) -Supports static and dynamic binding (bdstatic, bdynamic) and heap dynamic

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Support for OOP in Fortran (90 and some 95)' - wesley-green


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
support for oop in fortran 90
Support for OOP in Fortran(90)

~General Characteristics

-Backwards compatible with Fortran 77

-Classes are supported (keyword: module)

-Supports static and dynamic binding

(bdstatic, bdynamic) and heap dynamic

variables

-Supports polymorphism /dynamic binding (Fortran 95)

support for oop in fortran 901
Support for OOP in Fortran (90)

Inheritance

-Single – only one member inherits

-Selective Single – specifies what to inherit

-Single with Local Renaming

-Multiple Selective

single inheritance
Single Inheritance

Module new_class_name

Use base_class_name

!make new attribute declarations

Contains

!declare new member definitions

End module new_class_name

selective single inheritance
Selective Single Inheritance

Module new_class_name

Use base_class_name; only: list_of_entities

!declare new attributes

Contains

!declare new member definitions

End module new_class_name

single inheritance with local renaming
Single Inheritance with Local Renaming

Module new_class_name

Use base_class name; local_name=> base_entity_name

!new attribute declarations

Contains

!new member declarations

End module new_class_name

multiple selective inheritance with renaming
Multiple Selective Inheritance with Renaming

Module new_class_name

Use base1_class_name

Use base2_class_name

Use base3_class_name; list of entities

Use base4_class_name, local_name => base entity name

!new member definitions

Contains

!new member definitions

End module new_class_name

examples
Examples

module student !declares student class

INTEGER idnumber

end module student

module class !declares student class

INTEGER classnumber

CHARACTER description

end module class

module student_information !new class

use student

use class, only: classnumber

end module student_information

examples1
Examples

module student

INTEGER idnumber

contains

subroutine grade

grade = average*4

end subroutine grade

end module student

module class

use student, classnumber =>idnumber

end module class

public and private
Public and Private

Source: IncyWincy.com

module Room_class

implicit none

public

type Room

private

integer :: roomNumber

logical, dimension(4) :: walls

end type Room

integer, parameter :: NORTH =1, SOUTH = 2..

contains

slide11
This

Source: IncyWincy.com

To make sure that a type is given the correct procedure, an object of that type needs to be passed. To do this, give the object the name “this” and make it first argument

Ex:

Subroutine new_Room (this, roomNumber,

N,S, E, W)

type(Room) :: this

...

support for oop in fortran 95
Support for OOP in Fortran(95)

Dynamic Binding – lets a single object refer to any member of an inheritance hierarchy and allows a procedure to resolve at run time whch object is being referred to

Necessary : id mechanism to keep track of the class of the object and method lookup to select the right procedure to execute

polymorphic type
Polymorphic Type

Source: rsimplifiedRT.cwk

type poly_stopwatch

private

type(stopwatch), pointer :: s

Type (parallel_stopwatch), pointer :: p

end type poly_stopwatch

slide14

Use poly_stopwatch_class

type(stopwatch) s

type(parallel_stopwatch) p

type(poly_stopwatch) sw

call new_stopwatch(s)

call new_parallel_stopwatch(p)

sw = poly(s)

call split(sw, 'bar')

call bar()

call split(sw, 'bar')

call report(sw, 6)

sw = poly(p)

call split(sw, 'foo')

call foo()

call split(sw, 'foo')

call report(sw, 6)

evaluation
Evaluation

~Fortran is object based, but not object oriented.

-Inheritance and run time polymorphism are not directly supported, rather they are emulated.

-Different, yet the similar.