FORTRAN ???? - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

FORTRAN ????

Description:

FORTRAN By Outline Fortran ... – PowerPoint PPT presentation

Number of Views:152
Avg rating:3.0/5.0
Slides: 51
Provided by: Cas145
Category:
Tags: fortran | fortran

less

Transcript and Presenter's Notes

Title: FORTRAN ????


1
FORTRAN ????
  • By ???

2
Outline
  • ??????????
  • Fortran ????
  • ????????
  • ?????
  • ????
  • ????
  • ??
  • ??

3
Fortran ??
  • ??-Formula Translator
  • IBM 1954 1957
  • ?????????????
  • ??
  • 1978 ? FORTRAN 77
  • 1992 ? FORTRAN 90
  • 1997 ? FORTRAN 95

4
FORTRAN COMPILER ??1
  • Visual FORTRAN
  • Microsoft ? Digital ? Compaq ? HP?
  • Microsoft Visual Studio
  • ???windows??????
  • ??Visual C??????

5
FORTRAN COMPILER ??2
  • ?????
  • ??Fortran 90 ? Fortran 77
  • ????
  • ???a.out
  • f77 filename.for
  • f90 filename.f90
  • ???????(sample)
  • f77 filename.for -o sample
  • f90 filename.for -o sample

6
FORTRAN COMPILER ??3
  • ?????? Fortran
  • ???? ccsun2635
  • ??2?
  • ??
  • telnet ccsun27.cc.nctu.edu.tw
  • ??u9031XXX
  • ???????????

7
FORTRAN ????1
  • ???
  • ????AZ (?????)
  • ??09
  • ???????????????????? etc

8
FORTRAN ????2
  • ???????
  • Fixed Format
  • Fortran 77 ????
  • ??????????
  • ???????????
  • Free Format
  • Fortran 90??????
  • ??????

9
FORTRAN ????3
  • Fixed Format
  • ?1???
  • ?????c,C?(??),???????
  • ?1-5???
  • ???????,????????,??????
  • ?6???
  • ???0?????,?????????????
  • ?7-72???
  • FORTRAN????????
  • ?73?????
  • ???,????????,???????????

10
FORTRAN ????4
  • Free Format
  • ???????????????
  • ??? ! ???????
  • ?????132???
  • ??????????
  • ?????????????,???????????????

11
FORTRAN ????5
  • ! Free Format
  • program main
  • write(,) hello ! ???hello???
  • write(,)
  • hello
  • wri
  • te(,) hello
  • end

12
??1
  • program main
  • write(,) hello
  • stop
  • end

13
??2
  • Write(,)
  • ??????????
  • ?????????
  • ????
  • WRITE(,) HELLO
  • WRITE(6,) HELLO
  • WRITE(UNIT6, FMT) HELLO

14
??3
  • ??write(,)
  • ????
  • ??????????2????
  • WRITE(,) MY NAME IS CASTER.
  • FORTRAN 90 ????/???
  • FORTRAN 77 ????

15
??4
  • PRINT
  • ??PRINT , ????
  • ???????

16
????
  • ????
  • END
  • END PROGRAM
  • END PROGRAM MAIN ! MAIN???????
  • Fortran 90 ? 1, 2, 3
  • Fortran 77 ? 1

17
????1
  • ??(integer)
  • ????integer a
  • ?????232 -232

18
????2
  • ???
  • ????real a ? real4 a
  • ????
  • 3.41038 -3.41038
  • ????67?
  • ????real8 a
  • 1.7910308
  • ????1516?

19
????3
  • ??
  • ??complex a
  • ??a(x,y) !x???,y???
  • program main
  • complex a,b
  • a(1.0,1.0)
  • b(3.0,4.3)
  • write(,) ab, ab
  • write(,) a-b, a-b
  • write(,) ab,ab
  • write(,) a/b, a/b
  • stop
  • end

20
????4
  • ????
  • ab (4.0,5.3)
  • a-b (-2.0,-3.3000001)
  • ab (-1.3000002,7.3)
  • a/b (0.2655511,-0.047289926)

21
????5
  • ?????
  • Character a !????
  • Character10 a !?????10???
  • ????
  • CHARACTER10
  • CHARACTER(LEN10)
  • CHARACTER(10)
  • ?????
  • A????

22
????
  • ???????????
  • INTEGER A
  • READ (,) A !??????,???A?
  • READ (5,) A !??
  • READ(UNIT5, FMT) A !??

23
?????1
  • ??I
  • WRITE(,(I5)) 100 !?5?????????????
  • OUTPUT _ _ 1 0 0
  • WRITE(,(I3)) 100000
  • OUTPUT
  • WRITE(,(I5.4)) 3
  • !????????,????4?,???0
  • OUTPUT _ 0 0 0 3

24
?????2
  • ??F
  • WRITE(,(F9.3)) 123.45
  • !??9?????,??????3???
  • OUTPUT _ _ 1 2 3 . 4 5 0
  • ??E
  • WRITE(,(E15.7)) 123.45
  • !????????,??15?????,?????7?
  • OUTPUT _ _ 0 . 1 2 3 4 5 0 0 E 0 3

25
?????3
  • ??A
  • WRITE (,(A10)) HELLO
  • !?10?????????
  • OUTPUT _ _ _ _ _ H E L L O
  • WRITE (,(A3)) HELLO
  • OUTPUT H E L

26
?????4
  • ??B
  • WRITE (,(B6.5)) 3
  • !?3???????,?6????,????5?
  • OUTPUT _ 0 0 0 1 1

27
?????5
  • ??X
  • WRITE (,(3X)) 20
  • !?????3?????
  • OUTPUT _ _ _ 2 0

28
????????1
  • ????
  • FORTRAN 77 ? ??6
  • FORTRAN 90 ? ??31
  • ????????
  • ??????I, J, K, L, M, N ???
  • ??????

29
????????2
  • PROGRAM MAIN
  • I1122
  • WRITE(,) 1122, J
  • STOP
  • END
  • ??
  • 11220

30
????????3
  • ?????????
  • IMPLICIT NONE
  • ??????????
  • ??PROGRAM??????

31
?????
  • ???
  • REAL PI
  • PARAMETER(PI3.14159)
  • ???
  • REAL, PARAMETER PI3.14159

32
????
33
FLOW CONTROL1
  • IF THEN ELSE??
  • IF(?????) THEN
  • ????1
  • ELSE
  • ????2
  • END IF

34
FLOW CONTROL2
  • PROGRAM MAIN
  • IMPLICIT NONE
  • REAL HIEGHT
  • REAL WEIGHT
  •  
  • READ(,) HEIGHT
  • READ(,) WEIGHT
  • IF (WEIGHT gt HEIGHT-100) THEN
  • WRITE(,) TOO FAT!
  • ELSE
  • WRITE(,) UNDER CONTROL
  • END IF
  • STOP
  • END

35
FLOW CONTROL3
  • ?????
  • ??
  • / ???
  • gt ??
  • gt ????
  • lt ??
  • lt ????
  • .AND. ?????????,???????
  • .OR. ????????????,???????
  • .NOT. ??????????,????????
  • .EQV. ??????????????,???????
  • .NEQV. ??????????????,???????

36
FLOW CONTROL4
  • FORTRAN 77??????
  • .EQ. ??
  • .NE. ???
  • .GT. ??
  • .GE. ????
  • .LT. ??
  • .LE. ????

37
FLOW CONTROL5
  • DO????
  • DO ???, ???, ???
  • ?????
  • END DO
  • ?
  • DO I10, 5, -1
  • WRITE(,) I
  • END DO

38
FLOW CONTROL6
  • ??
  • 10
  • 9
  • 8
  • 7
  • 6
  • 5

39
FLOW CONTROL7
  • Dowhile??
  • DO WHILE (????)
  • ???
  • END DO

40
??1
  • FORTRAN 90 ?????
  • integer a(10) !??a?????10???
  • integer , dimension(10) a
  • ! ??,?????
  • FORTRAN 77 ?????
  • integer a
  • dimension a(10)
  • ??!!index??1????!!

41
??2
  • ????
  • a(1)18
  • INTEGER A(3)
  • DATA A /36, 24, 36/
  • ?FORTRAN 90?,?????DATA????
  • INTEGER A(3) (/36, 26, 36/)
  • ? ????????????,?????????

42
??1
  • ???(SUBROUTINE)???(???)
  • PROGRAM MAIN
  • ????
  • END
  • SUBROUTINE SUB1()
  • ???
  • END SUBROUTINE
  • SUBROUTINE SUB2()
  • ???
  • END SUBROUTINE

43
??2
  • ??
  • CALL BY REFERENCE
  • ????
  • ????????????RETURN
  • ?????????CALL

44
??3
  • PROGRAM MAIN
  • IMPLICIT NONE
  • INTEGER A1
  • WRITE (,) A?????, A
  • CALL ADD(A)
  • WRITE(,) A?????, A
  • STOP
  • END
  •  
  • SUBROUTINE ADD(NUM)
  • IMPLICIT NONE
  • INTEGER NUM
  • NUM NUM 1
  • RETURN
  • END SUBROUTINE

45
??4
  • ???????
  • A????? 1
  • A????? 2
  • ?????subroutine,??A?????!

46
??5
  • ????(function)
  • ??SUBROUTINE
  • ???
  • ???????
  • ????
  • ????
  • Fortran 90
  • REAL , EXTERNAL ADD
  • Fortran 77
  • REAL ADD
  • EXTERNAL ADD

47
??6
  • PROGRAM MAIN
  • IMPLICIT NONE
  • REAL, EXTERNAL TRIPPLE
  • real A1.38
  • WRITE (,) "A?????", A
  • WRITE (,) "????",TRIPPLE(A)
  • WRITE(,) "A?????", A
  • STOP
  • END 
  • REAL FUNCTION TRIPPLE(NUM)
  • IMPLICIT NONE
  • REAL NUM
  • TRIPPLE NUM 3
  • RETURN
  • END

48
????
  • A????? 1.38
  • ???? 4.14
  • A????? 1.38

49
??
  • ???????
  • ????(???),?????(???)
  • ????subroutine, function??????
  • ??????????????
  • Pi3.1416

50
Any Question
  • Please email caster_at_cis.nctu.edu.tw
Write a Comment
User Comments (0)
About PowerShow.com