Chapter 7 Subroutine and Function - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 7 Subroutine and Function

Description:

Chapter 7 Subroutine and Function 7-1 subroution( ) 7-1 subroution( ) 7-1 subroution( ) ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 57
Provided by: Sibevi
Category:

less

Transcript and Presenter's Notes

Title: Chapter 7 Subroutine and Function


1
Chapter 7 Subroutine and Function
2
7-1 subroution(???)
3
7-1 subroution(???)
4
7-1 subroution(???)
  • ?????????
  • ????????????
  • ?????,??????
  • ???????????,
  • ??????????,?
  • ????????????

5
7-1 subroution(???)
6
7-1 subroution(???)
  • ?????????
  • real, intent(in) A

7
7-1 subroution(???)
  • ?????????

8
7-1 subroution(???)
  • ?????????

9
7-1 subroution(???)
  • ?????????

10
7-1 subroution(???)
????? ??? ???
001 a x
002 b(1) y(1)
003 b(2) y(2)
004 b(3) y(3)
005 b(4) y(4)
006 next i
  • ????? pass-by-reference
  • Fortran??????,
  • ?????????????

11
7-1 subroution(???)
  • ?????
  • ?????????????????
  • real a, b(4) real, intent(out)
    x
  • real,
    dimension(4), intent(in) y
  • integer next integer I
  • call sub1(a, b, next)
  • subroutine sub1(x, y, i)

12
7-1 subroution(???)
  • ?????

13
7-1 subroution(???)
  • ???????
  • ???????????????

14
7-1 subroution(???)
  • ???????
  • ???????????????

15
7-2 save
  • ????
  • integer, save n

16
7-2 save
17
7-2 save
18
7-3 ??module????
  • ????????

19
7-3 ??module????
  • ????

20
7-3 ??module????
  • ????

21
7-4 Fortran Functions
  • ??????
  • ???Fortran??,??????

Ex. sin(x) ? log(x)
22
7-4 Fortran Functions
  • ????

23
7-4 Fortran Functions
  • ?????
  • function fun_1 (argument_list)
  • integer fun_1
  • integer function fun_1(argument_list)

24
7-4 Fortran Functions
25
7-4 Fortran Functions
26
7-5 ?????????????
27
7-6 Interface(??)
  • ????
  • interface
  • ...
  • end interface

28
7-6 Interface(??)
29
7-6 Interface(??)
30
7-6 Interface(??)
31
7-6 Interface(??)
32
7-6 Interface(??)
33
7-6 Interface(??)
  • Fortran 90 ???????????????
  • interface,??????????,??
  • interface????
  • ????????????
  • ??????????????
  • ???????
  • ???????????
  • ?????????
  • ?????????

34
7-7 ?????????
  • ????
  • integer, intent(in), optional b
  • present(b)

35
7-7 ?????????
36
7-7 ?????????
37
7-8 Recursive(??)procedures
  • ????
  • recursive subroutine fact(n, ans)
  • call fact(n-1, temp)

38
7-8 Recursive(??)procedures
  • ????
  • Ex.?n??

39
7-8 Recursive(??)procedures
40
7-8 Recursive(??)procedures
41
7-8 Recursive(??)procedures
42
7-8 Recursive(??)procedures
43
7-8 Recursive(??)procedures
44
7-8 Recursive(??)procedures
45
7-9 Contains statement
  • ????????????????????(?
  • ???)?????????????
  • program scoping_test
  • call sub2
  • contains
  • subroutine sub2
  • end subroutine sub2
  • end program scoping_test

46
7-9 Contains statement
47
7-9 Contains statement
48
7-9 Contains statement
49
7-9 Contains statement
50
7-9 Contains statement
lt Ex. ????gt
Beginning 1 2 100.0 200.0 In
sub1 before sub2 1 2 In sub1
in sub3 1000 2000 In sub1 after sub2
1 2000 After array def in sub2 1
2000 TEST
? 2000 3000
? 5000 After sub1 1
2000 100.0 200.0 In sub2
1000.0 2000.0 After sub2 1
2000 100.0 2000.0
51
7-9 Contains statement
  • ?????????????????????

52
7-9 Contains statement
53
7-9 Contains statement
54
7-9 Contains statement
55
7-10 Intrinsic External
  • ????????,intrinsic?external???
  • ?,???????????????????
  • ??????,external?intrinsic?????
  • integer, external Func1, Func2
  • real, intrinsic sin, cos

56
7-10 Intrinsic External
Write a Comment
User Comments (0)
About PowerShow.com