8Procedures - Procedure Top-down design. Procedures:...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Procedure Top-down design. Procedures: Internal External External Procedure Subroutines Functions
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Why?? PROGRAM find_sin_cos IMPLICIT NONE REAL :: x, sinx WRITE(*,*) ‘enter x’ READ(*,*) x sinx = x – x**3/(3*2*1)+x**5(5*4*3*2*1)-x**7(7*6*5*4*3*2*1) cosx = 1 – x**2/(2*1)+x**4(4*3*2*1)-x**6(6*5*4*3*2*1) WRITE(*,*) ‘Approximate sin value is’, sinx WRITE(*,*) ‘Approximate cos value is’, cosx END PROGRAM find_sin_cos
Background image of page 2
Why?? Improved Readability, Better Organization Independent testing of each substasks Reusable code Reduced side effects
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Subroutines Fortran procedure invoked by CALL statement Receives input and returns output through an argument list SUBROUTINE subroutine_name (argument_list) …declaration statement …execution statement RETURN END SUBROUTINE [name]
Background image of page 4
Subroutines Argument list: List of variables passed from the calling program. Dummy argument: no memory in subroutine. Data declaration: Local variables: limited to a particular subroutine
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example 2 PROGRAM prime1 IMPLICIT NONE INTEGER:: I, N
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2009 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 14

8Procedures - Procedure Top-down design. Procedures:...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online