External Fortran-C Codes external codes, Fortran, C, or local commerical libraries may be executed from within NCL generic process – develop a wrapper.

Slides:



Advertisements
Similar presentations
Accelerated Linear Algebra Libraries James Wynne III NCCS User Assistance.
Advertisements

Everyone loves Fortran. 1. Deprecate mpif.h Fortran refresher Two Fortran interfaces for each MPI function Available in three different bindings Integer.
N ATIONAL E NERGY R ESEARCH S CIENTIFIC C OMPUTING C ENTER 1 Mixed Language Programming on Seaborg Mark Durst NERSC User Services.
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.
Review What is a virtual function? What can be achieved with virtual functions? How to define a pure virtual function? What is an abstract class? Can a.
Combining NCL and Fortran in C-shell
Chapter 7 Process Environment Chien-Chung Shen CIS, UD
Lecture 16 Subroutine Calls and Parameter Passing Semantics Dragon: Sec. 7.5 Fischer: Sec Procedure declaration procedure p( a, b : integer, f :
Binding python to other languages (Fortran and C).
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Application of Fortran 90 to ocean model codes Mark Hadfield National Institute of Water and Atmospheric Research New Zealand.
Chapter 6 Programming with Functions. FUNCTIONS Intrinsic Functions (or called library functions) Function Subprograms: programmer-defined functions.
FORTRAN Short Course Week 2 Kate Thayer-Calder February 23, 2009.
Functions & Subroutines HTML version DFMain.chm. Types of subprograms Internal External Module Pure Elemental Recursive Optional arguments Generic Defined.
Introduction to Fortran 90 Programming André Paul.
Fortran 9x HTML version. New F90 features Free source form Modules User-defined data types and operators Generic user-defined procedures Interface blocks.
6 April, 2000 CS1001 Lecture 15 EXAM1 - results SUBPROGRAM - - revisit FUNCTION.
27 March, 2000 CS1001 Lecture 16 FUNCTIONS SUBROUTINES SCOPE MODULES EXTERNAL SUBPROGRAMS.
Chapter 10 Modules and programming with subroutines.
Chapter 9 Modules and Programming with Functions.
ICS312 Set 11 Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External.
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.
The switch StatementtMyn1 The switch Statement Sometimes there can be a multiple-choice situation, in which you need to execute a particular set of statements.
ReAl :: x OK CHARACTER :: name OK, a 1 character name! CHARACTER(LEN=10) :: name OK, string length 10 REAL :: var-1 cannot have -1 in a declaration var_1.
Fortran- Subprograms Chapters 6, 7 in your Fortran book.
The NCAR Command Language (NCL) Ethan Alpert Visualization and Enabling Technologies Section, SCD, NCAR.
Fortran: Specification Statements Session Six ICoCSIS.
Introduction to FORTRAN
Fortran: Program Units and Procedures Session Four ICoCSIS.
Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External 2. The type.
Dennis Shea National Center for Atmospheric Research
Hans-Peter Plag October 16, 2014 Session 3 Programming Languages Data Types and Variables Expressions and Operators Flow Control.
Week 8. Today’s program n New stuff: –Recursion in F –Procedures as arguments –User-defined data types n Quiz #3.
Week 8 Improving on building blocks Recursive procedures.
VHDL FLI. FLI Definition FLI routines are C programming language functions that provide procedural access to information within the HDL simulator.
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:
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.
1 Serial Run-time Error Detection and the Fortran Standard Glenn Luecke Professor of Mathematics, and Director, High Performance Computing Group Iowa State.
Subprograms subroutines, procedures, functions, methods.
ECE122 Feb. 22, Any question on Vehicle sample code?
Some Fortran programming tips ATM 562 Fall 2015 Fovell (see also PDF file on class page) 1.
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.
Fortran 95 for the.NET Framework David Bailey
Navigation and Ancillary Information Facility NIF IDL Interface to CSPICE “Icy” How to Access the CSPICE library Using Interactive Data Language (IDL)
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Beginning Fortran Fortran (77) Advanced 29 October 2009 *Black text on white background provided for easy printing.
Subroutines. Subroutine Subprograms Common features of Subroutines and functions –They perform particular tasks under the control of some other program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
FORTRAN History. FORTRAN - Interesting Facts n FORTRAN is the oldest Language actively in use today. n FORTRAN is still used for new software development.
FALL 2001ICOM Lecture 01 ICOM 4015 Advanced Programming Lecture 0 Review of Programming I Reading: LNN Chapters 1-3,5-6.
FORTRAN 90+ Yetmen Wang Fortran 90/95/2000 INTRODUCTION FORTRAN VERSIONS PROGRAM STRUCTURE NEW SOURCE FORM OO PROGRAMMING ARRAY PROGRAMMING SIGNIFICANT.
Fortran MATTHEW CARSON. History of FORTRAN FORTRAN ; First High Level Language FORTRAN I 1957; First Compiled Language FORTRAN II ; Independent.
More on F90 Outline: I.Parameter statements II.Comments III.Program layout-- execution part IV.if/then/else V.Case statements VI.do loops VII.goto VIII.Intrinsic.
19 - 2/25/2000AME 150L1 Solving Systems of Linear Equations.
More on Variables and Subroutines. Introduction Discussion so far has dealt with self- contained subs. Subs can call other subs or functions. A module.
Data Processing Dennis Shea National Center for Atmospheric Research NCAR is sponsored by the National Science Foundation.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Fundamentals of Programming Most.
Announcements. Practice questions, with and without solutions will be uploaded by Friday 5 th November, make sure to check them before the weekend \\netstorage\Subjects\ITCA-b\Exam.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
Fortran Tutorial Fortran spaces for code qqqqqqCODE
Functions and Subroutines
Procedures and Modular Programming
Midterm Review Programming in Fortran
Interface to the current CCPP: A simple model’s perspective
mdul-cntns-sub-cmmnts2.f90
LAPACK3E – A Fortran 90-enhanced version of LAPACK
Presentation transcript:

External Fortran-C Codes external codes, Fortran, C, or local commerical libraries may be executed from within NCL generic process – develop a wrapper (interface) to transmit arguments – compile the external code (eg, f77, f90, cc) – link the external code to create a shared object process simplified by operator called WRAPIT specifying where shared objects are located – external statement  external “/dir/code.so” – system environment variable:  LD_LIBRARY_PATH – NCL environment variable:  NCL_DEF_LIB_DIR  external functions need not have :: before use

NCL/ Fortran Argument Passing arrays: NO reordering required – x(time,lev,lat,lon) x(lon,lat,lev,time) ncl: x( N,M ) => value <= x( M,N ) :fortran [M=3, N=2]  x(0,0) => 7.23 <= x(1,1)  x(0,1) => <= x(2,1)  x(0,2) => 0.3 <= x(3,1)  x(1,0) => <= x(1,2)  x(1,1) => <= x(2,2)  x(1,2) => <= x(3,2) numeric types must match – integer integer – double double – float real Character-Strings: a nuisance [C,Fortran]

Example: Linking to Fortran 77 STEP 1: quad.f C NCLFORTSTART subroutine cquad(a,b,c,nq,x,quad) dimension x(nq), quad(nq) C NCLEND do i=1,nq quad(i) = a*x(i)**2 + b*x(i) + c end do return end C NCLFORTSTART subroutine prntq (x, q, nq) integer nq real x(nq), q(nq) C NCLEND do i=1,nq write (*,"(i5, 2f10.3)") i, x(i), q(i) end do return end STEP 2: quad.so WRAPIT quad.f STEPS 3-4 external QUPR "./quad.so" begin a = 2.5 b = -.5 c = 100. nx = 10 x = fspan(1., 10., 10) q = new (nx, float) QUPR::cquad(a,b,c, nx, x,q) QUPR::prntq (x, q, nx) end

Example: Linking F90 routines prntq_I.f90 module prntq_I interface subroutine prntq (x,q,nq) real, dimension(nq) :: x, q integer, intent(in) :: nq end subroutine end interface end module cquad_I.f90 module cquad_I interface subroutine cquad (a,b,c,nq,x,quad) real, intent(in) :: a,b,c integer, intent(in) :: nq real,dimension(nq), intent(in) :: x real,dimension(nq),intent(out) :: quad end subroutine end interface end module quad.f90 subroutine cquad(a, b, c, nq, x, quad) implicit none integer, intent(in) :: nq real, intent(in) :: a, b, c, x(nq) real, intent(out) :: quad(nq) integer :: i ! local quad = a*x**2 + b*x + c ! array return end subroutine cquad subroutine prntq(x, q, nq) implicit none integer, intent(in) :: nq real, intent(in) :: x(nq), q(nq) integer :: i ! local do i = 1, nq write (*, '(I5, 2F10.3)') i, x(i), q(i) end do return end STEP 1: quad90.stub C NCLFORTSTART subroutine cquad (a,b,c,nq,x,quad) dimension x(nq), quad(nq) ! ftn default C NCLEND C NCLFORTSTART subroutine prntq (x, q, nq) integer nq real x(nq), q(nq) C NCLEND STEP 2: quad90.so WRAPIT –pg quad90.stub printq_I.f90 \ cquad_I.f90 quad.f90 STEP 3-4: same as previous ncl < PR_quad90.ncl