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

beginning fortran slide

29 214 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 29
Dung lượng 1,12 MB

Nội dung

Beginning Fortran Introduction 13 October 2009 *Black text on white background provided for easy printing What is Fortran? • One of the oldest programming languages still in use • Fortran77, Fortran90 • Used primarily by geophysical sciences: – Good at math and manipulation of large data sets – Consistent with earliest NWP models I program in Fortran… I program in Fortran… … … Why Learn It? • If you are pursuing a graduate degree in AOS, you will eventually run into Fortran: – An assignment – A research problem – Someone else’s code* *THIS is why commenting code is so important (later on that) Your Typical Program c234567 PROGRAM MYPROGRAM STOP END Program Options Program Options Declaration of Variables Declaration of Variables MAIN CODE MAIN CODE Your Typical Program c234567 PROGRAM MYPROGRAM STOP END Program Options Program Options Declaration of Variables Declaration of Variables MAIN CODE MAIN CODE The first seven columns of the program code are reserved for special functions – most lines of code begin on the seventh column Your Typical Program c234567 PROGRAM MYPROGRAM STOP END Program Options Program Options Declaration of Variables Declaration of Variables MAIN CODE MAIN CODE This line identifies the code as a program (instead of, say, a subroutine) and gives it the name MYPROGRAM. Your Typical Program c234567 PROGRAM MYPROGRAM STOP END Program Options Program Options Declaration of Variables Declaration of Variables MAIN CODE MAIN CODE All variables used in the code have to be declared at the top, before any of the main code is run. Your Typical Program c234567 PROGRAM MYPROGRAM STOP END Program Options Program Options Declaration of Variables Declaration of Variables MAIN CODE MAIN CODE Here is where the magic happens. [...]... going on – these are called “comments” Code sees this identifier as “comment” and For i = 1, 4 Skips it c c I’m looping over the first index of VALUES here c In The Next Few Weeks • • • • • • • Fortran – Basics Fortran – “Advanced” Matlab 1 Matlab 2 Matlab 3 IDL 1 IDL 2 ... Declaration of Variables MAIN CODE CALL MYSUBROUTINE MAIN CODE RETURN END A More Complicated Program Being able to trace the flow of information is by far the most important thing to learn about programming, in Fortran or in any other language You will eventually have to write code that is not only able to perform complicated functions, but is readable to someone else who wishes to use it PROGRAM MYPROGRAM Options . Beginning Fortran Introduction 13 October 2009 *Black text on white background provided for easy printing What is Fortran? • One of the oldest programming languages still in use • Fortran7 7,. use • Fortran7 7, Fortran9 0 • Used primarily by geophysical sciences: – Good at math and manipulation of large data sets – Consistent with earliest NWP models I program in Fortran I program in Fortran … … Why. Fortran … … Why Learn It? • If you are pursuing a graduate degree in AOS, you will eventually run into Fortran: – An assignment – A research problem – Someone else’s code* *THIS is why commenting code

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