Introduction to Fortran Programming. -External subprograms-

Size: px
Start display at page:

Download "Introduction to Fortran Programming. -External subprograms-"

Transcription

1 Introduction to Fortran Programming -External subprograms-

2 Subprograms Subprograms are used to split a program into separate smaller units. Internal subprograms are dependent parts of a program. Fortran 90 has two types of subprograms: functions and subroutines. Once each piece is working correctly, we can put the pieces together to build the program. 1

3 Program unit It is a physically complete sequence of program lines with end statement. Main program: The main program unit containing the first statement of the actual program. External subprogram: User-defined subprogram which is an independent program unit. Module (since Fortran90): A program unit which contains only declarations and external subprograms. 2

4 Program unit Main program (program-name) Internal functions Internal subroutines External Subprograms External functions External subroutines Today s topic!! But not recommended. Module 3

5 External Subprograms Internal subprograms are described in the main program. Internal subprograms are not an independent of a main program. Variables of the main program and internal subprograms are shared. External subprograms are defined outside the main program. External subprograms are independent of a main program. Variables of the main program and external subprograms are not shared. 4

6 External functions program program_name [Specification part] [Execution part] end program program_name End of main program function function_name (arg1,arg2, ) [Specification part] [Execution part] end function function_name External functions are defined outside the main program. Be sure to write implicit none in specification part. 5

7 External subroutines program program_name [Specification part] [Execution part] end program program_name End of main program Subroutine subroutine_name (arg1, arg2, ) [Specification part] [Execution part] end subroutine subroutine_name Same as external functions. 6

8 External Statement The general form of the statement is data_type, external ename1, ename2,, where ename is the name of some external function. Required when using external functions. Not recommended (interface statement is preferable). program examp real(8), external :: expfunc end program examp function expfunc( ) result(res) real(8) :: res end function It is not necessary for external subroutine. Declaration of external function expfunc. real(8) is the data type of return value of expfunc. Defined outside the main program. The data type of return value of expfunc. This matches real (8) in main program. 7

9 Example 1 Let r be a double-precision real type variable and assign a value appropriately. Create external functions and external subroutines to calculate the volume of the sphere with radius r. 8

10 Example 1 External function program examp1 real(8) :: r real(8), external :: volfunc r = 1d0 V = volfunc(r) write(*,*) V end program examp1 function volfunc(r) result(v) real(8), intent(in) :: r real(8) :: pi = acos(-1d0) V = 4d0/3d0*pi*r**3 end function volfunc Declaration of external function volfunc. real(8) is the data type of return value of volfunc. Use external function volfunc. External function is declared outside the main program. 9

11 Example 1 External subroutine program examp1 real(8) :: r For external subroutines, r = 1d0 call volsub(r,v) write(*,*) V end program examp1 subroutine volsub(r,v) real(8), intent(in) :: r real(8) :: pi = acos(-1d0) real(8), intent(out) :: V V = 4d0/3d0*pi*r**3 end subroutine volsub external statements are not required. External subroutine is declared outside the main program. 10

12 Comparison of internal and external functions External function program examp1 real(8) :: r real(8), external :: volfunc r = 1d0 V = volfunc(r) write(*,*) V end program examp1 function volfunc(r) result(v) real(8), intent(in) :: r real(8) :: pi = acos(-1d0) V = 4d0/3d0*pi*r**3 end function volfunc Internal function program examp1 real(8) :: r r = 1d0 V = volfunc(r) write(*,*) V contains function volfunc(r) result(v) real(8), intent(in) :: r real(8) :: pi = acos(-1d0) V = 4d0/3d0*pi*r**3 end function volfunc end program examp1 11

13 Comparison of internal and external functions External function Internal function program examp1 program examp1 What implicit happens none if you declare pi which was already implicit declared none in the main program? Deleting real(8) the pi :: declared r in the main program. real(8) :: r real(8) :: pi = acos(-1d0) real(8) :: pi = acos(-1d0) real(8), external :: volfunc r = 1d0 r = 1d0 V = volfunc(r) V = volfunc(r) write(*,*) V write(*,*) V contains end program examp1 function volfunc(r) result(v) function volfunc(r) result(v) real(8), intent(in) :: r real(8), intent(in) :: r V = 4d0/3d0*pi*r**3 end function volfunc V = 4d0/3d0*pi*r**3 end program examp1 end function volfunc 12

14 Comparison of internal and external functions External function Internal function program examp1 program examp1 What implicit happens none if you declare pi which was already implicit declared none in the main program? Deleting real(8) the pi :: rdeclared in the main program. real(8) :: r real(8) :: pi = acos(-1d0) real(8) :: pi = acos(-1d0) real(8), external :: volfunc r = 1d0 r = 1d0 V = volfunc(r) V = volfunc(r) write(*,*) V write(*,*) ERROR V OK! contains end program examp1 function volfunc(r) result(v) function volfunc(r) result(v) real(8), intent(in) :: r Variables of the main program real(8) Variables :: V of the main program and real(8), external intent(in) subprograms :: r V and = 4d0/3d0*pi*r**3 internal subprograms are real(8) not shared. :: V end are function shared. volfunc V = 4d0/3d0*pi*r**3 end program examp1 There end function are two volfunc program units. There is one program unit. 13

15 Common statement The general form of the statement is common /block_name/ variable_name, The Common statement defines a block of main memory storage so that different program units can share the same data without using arguments. (Not recommended.) program examp real(8) :: pi common /pidata/ pi pi = acos(-1) end program examp subroutine expsub( ) real(8) :: pi common /pidata/ pi end function Declare pi to be a shared variable. The block name is decided individually. By writing the block name and pi as a common statement, it is associated with pi of main program. 14

16 Example 2 Let r be a double-precision real type variable and assign a value appropriately. Create external functions and external subroutines to calculate the volume of the sphere with radius r. However, pi assigns the value with the main program and shares the value with common statement. 15

17 Example 2 program examp2 real(8) :: r real(8) :: pi real(8),external :: volfunc common /pidata/ pi pi = acos(-1d0) r = 1d0 V = volfunc (r) write(*,*) V end program examp2 function volfunc(r) result(v) real(8), intent(in) :: r real(8) :: pi common /pidata/ pi V = 4d0/3d0*pi*r**3 end function volfunc Declare pi to be a shared variable. Assign a value to pi in the main program. Use pi assigned with the value in the main program. 16

18 Example 2 program examp2 real(8) :: r real(8) :: pi common /pidata/ pi pi = acos(-1d0) r = 1d0 call volsub(r,v) write(*,*) V end program examp2 subroutine volsub(r,v) real(8), intent(in) :: r real(8) :: pi real(8), intent(inout) :: V common /pidata/ pi V = 4d0/3d0*pi*r**3 end subroutine volsub Declare pi to be a shared the variable. Assign the value to pi in the main program. Use pi assigned with the value in the main program. 17

19 Split compilation Program can be divided into smaller files for each unit. aaa.f90 program aaa end program aaa gfortran bbb.f90 aaa.f90 bbb.f90 function bbb( ) end function bbb subroutine ccc( ) end subroutine ccc Write all the necessary files. 18

20 Example 3 Let r be a double-precision real type variable and assign a value appropriately. Create an external subroutine that calculates the volume of the sphere with radius r. However, save the external subroutine in a separate file from the main program. 19

21 Example 3 examp3.f90 program examp2 real(8) :: r real(8) :: pi common /pidata/ pi pi = acos(-1d0) r = 1d0 call volsub(r,v) write(*,*) V end program examp2 ex3sub.f90 subroutine volsub(r,v) real(8), intent(in) :: r real(8) :: pi real(8), intent(inout) :: V common /pidata/ pi V = 4d0/3d0*pi*r**3 end subroutine volsub Compilation gfortran ex3sub.f90 examp3.f90 20

Introduction to Fortran Programming. -Internal subprograms (1)-

Introduction to Fortran Programming. -Internal subprograms (1)- Introduction to Fortran Programming -Internal subprograms (1)- Subprograms Subprograms are used to split the program into separate smaller units. Internal subprogram is not an independent part of a program.

More information

Introduction to Fortran Programming. - Module -

Introduction to Fortran Programming. - Module - Introduction to Fortran Programming - Module - Subprograms Subprograms are used to split program into separate smaller units. Internal subprograms are dependent parts of program. Fortran 90 has two types

More information

Subroutines and Functions

Subroutines and Functions Subroutines and Functions Procedures: Subroutines and Functions There are two types of procedures: SUBROUTINE: a parameterized named sequence of code which performs a specific task and can be invoked from

More information

FORTRAN 90: Functions, Modules, and Subroutines. Meteorology 227 Fall 2017

FORTRAN 90: Functions, Modules, and Subroutines. Meteorology 227 Fall 2017 FORTRAN 90: Functions, Modules, and Subroutines Meteorology 227 Fall 2017 Purpose First step in modular program design Cannot always anticipate all of the steps that will be needed to solve a problem Easier

More information

Review More Arrays Modules Final Review

Review More Arrays Modules Final Review OUTLINE 1 REVIEW 2 MORE ARRAYS Using Arrays Why do we need dynamic arrays? Using Dynamic Arrays 3 MODULES Global Variables Interface Blocks Modular Programming 4 FINAL REVIEW THE STORY SO FAR... Create

More information

Subroutines, Functions and Modules

Subroutines, Functions and Modules Subroutines, Functions and Modules Subdividing the Problem Most problems are thousands of lines of code. Few people can grasp all of the details. Good design principle: Exhibit the overall structure in

More information

Reusing this material

Reusing this material Modules Reusing this material This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License. http://creativecommons.org/licenses/by-ncsa/4.0/deed.en_us

More information

SUBPROGRAMS AND MODULES

SUBPROGRAMS AND MODULES SUBPROGRAMS AND MODULES FORTRAN PROGRAMING Zerihun Alemayehu AAiT.CED Program structure Advantages of subprograms Program units can be written and tested independently A program unit that has a well defined

More information

Computational Astrophysics AS 3013

Computational Astrophysics AS 3013 Computational Astrophysics AS 3013 Lecture 2: 1) F90 variable types 2) variable declaration 3) good programming style AS3013: F90 lecture2 1 Fortran 90 variable types integer whole numbers: 3, 244, -10,

More information

AMath 483/583 Lecture 8

AMath 483/583 Lecture 8 AMath 483/583 Lecture 8 This lecture: Fortran subroutines and functions Arrays Dynamic memory Reading: class notes: Fortran Arrays class notes: Fortran Subroutines and Functions class notes: gfortran flags

More information

Programmation in Fortran

Programmation in Fortran Programmation in Fortran Adrien Poteaux CRIStAL, Université Lille Year 2017-2018 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. http://creativecommons.org/licenses/by-nc-sa/3.0/

More information

Review Functions Subroutines Flow Control Summary

Review Functions Subroutines Flow Control Summary OUTLINE 1 REVIEW 2 FUNCTIONS Why use functions How do they work 3 SUBROUTINES Why use subroutines? How do they work 4 FLOW CONTROL Logical Control Looping 5 SUMMARY OUTLINE 1 REVIEW 2 FUNCTIONS Why use

More information

SUBROUTINE subroutine-name (arg1, arg2,..., argn)

SUBROUTINE subroutine-name (arg1, arg2,..., argn) FORTRAN Subroutines Syntax Form 1 SUBROUTINE subroutine-name (arg1, arg2,..., argn) [specification part] [execution part] [subprogram part] subroutine-name Form 2 SUBROUTINE subroutine-name () [specification

More information

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Using Monte Carlo to Estimate π using Buffon s Needle Problem An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Here s the problem (in a simplified form). Suppose

More information

NO CALCULATOR ALLOWED!!

NO CALCULATOR ALLOWED!! CPSC 203 500 EXAM TWO Fall 2005 NO CALCULATOR ALLOWED!! Full Name (Please Print): UIN: Score Possible Points Prog Points Part One 33 pts Part Two 30 pts Part Three 20 pts Part Four 25 pts Total 108 pts

More information

1. User-Defined Functions & Subroutines Part 1 Outline

1. User-Defined Functions & Subroutines Part 1 Outline User-Defined Functions Subroutines Part 1 Outline 1. User-Defined Functions Subroutines Part 1 Outline 2. Intrinsic Functions Are Not Enough 3. User-Defined Functions 4. A User-Defined Function for Mean

More information

7. Procedures and Structured Programming

7. Procedures and Structured Programming 7. Procedures and Structured Programming ONE BIG PROGRAM external procedure: separated small and reusable program units to conduct individual subtasks smaller main program Each program unit can be debugged

More information

UNIVERSITY OF OSLO Department of Geosciences. GEO4060: Intro to Fortran 2003 programming. Gunnar Wollan

UNIVERSITY OF OSLO Department of Geosciences. GEO4060: Intro to Fortran 2003 programming. Gunnar Wollan UNIVERSITY OF OSLO Department of Geosciences GEO4060: Intro to Fortran 2003 programming Gunnar Wollan Spring 2014 Contents 1 Introduction 2 1.1 Why use Fortran?.................................... 2 1.2

More information

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Understand what function subprograms are Understand how to use function subprograms Understand the various kinds of REAL types Understand how to select precision in a processor

More information

Programming Tips for Plugins

Programming Tips for Plugins Programming Tips for Plugins Chad Neufeld Centre for Computational Geostatistics Department of Civil & Environmental Engineering University of Alberta Working in a university based research environment

More information

Computational Techniques I

Computational Techniques I Computational Techniques I Course Zero 2017-2018 Madrid Alicia Palacios, alicia.palacios@uam.es Cristina Sanz Sanz, cristina.sanz@uam.es Outline 1. Introduction: how to run, input 2. Data types 3. Declaration

More information

Computational modeling

Computational modeling Computational modeling Lecture 3 : Random variables Theory: 1 Random variables Programming: 1 Implicit none statement 2 Modules 3 Outputs 4 Functions 5 Conditional statement Instructor : Cedric Weber Course

More information

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Learn a simple sorting algorithm Understand how compilation & linking of separate main program and subprogram files are accomplished. Understand how to use subprograms to create

More information

PACKAGE SPECIFICATION HSL 2013

PACKAGE SPECIFICATION HSL 2013 PACKAGE SPECIFICATION HSL 2013 1 SUMMARY Given a rank-one or rank-two allocatable array, reallocates the array to have a different size, and can copy all or part of the original array into the new array.

More information

C for Engineers and Scientists

C for Engineers and Scientists C for Engineers and Scientists An Interpretive Approach Harry H. Cheng University of California, Davis 0.8 0.6 j0(t) j1(t) j2(t) j3(t) 0.4 Bessel functions 0.2 0-0.2-0.4-0.6 1 2 3 4 5 6 7 8 9 10 t Copyright

More information

Old Questions Name: a. if b. open c. output d. write e. do f. exit

Old Questions Name: a. if b. open c. output d. write e. do f. exit Old Questions Name: Part I. Multiple choice. One point each. 1. Which of the following is not a Fortran keyword? a. if b. open c. output d. write e. do f. exit 2. How many times will the code inside the

More information

Merge Sort. Run time typically depends on: Insertion sort can be faster than merge sort. Fast, able to handle any data

Merge Sort. Run time typically depends on: Insertion sort can be faster than merge sort. Fast, able to handle any data Run time typically depends on: How long things take to set up How many operations there are in each step How many steps there are Insertion sort can be faster than merge sort One array, one operation per

More information

Introduction to Modern Fortran

Introduction to Modern Fortran Introduction to Modern Fortran p. 1/?? Introduction to Modern Fortran Advanced Use Of Procedures Nick Maclaren nmm1@cam.ac.uk March 2014 Introduction to Modern Fortran p. 2/?? Summary We have omitted some

More information

Fortran 95/2003 Course

Fortran 95/2003 Course Fortran 95/2003 Course Procedures and Modules by Hartmut Häfner March 25, 2015 STEINBUCH CENTRE FOR COMPUTING - SCC KIT University of the State of Baden-Württemberg and National Laboratory of the Helmholtz

More information

Welcome. Modern Fortran (F77 to F90 and beyond) Virtual tutorial starts at BST

Welcome. Modern Fortran (F77 to F90 and beyond) Virtual tutorial starts at BST Welcome Modern Fortran (F77 to F90 and beyond) Virtual tutorial starts at 15.00 BST Modern Fortran: F77 to F90 and beyond Adrian Jackson adrianj@epcc.ed.ac.uk @adrianjhpc Fortran Ancient History (1967)

More information

Subprograms. Bilkent University. CS315 Programming Languages Pinar Duygulu

Subprograms. Bilkent University. CS315 Programming Languages Pinar Duygulu 1 Subprograms CS 315 Programming Languages Pinar Duygulu Bilkent University Introduction 2 Two fundamental abstraction facilities Process abstraction Emphasized from early days Data abstraction Emphasized

More information

Paul F. Dubois. X-Division.

Paul F. Dubois. X-Division. Large-scale simulations with Fortran 95: An object-based approach Lesson 3 Types and objects X-Division 1 of 29 In our first two lessons, we have concentrated on arrays, modules, and derived types. It

More information

C, C++, Fortran: Basics

C, C++, Fortran: Basics C, C++, Fortran: Basics Bruno Abreu Calfa Last Update: September 27, 2011 Table of Contents Outline Contents 1 Introduction and Requirements 1 2 Basic Programming Elements 2 3 Application: Numerical Linear

More information

Reflection Seismology (SCPY 482) An Introduction to Fortran 90 Programming

Reflection Seismology (SCPY 482) An Introduction to Fortran 90 Programming Reflection Seismology (SCPY 482) An Introduction to Fortran 90 Programming Chaiwoot Boonyasiriwat September 18, 2014 Outline Why Fortran 90? Hello World Compilation and Execution Recommended Program Structure

More information

Lecture V: Introduction to parallel programming with Fortran coarrays

Lecture V: Introduction to parallel programming with Fortran coarrays Lecture V: Introduction to parallel programming with Fortran coarrays What is parallel computing? Serial computing Single processing unit (core) is used for solving a problem One task processed at a time

More information

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable? Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable

More information

Modern Fortran OO Features

Modern Fortran OO Features Modern Fortran OO Features Salvatore Filippone School of Aerospace, Transport and Manufacturing, salvatore.filippone@cranfield.ac.uk IT4I, Ostrava, April 2016 S. Filippone (SATM) Modern Fortran OO Features

More information

Fortran programming for beginner seismologists Lesson 6

Fortran programming for beginner seismologists Lesson 6 IISEE lecture for group training (Seismological course) Fortran programming for beginner seismologists Lesson 6 Lecturer Tatsuhiko Hara Subprogram modules It is convenient to make a subprogram module which

More information

INF 212 ANALYSIS OF PROG. LANGS PROCEDURES & FUNCTIONS. Instructors: Kaj Dreef Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS PROCEDURES & FUNCTIONS. Instructors: Kaj Dreef Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS PROCEDURES & FUNCTIONS Instructors: Kaj Dreef Copyright Instructors. Subroutines aka Procedures Historically: blocks of instructions executed several times during program

More information

1. User-Defined Functions & Subroutines Part 2 Outline

1. User-Defined Functions & Subroutines Part 2 Outline User-Defined Functions Subroutines Part 2 Outline 1. User-Defined Functions Subroutines Part 2 Outline 2. Argument Order When Passing Arrays 3. Code Reuse Is GOOD GOOD GOOD 4. Reusing User-Defined Functions

More information

Fortran. (FORmula TRANslator) History

Fortran. (FORmula TRANslator) History Fortran (FORmula TRANslator) History FORTRAN vs. Fortran 1954 FORTRAN first successful high level language John Backus (IBM) 1958 FORTRAN II (Logical IF, subroutines, functions) 1961 FORTRAN IV 1966 FORTRAN

More information

Numerical Modelling in Fortran: day 2. Paul Tackley, 2017

Numerical Modelling in Fortran: day 2. Paul Tackley, 2017 Numerical Modelling in Fortran: day 2 Paul Tackley, 2017 Goals for today Review main points in online materials you read for homework http://www.cs.mtu.edu/%7eshene/courses/cs201/notes/intro.html More

More information

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CoCo Processor - Copyright (c) 1996 Imagine1, Inc.!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CoCo Processor - Copyright (c) 1996 Imagine1, Inc.!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CoCo Processor - Copyright (c) 1996 Imagine1, Inc.!!!!!!!! Imagine1 claims that this software is not a complete implementation!!!!

More information

y = f (x) f(x) MATLAB MATLAB - Lecture # 7 Functions and Function Files / Chapter Function File

y = f (x) f(x) MATLAB MATLAB - Lecture # 7 Functions and Function Files / Chapter Function File MATLAB - Lecture # 7 Functions and Function Files / Chapter 6 Topics Covered: 1. Function files. A FUNCTION y = f (x) A function f (x) associates a unique number y to each value of x. For example, if y

More information

Table 2 1. F90/95 Data Types and Pointer Attributes. Data Option. (Default Precision) Selected-Int-Kind

Table 2 1. F90/95 Data Types and Pointer Attributes. Data Option. (Default Precision) Selected-Int-Kind Chapter 2 Data Types Any computer program is going to have to operate on the available data. The valid data types that are available will vary from one language to another. Here we will examine the intrinsic

More information

Computers in Engineering. Subroutines Michael A. Hawker

Computers in Engineering. Subroutines Michael A. Hawker Computers in Engineering COMP 208 Subroutines Michael A. Hawker Subprograms Functions are one type of subprogram in FORTRAN Another type of subprogram FORTRAN allows is called a subroutine There are many

More information

Page 1 of 7. Date: 1998/05/31 To: WG5 From: J3/interop Subject: Interoperability syntax (Part 1) References: J3/98-132r1, J3/98-139

Page 1 of 7. Date: 1998/05/31 To: WG5 From: J3/interop Subject: Interoperability syntax (Part 1) References: J3/98-132r1, J3/98-139 (J3/98-165r1) Date: 1998/05/31 To: WG5 From: J3/interop Subject: Interoperability syntax (Part 1) References: J3/98-132r1, J3/98-139 ISO/IEC JTC1/SC22/WG5 N1321 Page 1 of 7 Describing pre-defined C data

More information

Python, C, C++, and Fortran Relationship Status: It s Not That Complicated. Philip Semanchuk

Python, C, C++, and Fortran Relationship Status: It s Not That Complicated. Philip Semanchuk Python, C, C++, and Fortran Relationship Status: It s Not That Complicated Philip Semanchuk (philip@pyspoken.com) This presentation is part of a talk I gave at PyData Carolinas 2016. This presentation

More information

FORTRAN Block data subprograms 2. Common blocks 3. Entry points 4. Function subprograms 5. Main program 6. Subroutines

FORTRAN Block data subprograms 2. Common blocks 3. Entry points 4. Function subprograms 5. Main program 6. Subroutines FORTRAN77 The first FORTRAN compiler was a milestone in the history of computing, at that time computers had very small memories (on the order of 15KB, it was common then to count memory capacities in

More information

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Understand what modules are Understand what module procedures are and how to use them Understand explicit and implicit interfaces Understand what automatic arrays are and how to

More information

Interfacing With Other Programming Languages Using Cython

Interfacing With Other Programming Languages Using Cython Lab 19 Interfacing With Other Programming Languages Using Cython Lab Objective: Learn to interface with object files using Cython. This lab should be worked through on a machine that has already been configured

More information

KGEN: Fortran Kernel Generator. National Center for Atmospheric Research (NCAR) Youngsung Kim, John Dennis, Raghu R. Kumar, and Amogh Simha

KGEN: Fortran Kernel Generator. National Center for Atmospheric Research (NCAR) Youngsung Kim, John Dennis, Raghu R. Kumar, and Amogh Simha KGEN: Fortran Kernel Generator Youngsung Kim, John Dennis, Raghu R. Kumar, and Amogh Simha National Center for Atmospheric Research (NCAR) Contents Introduction A kernel generation example Kernel generation

More information

C interfaces to HSL routines. J. D. Hogg. Version 1.0 5th December Numerical Analysis Group Internal Report

C interfaces to HSL routines. J. D. Hogg. Version 1.0 5th December Numerical Analysis Group Internal Report 2011-1 Numerical Analysis Group Internal Report C interfaces to HSL routines J. D. Hogg Version 1.0 5th December 2011 Copyright (c) 2011 Science and Technology Facilities Council C interfaces to HSL routines

More information

Fortran Introduction

Fortran Introduction 26/10/2015 1 Background 2 Creating an Executable 3 Variables 4 Program Flow 5 Procedures 6 Input and Output 7 Deprecated Background In this opening section, I will talk briefly about The History of Fortran

More information

Subprograms. FORTRAN 77 Chapter 5. Subprograms. Subprograms. Subprograms. Function Subprograms 1/5/2014. Satish Chandra.

Subprograms. FORTRAN 77 Chapter 5. Subprograms. Subprograms. Subprograms. Function Subprograms 1/5/2014. Satish Chandra. FORTRAN 77 Chapter 5 Satish Chandra satish0402@gmail.com When a programs is more than a few hundred lines long, it gets hard to follow. Fortran codes that solve real research problems often have tens of

More information

Assignment no. 5 Implementing the Parallel Quick-sort algorithm in parallel distributed memory environment

Assignment no. 5 Implementing the Parallel Quick-sort algorithm in parallel distributed memory environment Assignment no. 5 Implementing the Parallel Quick-sort algorithm in parallel distributed memory environment DCAMM PhD Course Scientific Computing DTU January 2008 1 Problem setting Given a sequence of n

More information

ParaFEM Coding Standard for Fortran 90. Contents. 1.0 Introduction. 2.0 Documentation. 2.1 External Documentation

ParaFEM Coding Standard for Fortran 90. Contents. 1.0 Introduction. 2.0 Documentation. 2.1 External Documentation ParaFEM Coding Standard for Fortran 90 This standard has been prepared by Lee Margetts, Francisco Calvo and Vendel Szeremi at the University of Manchester. It is based on Version 1.1 of the European Standards

More information

ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I

ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, 2 0 1 0 R E Z A S H A H I D I Today s class Constants Assignment statement Parameters and calling functions Expressions Mixed precision

More information

01. Function Description and Limitation 02. Fortran File Preparation 03. DLL File Preparation 04. Using the USSR material model in midas FEA

01. Function Description and Limitation 02. Fortran File Preparation 03. DLL File Preparation 04. Using the USSR material model in midas FEA midas FEA User Supplied Subroutine User Manual 01. Function Description and Limitation 02. Fortran File Preparation 03. DLL File Preparation 04. Using the USSR material model in midas FEA MIDAS Information

More information

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Understand the various kinds of REAL types Understand how to select precision in a processor independent manner Introduction to Makefiles Kinds of REAL variables The default REAL

More information

Extrinsic Procedures. Section 6

Extrinsic Procedures. Section 6 Section Extrinsic Procedures 1 1 1 1 1 1 1 1 0 1 This chapter defines the mechanism by which HPF programs may call non-hpf subprograms as extrinsic procedures. It provides the information needed to write

More information

2 Recommended books and a Web page

2 Recommended books and a Web page Fortran 95 for Fortran 77 users J.F.Harper School of Mathematics, Statistics and Computer Science Victoria University of Wellington First ed. 5 Apr 2006, latest amendments 23 May 2007 1 Introduction With

More information

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill Review of Lecture 4 Looked at Fortran commands in more detail Looked at variables and constants IO commands:

More information

2 3. Syllabus Time Event 9:00{10:00 morning lecture 10:00{10:30 morning break 10:30{12:30 morning practical session 12:30{1:30 lunch break 1:30{2:00 a

2 3. Syllabus Time Event 9:00{10:00 morning lecture 10:00{10:30 morning break 10:30{12:30 morning practical session 12:30{1:30 lunch break 1:30{2:00 a 1 Syllabus for the Advanced 3 Day Fortran 90 Course AC Marshall cuniversity of Liverpool, 1997 Abstract The course is scheduled for 3 days. The timetable allows for two sessions a day each with a one hour

More information

Outline of Fortran 90 Topics

Outline of Fortran 90 Topics Outline of Fortran 90 Topics Overview of Computing Computer Organization Languages Problem Solving Data Fortran 90 Character Set Variables Basic Data Types Expressions Numeric Non-numeric Control Structures

More information

A Brief Introduction to Fortran of 15

A Brief Introduction to Fortran of 15 A Brief Introduction to Fortran 90 1 of 15 Data Types and Kinds Data types Intrisic data types (INTEGER, REAL,LOGICAL) derived data types ( structures or records in other languages) kind parameter (or

More information

AN INTRODUCTION TO FORTRAN 90 LECTURE 2. Consider the following system of linear equations: a x + a x + a x = b

AN INTRODUCTION TO FORTRAN 90 LECTURE 2. Consider the following system of linear equations: a x + a x + a x = b AN INTRODUCTION TO FORTRAN 90 LECTURE 2 1. Fortran 90. Arrays, functions and subroutines. 2. Scientific plotting. Gnuplot 1 Each coefficient and variable is a scalar. Lengthy and cumbersome! Program Scalar

More information

Unit Testing in CESM

Unit Testing in CESM Unit Testing in CESM Bill Sacks CESM Software Engineering Group (CSEG) NCAR / CGD with substantial contributions from Sean Santos (U Washington, formerly CSEG) See also: https://github.com/ncar/cesm_unit_test_tutorial

More information

Storage and Sequence Association

Storage and Sequence Association 2 Section Storage and Sequence Association 1 1 HPF allows the mapping of variables across multiple processors in order to improve parallel 1 performance. FORTRAN and Fortran 0 both specify relationships

More information

CUDA Fortran COMPILERS &TOOLS. Porting Guide

CUDA Fortran COMPILERS &TOOLS. Porting Guide Porting Guide CUDA Fortran CUDA Fortran is the Fortran analog of the NVIDIA CUDA C language for programming GPUs. This guide includes examples of common language features used when porting Fortran applications

More information

CS 2530 INTERMEDIATE COMPUTING

CS 2530 INTERMEDIATE COMPUTING CS 2530 INTERMEDIATE COMPUTING Spring 2018 1-24-2018 Michael J. Holmes University of Northern Iowa Today s topic: Writing classes. 1 Die Objects A die has physical attributes: a specific Number of Sides

More information

Object Oriented Methods

Object Oriented Methods Chapter 5 Object Oriented Methods 5.1 Introduction In Section 1.7 we outlined procedures that should be considered while conducting the object-oriented analysis and object-oriented design phases that are

More information

Chapter 6. A Brief Introduction to Fortran David A. Padua

Chapter 6. A Brief Introduction to Fortran David A. Padua Chapter 6. A Brief Introduction to Fortran 90 1998 David A. Padua 1 of 15 6.1 Data Types and Kinds Data types Intrisic data types (INTEGER, REAL,LOGICAL) derived data types ( structures or records in other

More information

An Introduction to Fortran

An Introduction to Fortran An Introduction to Fortran Sylvia Plöckinger March 10, 2011 Sylvia Plöckinger () An Introduction to Fortran March 10, 2011 1 / 43 General Information Find this file on: http://homepage.univie.ac.at/nigel.mitchell/numprac/

More information

Module 3.7: nag ell fun Elliptic Functions. Contents

Module 3.7: nag ell fun Elliptic Functions. Contents Special Functions Module Contents Module 3.7: nag ell fun Elliptic Functions nag ell fun contains a procedure for evaluating the Jacobian elliptic functions sn, cn and dn. Contents Introduction... 3.7.3

More information

DVRP Library Documentation

DVRP Library Documentation DVRP Library Documentation A Parallel Library for 3D-Visualization RRZN (http://www.rrzn.uni-hannover.de) Universität Hannover DVRP Library Documentation: A Parallel Library for 3D-Visualization by RRZN

More information

Introduction to parallel computing with MPI

Introduction to parallel computing with MPI Introduction to parallel computing with MPI Sergiy Bubin Department of Physics Nazarbayev University Distributed Memory Environment image credit: LLNL Hybrid Memory Environment Most modern clusters and

More information

Computational modeling

Computational modeling Computational modeling Lecture 5 : Monte Carlo Integration Physics: Integration The Monte Carlo method Programming: Subroutine Differences Subroutine/Function The Fortran random number subroutine Monte

More information

naïve GPU kernels generation from Fortran source code Dmitry Mikushin

naïve GPU kernels generation from Fortran source code Dmitry Mikushin KernelGen naïve GPU kernels generation from Fortran source code Dmitry Mikushin Contents Motivation and target Assembling our own toolchain: schemes and details Toolchain usecase: sincos example Development

More information

II Esercitazione: S.O. & Fortran 90

II Esercitazione: S.O. & Fortran 90 II Esercitazione: S.O. & Fortran 90 Francesco Battista Laboratorio di Calcolo di Aerodinamica a.a. 2016/17 DIMA, Sapienza University of Rome, Italy April 4, 2017 Outlines 1 Short description of computer

More information

Chapter 7 - Notes User-Defined Functions II

Chapter 7 - Notes User-Defined Functions II Chapter 7 - Notes User-Defined Functions II I. VOID Functions ( The use of a void function is done as a stand alone statement.) A. Void Functions without Parameters 1. Syntax: void functionname ( void

More information

Advanced Features. SC10 Tutorial, November 15 th Parallel Programming with Coarray Fortran

Advanced Features. SC10 Tutorial, November 15 th Parallel Programming with Coarray Fortran Advanced Features SC10 Tutorial, November 15 th 2010 Parallel Programming with Coarray Fortran Advanced Features: Overview Execution segments and Synchronisation Non-global Synchronisation Critical Sections

More information

6.1 Expression Evaluation. 1 of 21

6.1 Expression Evaluation. 1 of 21 6.1 Expression Evaluation 1 of 21 The world of expressions In the absence of side effects, expressions are relatively simple and nice objects. Functional programming languages rely on expressions as their

More information

41391 High performance computing: Miscellaneous parallel programmes in Fortran

41391 High performance computing: Miscellaneous parallel programmes in Fortran 1391 High performance computing: Miscellaneous parallel programmes in Fortran Nilas Mandrup Hansen, Ask Hjorth Larsen January 19, 0 1 Introduction This document concerns the implementation of a Fortran

More information

Chapter 6: User defined functions and function files

Chapter 6: User defined functions and function files The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming (ECIV 2302) Chapter 6: User defined functions and function files ١ 6.1 Creating a function file Input

More information

eccodes GRIB Fortran 90 - Python APIs Part 1 Dominique Lucas and Xavi Abellan ECMWF March 1, 2016

eccodes GRIB Fortran 90 - Python APIs Part 1 Dominique Lucas and Xavi Abellan  ECMWF March 1, 2016 eccodes GRIB Fortran 90 - Python APIs Part 1 Dominique Lucas and Xavi Abellan Dominique.Lucas@ecmwf.int Xavier.Abellan@ecmwf.int ECMWF March 1, 2016 For GRIB data, the only difference between the GRIB

More information

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill Review of last lecture Start examining the FORTRAN language Development of the language Philosophy of language:

More information

Programming Languages

Programming Languages Programming Languages Tevfik Koşar Lecture - VIII February 9 th, 2006 1 Roadmap Allocation techniques Static Allocation Stack-based Allocation Heap-based Allocation Scope Rules Static Scopes Dynamic Scopes

More information

8. Random Number Generation

8. Random Number Generation 8. Random Number Generation Pseudo-Random Numbers To simulate noise signals in the real world (true random numbers) e.g., background ambient noise in acoustics; turbulence in fluid flows To generate values

More information

Level 3 Computing Year 2 Lecturer: Phil Smith

Level 3 Computing Year 2 Lecturer: Phil Smith Level 3 Computing Year 2 Lecturer: Phil Smith Previously We started to build a GUI program using visual studio 2010 and vb.net. We have a form designed. We have started to write the code to provided the

More information

Numerical Modelling in Fortran: day 6. Paul Tackley, 2017

Numerical Modelling in Fortran: day 6. Paul Tackley, 2017 Numerical Modelling in Fortran: day 6 Paul Tackley, 2017 Today s Goals 1. Learn about pointers, generic procedures and operators 2. Learn about iterative solvers for boundary value problems, including

More information

write (unit=*,fmt=*) i =, i! will print: i = 3

write (unit=*,fmt=*) i =, i! will print: i = 3 I/O (F book, chapters 9, 10 and 15) All I/O in Fortran90 is record-based, typically with record delimiters of some kind. This is in contrast to C, which has stream I/O, with no record delimiters required.

More information

Manual for explicit parallel peer code EPPEER

Manual for explicit parallel peer code EPPEER Manual for explicit parallel peer code EPPEER Bernhard A. Schmitt (Univ. Marburg, Germany) Rüdiger Weiner (Univ. Halle, Germany) August 24, 202 eppeer is a FORTRAN95 code with OpenMP parallelization solving

More information

Array Processing { Part II. Multi-Dimensional Arrays. 1. What is a multi-dimensional array?

Array Processing { Part II. Multi-Dimensional Arrays. 1. What is a multi-dimensional array? Array Processing { Part II Multi-Dimensional Arrays 1. What is a multi-dimensional array? A multi-dimensional array is simply a table (2-dimensional) or a group of tables. The following is a 2-dimensional

More information

UNIT II PL / SQL AND TRIGGERS

UNIT II PL / SQL AND TRIGGERS UNIT II PL / SQL AND 1 TRIGGERS TOPIC TO BE COVERED.. 2.1 Basics of PL / SQL 2.2 Datatypes 2.3 Advantages 2.4 Control Structures : Conditional, Iterative, Sequential 2.5 Exceptions: Predefined Exceptions,User

More information

Fortran 90. Student Notes. A Conversion Course for Fortran 77 Programmers. S Ramsden, F Lin. M A Pettipher, G S Noland, J M Brooke

Fortran 90. Student Notes. A Conversion Course for Fortran 77 Programmers. S Ramsden, F Lin. M A Pettipher, G S Noland, J M Brooke Fortran 90 A Conversion Course for Fortran 77 Programmers Student Notes S Ramsden, F Lin Manchester and North HPC T&EC M A Pettipher, G S Noland, J M Brooke Manchester Computing Centre, University of Manchester

More information

A quick guide to Fortran

A quick guide to Fortran A quick guide to Fortran Sergiy Bubin Department of Physics Nazarbayev University History of Fortran One of the oldest general purpose high-level computer languages First developed in 1957 at IBM in the

More information

2. Basic Elements of Fortran

2. Basic Elements of Fortran 2. Basic Elements of Fortran Structure of a Fortran Program 31 characters must be in the 1st line if present declaration section program my_first_program! Declare variables integer :: i, j, k! i, j, k

More information

CS 251 Intermediate Programming Java Basics

CS 251 Intermediate Programming Java Basics CS 251 Intermediate Programming Java Basics Brooke Chenoweth University of New Mexico Spring 2018 Prerequisites These are the topics that I assume that you have already seen: Variables Boolean expressions

More information

Introduction to Scientific Computing Languages

Introduction to Scientific Computing Languages 1 / 1 Introduction to Scientific Computing Languages Prof. Paolo Bientinesi pauldj@aices.rwth-aachen.de Languages for Scientific Computing 2 / 1 What is a programming language? Languages for Scientific

More information