This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Chapter 5 Object Oriented Programming 5.1 Derived Types They are a way to group connected variables. Where you declare variables you make up your own data type Derived Type ex1 TYPE COORDINATES REAL ( KIND =dp) : : x , y , z END TYPE COORDINATES TYPE (COORDINATES) : : point1 , point2 point1%x=1.0 point1%y=2.0 point1%z=3.0 write ( , ) point1 point2=coordinates ( 4. 0 , 5. 0 , 6. 0) write ( , ) point2 5.2 Modules In general Modules have the form General Module Structure MODULE module name s t a t i c data d e f i n i t i o n s CONTAINS functions , subroutines and i n t e r f a c e s ENDMODULE module name double example double.f90 MODULE double IMPLICIT NONE INTEGER , PARAMETER : : DP = SELECTED REAL KIND(P=15) ENDMODULE double Now in your main program you start 13 MAT 5939-03 Pierre Garreau main.f90 Program main use double IMPLICIT NONE . . . 5.3 Interfaces So now we know the major two features of modules. We can organize data and functions. Now lets learn about interfaces which will make this module easier to use. So to do this we first need two functions. Well make twointerfaces which will make this module easier to use....
View Full Document
This note was uploaded on 01/15/2012 for the course MAT 5939 taught by Professor Garreau during the Fall '11 term at FSU.
- Fall '11