Functions & Subroutines HTML version DFMain.chm. Types of subprograms Internal External Module Pure Elemental Recursive Optional arguments Generic Defined.

Slides:



Advertisements
Similar presentations
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Advertisements

Chapter 8 Advanced SQL Pearson Education © Chapter 8 - Objectives u How to use the SQL programming language u How to use SQL cursors u How to create.
Spring Semester 2013 Lecture 5
Template. 2 Using templates, it is possible to create generic functions and classes. In a generic function or class, the type of data upon which the function.
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Programming Languages and Paradigms
Names and Bindings.
Subprogram Control - Data sharing Mechanisms to exchange data Arguments - data objects sent to a subprogram to be processed. Obtained through  parameters.
The new features of Fortran 2003 David Muxworthy BSI Fortran Convenor.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Fortran: Array Features Session Five ICoCSIS. Outline 1.Zero-sized Array 2.Assumed-shaped Array 3.Automatic Objects 4.Allocation of Data 5.Elemental Operations.
Chapter 9 Subprograms Sections 1-5 and 9. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Introduction Two fundamental abstraction facilities.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Application of Fortran 90 to ocean model codes Mark Hadfield National Institute of Water and Atmospheric Research New Zealand.
VBA Modules, Functions, Variables, and Constants
Chapter 6 Programming with Functions. FUNCTIONS Intrinsic Functions (or called library functions) Function Subprograms: programmer-defined functions.
Program Units Main Program Syntax Program Example Introduction to Procedures Subroutines Functions Argument Association Local Objects Argument Intent Scoping.
Chapter 10 Additional Features of Arrays Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Introduction to Fortran Fortran Evolution Drawbacks of FORTRAN 77 Fortran 90 New features Advantages of Additions.
Array HTML version. Declaration in Main Program 2 ways to declare a real array A of rank N : DIMENSION A( start_index1 : end_index1, …, start_indexN :
ISBN Chapter 9 Subprograms. Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Introduction Two fundamental abstraction facilities.
Topics of Lecture Structural Model Procedures Functions Overloading.
Fortran 9x HTML version. New F90 features Free source form Modules User-defined data types and operators Generic user-defined procedures Interface blocks.
PSU CS 106 Computing Fundamentals II VB Subprograms & Functions HM 4/29/2008.
Using Templates Object-Oriented Programming Using C++ Second Edition 11.
Chapter 10 Modules and programming with subroutines.
Chapter 9 Modules and Programming with Functions.
Chapter 9 Introduction to Procedures Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul -
Chapter 12 Pointers and linked structures. 2 Introduction  The data structures that expand or contract as required during the program execution is called.
ISBN Chapter 9 Subprograms and Functions –Design Issues –Local Referencing Environments –Parameter-Passing Methods –Parameters that are Subprogram.
Functions. Program complexity the more complicated our programs get, the more difficult they are to develop and debug. It is easier to write short algorithms.
Fortran- Subprograms Chapters 6, 7 in your Fortran book.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Fortran: Specification Statements Session Six ICoCSIS.
Block-Structured Procedural Languages Lecture 11: Dolores Zage.
Introduction to FORTRAN
1 Week 12 Arrays, vectors, matrices and cubes. Introduction to Scientific & Engineering Computing 2 Array subscript expressions n Each subscript in an.
Fortran: Program Units and Procedures Session Four ICoCSIS.
1 VBA – podstawowe reguły języka Opracowanie Janusz Górczyński wg Microsoft Help.
Chapter Nine: Subprograms Lesson 09. What are they  Modularized code  Might return a value  Functions  Or not  Procedures  Subroutines  In object.
Subprograms Support process abstraction and modularity –characteristics of subprograms are that they have a single entry point the calling entity is suspended.
Week 8. Today’s program n New stuff: –Recursion in F –Procedures as arguments –User-defined data types n Quiz #3.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Week 8 Improving on building blocks Recursive procedures.
Some Advanced Features of Procedures. Recursion Recursive Calls –A procedure can call itself (Self Recursion) –A can call B, B calls C, etc, Z calls A.
Functions. Type of Subprograms Fortran 90/95 allows for two types of subprograms: –Functions, and –Subroutines. In general, there are two forms of subprograms:
Introduction A variable can be characterized by a collection of properties, or attributes, the most important of which is type, a fundamental concept in.
CHAPTER 9 SUBPROGRAMS Subprograms are useful in the following cases: long complicated program  Subprograms make it readable and simple by dividing it.
Module and Data Sharing. Programming in the Large Software, in general, is large having multiple units Multiple units designed and developed independently.
Week 3 Let's review! Fundamental data types List-directed input/output.
Programming Languages and Paradigms Imperative Programming.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Procedures and Modular Programming Part # 2. Interface Block ► Functions do not have to be internal to main program ► They can be stand-alone ► In this.
1 Subprograms In Text: Chapter 8. 2 Chapter 8: Subprograms Outline Definitions Referencing environments Parameter passing modes and mechanisms Independent.
Arrays Introduction In scientific and engineering computing, it is very common to need to manipulate ordered sets of values, such as vectors and matrices.
Parameterized modules, BITS, and other features that may or may not be included in the revision of Fortran 2003 David Muxworthy BSI Fortran Convenor Prepared.
1 Using Templates COSC 1567 C++ Programming Lecture 10.
CCSA 221 Programming in C CHAPTER 8 – PART 1 WORKING WITH FUNCTIONS 1.
Procedure Definitions and Semantics Procedures support control abstraction in programming languages. In most programming languages, a procedure is defined.
Introduction to Fortran95 Programming Part II By Deniz Savas, CiCS, 2007
Dynamic Data Structures. Point to Derived Data Values So far, we saw examples where pointers pointed to targets that are simple or array variables Targets.
Functions and Subroutines
Procedures and Modular Programming
2. Understanding VB Variables
Array processing and Matrix manipulation
Subprograms In Text: Chapter 9.
mdul-cntns-sub-cmmnts2.f90
Chapter 9 Subprograms Fundamentals of Subprograms
Array processing and Matrix manipulation
Presentation transcript:

Functions & Subroutines HTML version DFMain.chm

Types of subprograms Internal External Module Pure Elemental Recursive Optional arguments Generic Defined operators Defined assignment

INTENT Type Declaration Statement: type, [att-ls,] INTENT (intent-spec) [, att-ls] :: d-arg [, d-arg]... Statement: INTENT (intent-spec) [::] d-arg [, d-arg]... intent-spec  IN, OUT, or INOUT Intent.f95Intent.exe

CONTAINS Separates the body of a main program, module, or external subprogram from any internal or module procedures it may contain. It is not executable. Thus, procedures following the CONTAINS statement are local ( internal ) procedures of the host program.

Procedure Interfaces Kind of Procedure Interface External procedure Implicit 1 Module Procedure Explicit Internal Procedure Explicit Intrinsic Procedure Explicit Dummy Procedure Implicit 1 Statement function Implicit 1 Unless an interface block is supplied for the procedure.

Explicit Interfaces are required for routines with optional dummy arguments. dummy arguments that are assumed- shape arrays, pointers, or targets. result that is array-valued or a pointer (functions only). result whose length is neither assumed nor a constant (character functions only)

Explicit Interfaces are required for calling routines with argument keywords. generic names. Defined assignments (subroutine only). Defined operators ( functions only ). Pure functions.

Recursive Procedures If a function is directly recursive and array valued, the keywords RECURSIVE and RESULT must both be specified in the FUNCTION statement. Recursive.f95Recursive.exe Fibonacci.f95Fibonacci.exe

Optional Arguments Optional arguments are specified by the OPTIONAL attribute. Use the intrinsic function PRESENT to determine whether an actual argument is present. Explicit procedure interfaces must be used. Optional.f95Optional.exe

Generic routines GenericS.f95GenericS.exe

Defined Operators GenericO.f95GenericO.exe Generic1.f95Generic1.exe

Defined Assignments Pure Procedures Elemental Procedures