1. Trang chủ
  2. » Công Nghệ Thông Tin

fortran lecture, slide

18 230 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 18
Dung lượng 769,13 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

• Developed by IBM in the 1950s • Designed for use in scientific and engineering fields • Originally written as FORTRAN – Convention is caps up to FORTRAN77 – Title caps for Fortran 90

Trang 1

Jordan Martin Steven Devine

Trang 2

• Developed by IBM in the 1950s

• Designed for use in scientific and engineering fields

• Originally written as FORTRAN

– Convention is caps up to FORTRAN77

– Title caps for Fortran 90 forward

Trang 3

• Brainchild of John Backus as a more friendly and useable alternative to assembly language

•Fortran’s compiler, released in 1957, was the first optimizing compiler.

Trang 4

Hello World

program hello

print *, "Hello World!"

end program hello

Trang 5

Current Usage

• Scientific Community

• Engineers

•Super Computing

Trang 6

• Pros

– Formulas and functions are easily recognizable

– Strongly typed.

– Looping and control statements work in familiar ways in later versions of Fortran, using do

as the primary key word.

Trang 7

• Cons

– Case Insensitive

– Whitespace insensitive

– Many built-in functions and types, lacks high orthogonality

– GOTO

– Column major order for 2D arrays

Trang 8

• Pros

– Case insensitive

– Whitespace insensitive

– Powerful functions and algebraic evaluation

Trang 9

• Cons

– GOTO is the basis for control structure in older versions

– Names restricted to 6 characters

– Variables are in scope only for subroutines

Trang 10

- The FORTRAN language has not specified evaluation order for expressions

- Compilers are free to evaluate each line as they please

PROGRAM ARGORD

INTEGER I, F1, F2, F3, F4

EXTERNAL F1, F2, F3, F4

WRITE (*,*) 'Evaluation order: '

I = F1(I) + F2(I) + F3(I) + F4(I)

END

Trang 11

Short Circuit Evaluation

-The compiler is free to evaluate boolean expressions in any order,

making short-circuit evaluation unreliable

-This code will either work as intended or crash, depending on the

compiler that was used

INTEGER I

REAL ARRAY(100)

IF ((I GE 1) AND (I LE 100) AND ARRAY(I) GT 0) THEN

WRITE (*,*) 'Array element is positive '

ENDIF

Trang 12

Strong Type Checking

- FORTRAN uses static (compile time) type checking

-At run time all variables in memory are bit strings without

data type information

-No type checking is done at run time, variables are just

accessed by the starting address of variable

Trang 13

-FORTRAN revisions are almost completely backwards-compatible and have only removed obsolete instructions

-FORTRAN 90 introduced KIND type parameters, which are

variables can be declared with arbitrarily specified ranges and

precisions, eliminating platform-based data type issues

-An example of the KIND type:

real (kind=kind(0.0)) r

-kind(0.0) defaults to the processor's built in size for a real,

or the programmer can specify the number of digits

Trang 14

FORTRAN Exception Handling

- In FORTRAN, pointers cannot overlap in memory

- This is done to allow optimization for greater speed in numerical calculations

- All arrays passed to subroutines are guaranteed not to be aliased, so array

elements can be stored in registers for the duration of the subroutine

void transform (float *output, float * input, float * matrix, int n)

{

int i;

for (i=0; i<n; i++)

{

float x = input[i*2+0];

float y = input[i*2+1];

output[i*2+0] = matrix[0] * x + matrix[1] * y;

output[i*2+1] = matrix[2] * x + matrix[3] * y;

}

}

Trang 15

- Time spent learning a dying niche language

-There are free compilers available that vary in quality and output

The expensive compilers offer tools and integration into modern programs like NET

-Legacy FORTRAN code can be difficult to read and refactor due to age Older FORTRAN programs may not have obeyed any recognizable

methodology Also, GOTO statements

Trang 16

Modern Uses

- A majority of supercomputers run programs written in FORTRAN

-Monster.com lists about fifty jobs that require FORTRAN experience Twenty of those fifty also require security clearance

-FORTRAN is still the fastest when it comes to computationally-intensive mathematical models, such as weather prediction,

computational science, air and fluid modeling, etc

Trang 17

Parting Thoughts

-FORTRAN isn't unique Everything FORTRAN does can also be done

by more powerful languages, starting with C

- FORTRAN is fast with mathematics, but Moore's Law is faster

-FORTRAN was an important step in programming languages,

but it now only caters to the niche market of High Performance Computing

Trang 18

http://www.ibiblio.org/pub/languages/fortran/ch1-8.html

http://www.lahey.com/lookat90.htm

http://chronicle.com/blogs/wiredcampus/supercomputers-often-run-outdated-software/8184 http://en.wikipedia.org/wiki/Row-major_order

http://fortran.com/

Ngày đăng: 24/10/2014, 21:24

TỪ KHÓA LIÊN QUAN