fortran 90 - center 4 fortran formula translation 1950년대후반ibm에서개발...

Download Fortran 90 -   Center 4 Fortran FORmula TRANslation 1950년대후반IBM에서개발 9가장오래된고급언어 국제표준채택(1980, ISO) FORTRAN 77 Fortran 90, Fortran 95, Fortran

Post on 08-May-2018

258 views

Category:

Documents

20 download

Embed Size (px)

TRANSCRIPT

  • Fortran 90Fortran 90

    KISTI KISTI

  • Supercomputing Center Supercomputing Center 22

    1.1. Fortran 90 Fortran 90

    2.2. Numerical RobustnessNumerical Robustness

    3.3. Data ParallelismData Parallelism

    4.4.

  • I I

    Fortran 90 Fortran 90

    Fortran 90Fortran 90

    Fortran 77, C/C++Fortran 77, C/C++

    ..

  • Supercomputing Center Supercomputing Center 44

    Fortran Fortran

    FORFORmula mula TRANTRANslationslation19501950 IBMIBM

    (1980, ISO) (1980, ISO) FORTRAN 77FORTRAN 77

    Fortran 90, Fortran 95, Fortran 2003Fortran 90, Fortran 95, Fortran 2003

  • Supercomputing Center Supercomputing Center 55

    Fortran 77Fortran 77 (1/2)(1/2)

    7272 55 66 11 , ,

    (6(6) )

  • Supercomputing Center Supercomputing Center 66

    Fortran 77Fortran 77 (2/2)(2/2)

    (()) COMMON COMMON , EQUIVQALENCE , EQUIVQALENCE

  • Supercomputing Center Supercomputing Center 77

    Type DeclarationType Declaration attributingattributing

    New control structureNew control structure

    Numeric ProcessingNumeric Processing

    Array ProcessingArray Processing

    PointersPointers

    I/OI/O

  • Supercomputing Center Supercomputing Center 88

    Fortran 90Fortran 90

    (http://www.comphys.uni(http://www.comphys.uni--duisburg.de/Fortran90/pl/pl.html)duisburg.de/Fortran90/pl/pl.html)

  • Supercomputing Center Supercomputing Center 99

    (1/12)(1/12)

    132132

    IBM XL FortranIBM XL Fortran 67006700 ;; !! && 3131 (( ))

    IBM XL FortranIBM XL Fortran 250250

    .LT., .LE., .EQ., .NE., .GE., .GT. .LT., .LE., .EQ., .NE., .GE., .GT.

  • Supercomputing Center Supercomputing Center 1010

    (2/12)(2/12)

    PRINT*, "This line is continued &on the next line"; END ! of program

  • Supercomputing Center Supercomputing Center 1111

    (3/12)(3/12)

    Fortran 90Fortran 90 -- : a: a--z, Az, A--Z, 0Z, 0--9, _ (underscore)9, _ (underscore)

    Symbol Description Symbol Description

    SpaceSpace == EqualEqual

    ++ PlusPlus -- MinusMinus

    ** AsteriskAsterisk // SlashSlash

    (( Left parenthesisLeft parenthesis )) Right parenthesisRight parenthesis

    ,, CommaComma .. PeriodPeriod

    Single quoteSingle quote Double quoteDouble quote

    :: ColonColon ;; Semi colonSemi colon

    !! ShriekShriek && Ampersand Ampersand

    %% PercentPercent > Greater thanGreater than $$ Dollar Dollar

    ?? Question markQuestion mark

  • Supercomputing Center Supercomputing Center 1212

    (4/12)(4/12)

    Type Declaration and AttributingType Declaration and Attributing

    Fortran77 Fortran90FUNCTION encode(pixels)

    INTEGER nPARAMETER(n=1000) INTEGER pixels(n, n), encode(n, n) REAL x(n), y(n) INTEGER*8 callcall = 0 ...END

    FUNCTION encode(pixels)

    IMPLICIT NONEINTEGER, PARAMETER :: n=1000 INTEGER, DIMENSION(n, n) :: pixels, encode REAL, DIMENSION(n) :: x, y INTEGER(8) :: call=0 ...END

  • Supercomputing Center Supercomputing Center 1313

    (5/12)(5/12)

    New Control Structure(1)New Control Structure(1)SELECTSELECT--CASECASE

    IF IF

    SELECT CASE (expression)CASE(value-list)CASE(value-list)

    END SELECT

  • Supercomputing Center Supercomputing Center 1414

    (6/12)(6/12)

    New Control Structure(2)New Control Structure(2)

    PROGRAM select

    INTEGER :: n, kPRINT *, 'Enter the value n = 'READ *, n

    SELECT CASE(n)CASE (:0)

    k = -nCASE (10:)

    k = n+10CASE DEFAULT

    k = nEND SELECT

    PRINT *, k

    END

  • Supercomputing Center Supercomputing Center 1515

    (7/12)(7/12)

    New Control Structure(3)New Control Structure(3) DO DO

    DO DO END DOEND DODO WHILE DO WHILE END DOEND DO

    DOIF (logical-expr) EXIT

    END DO

    DO WHILE (logical-expr)

    END DO

  • Supercomputing Center Supercomputing Center 1616

    (8/12)(8/12)

    Numeric ProcessingNumeric Processing

    kind kind

    Array ProcessingArray ProcessingPointersPointers

    REAL, TARGET :: B(100,100) ! B target .REAL, POINTER :: U(:,:),V(:),W(:,:) ! 3

    ...U => B(I:I+2,J:J+2) ! U B 3x3 pointALLOCATE ( W(M,N) ) ! MxN W V => B(:,J) ! V B J point V => W(I-1,1:N:2) ! V W I-1 point

  • Supercomputing Center Supercomputing Center 1717

    (9/12)(9/12)

    + +

    TYPE RATIONAL ! This defines the type RATIONAL.INTEGER :: NUMERATORINTEGER :: DENOMINATOR

    END TYPE RATIONAL...TYPE (RATIONAL) :: X, Y(100,100) ! X and Y are variables of type RATIONAL.X%NUMERATOR = 2; X%DENOMINATOR = 3

    INTERFACE OPERATOR(+)FUNCTION RAT_ADD(X, Y)

    TYPE (RATIONAL) :: RAT_ADDTYPE (RATIONAL), INTENT(IN) :: X, Y

    END FUNCTION RAT_ADDEND INTERFACE

  • Supercomputing Center Supercomputing Center 1818

    (10/12)(10/12)

    Recursive Recursive

    OPTIONAL, INTENE OPTIONAL, INTENE

    TYPE LISTREAL :: DATATYPE (LIST), POINTER :: PREVIOUS, NEXT !Recursive Components

    END TYPE LIST

  • Supercomputing Center Supercomputing Center 1919

    (11/12)(11/12)

    (1)(1)

    Generic Generic

  • Supercomputing Center Supercomputing Center 2020

    (12/12)(12/12)

    (2)(2)MODULE RATIONAL_ARITHMETIC

    TYPE RATIONALINTEGER :: NUMERATORINTEGER :: DENOMINATOR

    END TYPE RATIONAL

    INTERFACE OPERATOR (+)FUNCTION RAT_ADD(X,Y)

    TYPE (RATIONAL) :: RAT_ADDTYPE (RATIONAL), INTENT(IN) :: X, Y

    END FUNCTION RAT_ADDEND INTERFACE

    ... ! and other stuff for a complete rational arithmetic facility

    END MODULE RATIONAL_ARITHMETIC

  • Supercomputing Center Supercomputing Center 2121

    Fortran 90Fortran 90 Data abstractionData abstraction

    Data hidingData hiding

    EncapsulationEncapsulation

    Inheritance and ExtensibilityInheritance and Extensibility

    PolymorphismPolymorphism

    ReusabilityReusability

  • Supercomputing Center Supercomputing Center 2222

    Fortran 90Fortran 90 (1/4)(1/4)

    Data AbstractionData Abstraction

    ) )

    Fortran 90Fortran 90 , ,

    TYPE T1INTEGER(KIND=1) :: heightREAL(KIND=1) :: weight

    END TYPE T1TYPE T2

    INTEGER(KIND=2) :: heightREAL(KIND=2) :: weight

    END TYPE T2

    TYPE T1(n)INTEGER(KIND=n) :: heightREAL(KIND=n) :: weight

    END TYPE T1

  • Supercomputing Center Supercomputing Center 2323

    Fortran 90Fortran 90 (2/4)(2/4)

    Data HidingData HidingPUBLIC, PRIVATE PUBLIC, PRIVATE

    PRIVATE ! set default visibilityINTEGER :: pos, store, stack_size ! hiddenINTEGER, PUBLIC :: pop, push ! not hidden

  • Supercomputing Center Supercomputing Center 2424

    Fortran 90Fortran 90 (3/4)(3/4)

    EncapsulationEncapsulation

    data hiding, module/module procedure, usedata hiding, module/module procedure, use modulemodule renamerename

    MODULE globalsREAL, SAVE : a, b, cINTEGER, SAVE :: i, j, k

    END MODULE globals

    USE globals ! allows all variables in the module to be accessedUSE globals, ONLY: a, c ! allows only variables a and c to be accessedUSE globals, r =>a, s => b ! allows a and b to be accessed with local variables r and s

  • Supercomputing Center Supercomputing Center 2525

    Fortran 90Fortran 90 (4/4)(4/4)

    Inheritance and ExtensibilityInheritance and Extensibility

    supersuper--type type subsub--type type

    PolymorphismPolymorphismGeneric Generic polymorphism polymorphism

    ReusabilityReusabilitymodulemodule unitunit

  • Supercomputing Center Supercomputing Center 2626

    Fortran 77, C/C++Fortran 77, C/C++ Fortran 90Fortran 90

  • Supercomputing Center Supercomputing Center 2727

    ((http://www.comphys.unihttp://www.comphys.uni--duisburgduisburg. de / . de / Fortran90/pl/pl.html) Fortran90/pl/pl.html)

    Functionality Fortran 77 C C++Fortran

    90Numerical Robustness 2 4 3 1Data Parallelism 3 3 3 1Data Abstraction 4 3 2 1Object Oriented Programming 4 3 1 2Functional Programming 4 3 2 1Average 3.4 3.2 2.2 1.2

  • Supercomputing Center Supercomputing Center 2828

    Fortran 77, C/C++Fortran 77, C/C++ (1/5)(1/5)

    Numerical RobustnessNumerical Robustness11: Fortran90 : Fortran90

    numeric polymorphism, kind type, numeric polymorphism, kind type, , , numeric environmental inquiry numeric environmental inquiry

    22: Fortran 77: Fortran 77complex type complex type

    33: C++: C++CC polymorphism polymorphism

    44: C: C

  • Supercomputing Center Supercomputing Center 2929

    Fortran 77, C/C++Fortran 77, C/C++ (2/5)(2/5)

    Data parallelismData parallelism11: Fortran90 : Fortran90

    Fortran 90Fortran 90

    Fortran 77, C, C++Fortran 77, C, C++

  • Supercomputing Center Super