Title: Chapter 7 Subroutine and Function
1Chapter 7 Subroutine and Function
27-1 subroution(???)
37-1 subroution(???)
47-1 subroution(???)
- ?????????
- ????????????
- ?????,??????
- ???????????,
- ??????????,?
- ????????????
57-1 subroution(???)
67-1 subroution(???)
- ?????????
- real, intent(in) A
77-1 subroution(???)
87-1 subroution(???)
97-1 subroution(???)
107-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??????,
- ?????????????
117-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)
127-1 subroution(???)
137-1 subroution(???)
147-1 subroution(???)
157-2 save
167-2 save
177-2 save
187-3 ??module????
197-3 ??module????
207-3 ??module????
217-4 Fortran Functions
- ??????
- ???Fortran??,??????
Ex. sin(x) ? log(x)
227-4 Fortran Functions
237-4 Fortran Functions
- ?????
- function fun_1 (argument_list)
- integer fun_1
-
- integer function fun_1(argument_list)
-
247-4 Fortran Functions
257-4 Fortran Functions
267-5 ?????????????
277-6 Interface(??)
- ????
- interface
-
-
- ...
- end interface
287-6 Interface(??)
297-6 Interface(??)
307-6 Interface(??)
317-6 Interface(??)
327-6 Interface(??)
337-6 Interface(??)
- Fortran 90 ???????????????
- interface,??????????,??
- interface????
- ????????????
- ??????????????
- ???????
- ???????????
- ?????????
- ?????????
347-7 ?????????
- ????
- integer, intent(in), optional b
- present(b)
357-7 ?????????
367-7 ?????????
377-8 Recursive(??)procedures
- ????
- recursive subroutine fact(n, ans)
-
- call fact(n-1, temp)
387-8 Recursive(??)procedures
397-8 Recursive(??)procedures
407-8 Recursive(??)procedures
417-8 Recursive(??)procedures
427-8 Recursive(??)procedures
437-8 Recursive(??)procedures
447-8 Recursive(??)procedures
457-9 Contains statement
- ????????????????????(?
- ???)?????????????
- program scoping_test
-
- call sub2
-
- contains
- subroutine sub2
-
- end subroutine sub2
- end program scoping_test
467-9 Contains statement
477-9 Contains statement
487-9 Contains statement
497-9 Contains statement
507-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
517-9 Contains statement
527-9 Contains statement
537-9 Contains statement
547-9 Contains statement
557-10 Intrinsic External
- ????????,intrinsic?external???
- ?,???????????????????
- ??????,external?intrinsic?????
- integer, external Func1, Func2
- real, intrinsic sin, cos
567-10 Intrinsic External