ME1107%20Computing%201 - PowerPoint PPT Presentation

About This Presentation
Title:

ME1107%20Computing%201

Description:

High level computer language. Basic, Fortran, C, C , ... rad. Output. rad. end. deg and rad are two variables, which are the names given to two memory locations ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 11
Provided by: yyan
Category:

less

Transcript and Presenter's Notes

Title: ME1107%20Computing%201


1
  • ME1107 Computing 1
  • 2007-2008
  • Y Yan
  • http//www.staff.city.ac.uk/ensyy

2
About Fortran
  • Fortran Formula Translation
  • High level computer language
  • Basic, Fortran, C, C, Java, C,Matlab
  • What do we learn?
  • basic programming skills
  • self-learning skills
  • References
  • Text book (Fortran 77 for Engineers)
  • Online notes (course website)

3
Creating Executable Code
  • Building a solution combines compiling and
    linking into one action
  • The .f95 extension is vital!

4
Fortran Programming Environment
  • Salford Plato, Integrated Development Environment
    (IDE), is used for Fortran programming
  • Create a folder for Fortran programs
  • Copy three files including salflibc.dll to the
    Fortran folder (those files should be always kept
    in the folder for Fortran programs)
  • Start Salford
  • Start -gt programs -gt F. Departmental software -gt
    B. Engineering mathematics -gt Fortran 95 -gt
    Salford Plato IDE

Getting Started
5
Exercise 1 Your first Fortran program
  • !
  • ! Your name, Group
  • ! Date
  • !
  • ! Hello World
  • Program Prog1
  • Print ,Hello World
  • Print , your name
  • End Prog1

6
Exercise 2 Run the quadratic equation solver
7
Variable types
  • Declaration of variables are not compulsory
  • Without declarations
  • I, J, K, L, M, N are integer type
  • the rest are real type
  • IMPLICITY NONE
  • all variables must be declared

8
Output statement
  • The syntax of output statement
  • WRITE (output_device, format, options) list
  • PRINT format, list (standard output device,
    usually the screen)
  • Print ,Hello World
  • Print , your name
  • Print ,Input A, B, C
  • Print , Roots are , ROOT1, ROOT2
  • Write(,) Roots are , ROOT1, ROOT2

9
Input statement
  • The syntax of input statement
  • READ (input_device, format, options)
    list_of_variables
  • READ format, list_of_variables (standard input
    device, usually the keyboard)
  • Print ,Input A, B, C
  • Read , A, B, C
  • Read(,) A, B, C

10
Exercise 3. Write a program for this flowchart
start
Input deg
deg and rad are two variables, which are the
names given to two memory locations for storing
data.
Calculate rad
Output rad
end
Write a Comment
User Comments (0)
About PowerShow.com