Top Banner
CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming It will at times seem like a course in programming, because we will sometimes get bogged down in details…
25

CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

1

CSCE 206Scientific Applications Programming

This is not a course in “programming”

This is a course in “computing”

We will do a lot of programming

It will at times seem like a course in programming, because we will sometimes get bogged down in details…

Page 2: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

2

CSCE 206

This will at times seem like a course in programming, because we will sometimes get bogged down in details…

Try to remember• that this is a course in “computing”• that to know “computing” you must know

“programming”• that our goal is “computing” for numerical

applications

Page 3: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

3

Numerical Applications

Top 500 list www.top500.orgFinding roots of equationsInterpolation of functionsCurve fittingNumerical differentiationNumerical integrationMatrix operationsAverages, deviations, momentsDifferential equations

Page 4: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

4

Why Fortran?

Why not Matlab? MathCad? Maple? Mathematica?

For “small” applications, these are fine

For “large” applications, they are too slow and inflexible

“Real” computing requires a “real” language

Page 5: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

5

Which Fortran?

195x – FORTRAN1962 – FORTRAN II1966 – FORTRAN IV (a.k.a. FORTRAN 66)1977 – FORTRAN 771990 – Fortran 901995 – Fortran 952003 – Fortran 2000 a.k.a. Fortran 2k

Various other versions have also existed (HPF, IBM FORTRAN G, H, …)

Page 6: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

6

Which Fortran?

The big change was to Fortran 90 from FORTRAN 77

We will do F90, which is the “modern” Fortran

Differences between F90, F95, and F2K are nonexistent at the level of this course

Vendors have always “enhanced” their languages as a way of making vendor switching hard

We will concentrate on ANSI Standard Fortran 90(ANSI = American National Standards Institute)

Page 7: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

7

Why Unix?

For small jobs, for simple experimentation, you should use Matlab, or something similar.

The reason for using a real programming language is to solve problems too big for desktops.

There aren’t any non-Unix machines on the Top 500 list (and I don’t think there ever have been any).

Real computing is done on Unix machines.

Page 8: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

8

Which Unix?

It is almost true that all Unix is alike.UnixLinuxSolaris (Sun Microsystems)HPIX (Hewlett-Packard)Irix (Silicon Graphics)UNICOS (Cray Research, Inc.)AIX (IBM)

Page 9: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

9

Why Unix?

“I view different computer operating systems as being like different cuisines. Using an Apple is like keeping kosher; the believers would not live any other way, but they cannot eat with members of other religions. Using Unix is like preparing your own meals from recipes in the Joy of Cooking; the effort involved initially exceeds the palatability of the results, but experience eventually brings satisfaction. Using Microsoft Windows is like eating at a McDonald’s; you can find one anywhere, and the food will keep you going, but it would be sad if there were no other restaurant in town.”

(Gerald Folland, American Math Monthly, March 2000)

Page 10: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

10

Bottom Line

We will, therefore, cover• computing• in the modern (standard) version of Fortran• on numerical applications• on a standard Unix platformThis will be computing done the way it’s done in

the major leagues (Los Alamos, NCAR, Livermore, aircraft/auto/oil industry)

This will (I hope) prepare you to be adaptable to Fortran (and other languages) on other platforms using other compilers and tools

Page 11: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

11

How-to-write-programs Issues

The operating system (in this case, Unix)The development environment• editor (you are free to choose)• we will not use a GUI (graphical user

interface)• we will use a command line interface• we will use a makefile for convenienceCompiler to translate source code to an

executableLibraries of standard routines (math functions,

etc.)

Page 12: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

12

CSE Dept: How to Write Programs

I don’t use Blackboard; I do use the CSE web server, and almost everything will be on the web

• look up the CSE secure web page https://www.cse.sc.edu

• CSCE dropbox for submitting your programs• CSCE206 group mailing list for broadcast• CSCE individual email accountswww.cse.sc.eduwww.cse.sc.edu/~buell

Page 13: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

13

Bonus Points

Computing is a human endeavor

You should know the human history of how we got to where we are

In-class bonus points: 1 point on the total grade

Exam bonus points: 2 points on the total grade per exam

Page 14: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

14

Some Thoughts on Programming

“Lesser artists borrow; great artists steal.”Stravinsky

There is a lot of code available to look at and use.

Page 15: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

15

From Whom Can You Steal?

Yourself—of course, from one program to the next

From the text—yesFrom the Internet—noFrom yourself—yesFrom other reference books—noFrom yourself—yesFrom the Internet—no

There is a program that lets me compare one program against another for similarities.

Page 16: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

16

The End

Page 17: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

17

Chapter 0 (or 1?)

Computer organisation and architecture

How is the machine put together

p17-ComputerComponents.pdf

Page 18: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

18

The Program Translation Process

Program source code (C, Fortran, Java, …)

Source is translated by a compiler

into object code

and then into machine code

which forms an executable module

Page 19: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

19

Source Code

Has symbolic names for things and permits writing programs in a way that is understandable by people.

PROGRAM hello_world

IMPLICIT none

REAL :: r,s

PRINT *, “hello, world”

PRINT *, “My name is Duncan Buell”

r = 64.0

s = SQRT(r)

PRINT *, “r is”,r,“and its square root is”,s

STOP

END PROGRAM hello_world

Page 20: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

20

Machine Code

Machines don’t understand Fortran

Computers don’t have a single “instruction” that prints a line of output, for example

Machine code is the numerical language for the specific instructions of the machine

one machine code instruction = one machine operation

The compiler (and other language translators) turn source code into machine code

Page 21: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

21

Object Code

Object code is intermediate between source and executable

We won’t deal much with object code, and we won’t even define it carefully

Characteristic of object code• the compiler turns your source into object• references outside your own source (e.g., math

libraries) may not be fully turned into machine code by the compiler—that happens later

Page 22: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

22

The Programming Process

Problem analysis and specification

Data organisation and algorithm design

Coding (programming)

Execution and testing

Maintenance

Page 23: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

23

Political Correctness—“Safe” programming

Programs have bugsPrograms have always had bugsWe all do stupid, careless, things

It’s possible to be careless and still get a working program

But it’s more likely that you’ll get working programs if you follow “safe” programming practices

And I’m going to beating these practices into you the entire semester!!!!!

Page 24: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

24

Prudent Programming Practices

“Failure is the norm. You’re going to fail. So fail in such a way that you can recover quickly and get it right the second time.” (John Mashey)

A working program that doesn’t quite do what is desired has some value.

A program that would do everything desired, if it worked, but doesn’t work, has almost no value.

“Make it right before you make it better.”

Page 25: CSCE 206 1 CSCE 206 Scientific Applications Programming This is not a course in “programming” This is a course in “computing” We will do a lot of programming.

CSCE 206

25

The End