Sie sind auf Seite 1von 27

Scientific Programming

Gordon Erlebacher
ISC5305
9:30 - 10:45 Tu-Th
Miscellaneous
Syllabus
http://www.scs.fsu.edu/~erlebach/course/scientific
_programming_f2007/syllabus.html
Class accounts
Who does not have an account?
http://www.scs.fsu.edu/user-request.php
Course number: ISC 5305
Instructor: Gordon Erlebacher
Section number: 01
Choose a password
Choose bash as the preferred shell, csh also ok
Provide your email
Class Expectations
Write many programs
Take notes in class (IMPORTANT)
Ask questions (IMPORTANT)
Modify examples (what-if scenarios)
Experimentation with code
Take code written in one language, and
translate it to another language
Benchmark and document all codes; output
the benchmark results
Write programs clearly (affects the grade)
Additional Information
Secondary web site:
http://www.sci-prog.gorerle.com/
Provides homework tracking and homework
submission
If homeworks are late (not allowed), users get
reminders. The system will track how late a
homework is returned and the number of times a user
returns a homework.
Users can monitor their status, and perhaps their
grades (several weeks into the course)
Chris Harden will provide help sessions and office
hours for help. I will serve as a backup.
Shell Environment: bash
Use bash shell. In .bashrc or .profile
export SHELL=bash
case `hostname` in
class*)
export PATH=.:$PATH
# JAVA
export JAVA_HOME_15=/usr/java/jdk1.5.0_06/
export JAVA_HOME=$JAVA_HOME_15
export JAVA_BIN=$JAVA_HOME/bin/
export PATH=$JAVA_BIN:$PATH
# C++ (paths work for everybody)
# Fortran (paths work for everybody)
GRAPHVIZ_BIN=$HOME/src/graphviz/bin
export PATH=$GRAPHVIZ_BIN:$BIN_PATH:$PATH
export TIMERS=$HOME/sci_prog07/src/timers
esac
Shell Environment: csh
Use bash shell. In .cshrc or .login
switch `hostname`
case class*:
export PATH=.:$PATH
# JAVA
setenv JAVA_HOME_15 /usr/java/jdk1.5.0_06/
setenv JAVA_HOME $JAVA_HOME_15
setenv JAVA_BIN $JAVA_HOME/bin/
setenv PATH $JAVA_BIN:$PATH
# C++ (paths work for everybody)
# Fortran (paths work for everybody)
set GRAPHVIZ_BIN = $HOME/src/graphviz/bin
setenv PATH $GRAPHVIZ_BIN:$BIN_PATH:$PATH
setenv TIMERS $HOME/sci_prog07/src/timers
breaksw
endsw
Syllabus Highlights
Class attendance is mandatory
No Final project or exam
Weekly homeworks
Articles to read and summarize
Programming assignments
Take notes in class
Ask questions
What we will do
Implement some basic algorithms
Learn to translate algorithms into pseudo-
code
Learn to translate pseudo-code to code in a
top-down approach
Learn to think in an object-oriented way
Learn the major features of each language
Use the Web to lookup information
dynamically
Program in class in real time to demonstrate
concepts
What we will not do
Learn theoretical properties of algorithms
and data structures
Learn parallel computing
Learn every last feature of each language
Simplified Language History
http://www.levenez.com/lang/
1957
1966
1986
1996
2005
1972
Fortran I
Fortran IV
1978
Fortran 77
Fortran 90
Fortran 2003
1991
Java
Java 1.5
C
ANSI C
GNU C
C++
C++ Release 3
The Language List: Fortran
http://people.ku.edu/~nkinners/LangList/Extras/langlist.htm
Fortran I: 1st compiler: 1957
Fortran IV: standardized: 1966
Fortran 77: 1978
Block IF, PARAMETER, SAVE statements added, no WHILE. Fixed length
character strings, format-free I/O, arrays with lower bounds
Fortran 90: 1991
An extensive enlargement of FORTRAN 77. Derived types, assumed shape
arrays, array sections, functions returning arrays, case statement, module
and internal subprograms, optional and keyword subprogram arguments,
recursion and dynamic memory allocation.
Fortran 2003: 2005
An extension of FORTRAN 95. Exception handling and object-oriented
programming, and interoperability with C. No compilers yet.
The Language List: Java
http://people.ku.edu/~nkinners/LangList/Extras/langlist.htm
Java: 1995
A simple, object-oriented, distributed, interpreted, robust,
architecture neutral, portable, high-performance,
multithreaded, dynamic language. Similar in appearance to
C++, but without operator overloading, multiple inheritance,
automatic coercions, and pointer arithmetic. Garbage
collection. Synchronization primitive based on monitors as
found in Cedar and Mesa. Interfaces borrowed from
Objective C. Designed to be secure, with authentication
techniques based on public-key encryption. Interpreted with
a stack-based virtual machine. A net interface allows the
compiled code to be sent across the Internet and remotely
executed, thus allowing users to add programs to their web
pages.
The Language List: C
http://people.ku.edu/~nkinners/LangList/Extras/langlist.htm
C: 1972
C was originally a systems language for Unix on the PDP-11, briefly named
NB. It was influenced by BCPL through Thompsons B. C is terse, low-level
and permissive. Preprocessor. Partly due to its distribution with Unix, C
became the language most widely used for software implementation.
ANSI C: 1989
A revision of C, adding function prototypes, structure passing, and
assignment, and standardized library functions. ANSI X3.159-1989.
GNU C: 1992
Many extensions: compound statement within an expression, pointers to
labels, local labels, nested functions, typeof operator, compound and
conditional expressions and casts allowed as lvalues, long long ints, arrays
of variables length macros with variable number of arguments, non-constant
initializers, constructor expressions, labeled elements in initializers, case
ranges, variable attributes.
The Language List: C++
http://people.ku.edu/~nkinners/LangList/Extras/langlist.htm
C++: 1986
An object-oriented superset of C. In C++ a class is a user-
defined type, syntactically a struct with member functions.
Constructors and destructors are member functions called to
create or destroy instances. A friend is a non-member
function that is allowed to access the private portion of a
class. C++ allows implicit type conversion, function inlining,
overloading of operators and function names, default
function arguments, and pass by reference. It has streams
for I/O.
C++ release 3.0: 1996
Templates added
By the end of the course
Understand benefits of each language
Understand where they are best used
Write programs in all three languages
Learn to look up relevant information on the
web
Learn to find documentation on the web, and
generate it
Automate the compilation/linking process
Understand benchmarking and profiling
results
Generic Structure of a
Scientific Code
Data Input
Initializations
Computations
Data Output
Important for Scientific Coding
Minimize hard coding (numbers and strings)
Documentation
Good Mnemonics
Restart capability
Documented data output
Code testing
Data analysis and visualization
Benchmarking
Profiling
Language Concepts
Variables (x,y,_a45,..)
Types (int, real, float, struct, typedef,..)
Classes, structures, modules
Subclasses, inheritance, interfaces
Methods, subroutines, functions
Function and operator overloading
Pointers, references, values
Language Commonalities
Variables
Object-orientation (encapsulation)
Subroutines/functions/methods
Iterators (for, while, do )
Flow control (if, unless, )
Multi-file objects
Input/Output (I/O)
External libraries
Project-related tools (make, ant, maven)
Java
Fully object-oriented
Subclassing
No multiple inheritance
Garbage collection
Automatic removal of unneeded data
No pointers (cannot manipulate memory
addresses)
Exception handling
Security (web-based computing: applets)
Protects users against themselves
C++
Object-oriented (but not necessary)
Superset of C
Low level, close to hardware devices
Multiple inheritance (dangerous)
Function and operator overloading
Pointers and references
Exception handling
Easy to write code difficult to debug
Hard to construct generic tools
Due to aliasing and pointer manipulation
Fortran 90/95
Increasingly object-oriented
Next version: 2003 (no compilers yet)
Array operations
Modules
Multi-dimension arrays
Very efficient
Function overloading through interfaces
Primitive structures
Java: some disadvantages
No operator overloading
No templates
Byte-level compiler
a sophisticated interpreter
50% of C++ efficiency
No exponentiation operator
No intrinsic multi-dimensional arrays
No pointers
Fortran 90/95: some
disadvantages
No subclassing
Lacks references
Verbose
Very large programs are difficult to
maintain
No exception handling
C++: some disadvantages
Messy class operations
Friends, multiple inheritance
Include files can be dangerous
No exponentiation operator
Use of pointers complicates debugging
Arguments can be passed by reference
or by pointer (can be confusing)
Coding Examples
Fortran 90
Espresso Code (quantum physics) (cp_fpmd_f90.pdf)
C++
Wavelet Transform (wlt_cpp.pdf)
3D array class (Array3D_h.pdf, Array3D_cpp.pdf)
Java
Flow (from middleware) (NBWaveletApplet_java.pdf
Dynamic Array Class (DynamicByteArray_java.pdf)
Homework
No homework on this first day

Das könnte Ihnen auch gefallen