没有合适的资源?快使用搜索试试~ 我知道了~
电子书 Introduction to Programming using Fortran 95/2003/2008
需积分: 1 0 下载量 155 浏览量
2023-10-10
14:09:58
上传
评论
收藏 1.95MB PDF 举报
温馨提示
试读
237页
Introduction to Programming using Fortran 95/2003/2008 本文介绍了使用Fortran 95/2003/2008编程语言进行编程和解决问题的方法。本简介适用于非计算机科学专业。因此,本文不是Fortran 95/2003/2008编程语言的完整、全面的指南。主要关注的是问题解决和算法开发的介绍。因此,Fortran 95/2203/2008语言的许多细节都被省略了。 This text provides an introduction to programming and problem solving using the Fortran 95/2003/2008 programming language. This introduction is geared for non computer science majors. As such, this text is not a complete, comprehensive guide to the Fortran 95/2003/2008 programming languag
资源推荐
资源详情
资源评论
Introduction to
Programming
using
Fortran 95/2003/2008
Ed Jorgensen
March 2018
Version 3.0.51
Cover Diagram
The cover image is the plotted output from the chaos game program from chapter 11.
The image was plotted with GNUplot.
Copyright
Ed Jorgensen 2013, 2014, 2015, 2016, 2017, 2018
You are free:
• to Share — to copy, distribute and transmit the work
• to Remix — to adapt the work
Under the following conditions:
• Attribution. You must attribute the work to “Introduction to Programming using Fortran
95/2003/2008” (but not in any way that suggests that the author endorses you or your
use of the work).
• Share Alike. If you alter, transform, or build upon this work, you may distribute the
resulting work only under the same, similar or a compatible license.
For any reuse or distribution, you must make clear to others the license terms of this work. The
best way to do this is with a link to
• http://creativecommons.org/licenses/by-sa/3.0/
Any of the above conditions can be waived if you get permission from the copyright holder.
Nothing in this license impairs or restricts the author's moral rights.
ii
Table of Contents
1 Introduction...................................................................................................................................... 1
1.1 Why Learn Programming........................................................................................................... 1
1.2 Fortran........................................................................................................................................ 1
1.3 Complete Fortran 95/2003/2008 Documentation....................................................................... 1
1.4 What Is A Program..................................................................................................................... 2
1.5 Operating System....................................................................................................................... 2
2 Computer Organization................................................................................................................... 3
2.1 Architecture Overview............................................................................................................... 3
2.2 Compiler..................................................................................................................................... 4
2.3 Information Representation........................................................................................................ 4
2.3.1 Decimal Numbers............................................................................................................... 4
2.3.2 Binary Numbers.................................................................................................................. 5
2.3.3 Character Representation.................................................................................................... 5
2.4 Exercises..................................................................................................................................... 5
2.4.1 Quiz Questions.................................................................................................................... 5
3 Getting Started................................................................................................................................. 7
3.1 Required Skills........................................................................................................................... 7
3.2 Program Formats........................................................................................................................ 7
3.2.1 Program Statement.............................................................................................................. 7
3.2.2 Comments........................................................................................................................... 8
3.2.3 Simple Output..................................................................................................................... 8
3.2.4 Example – First Program.................................................................................................... 8
3.3 Text Editor.................................................................................................................................. 8
3.4 Compiling................................................................................................................................... 9
3.4.1 Advanced Compiler Options............................................................................................... 9
3.5 Executing.................................................................................................................................... 9
3.6 Exercises................................................................................................................................... 10
3.6.1 Quiz Questions.................................................................................................................. 10
3.6.2 Suggested Projects............................................................................................................ 11
4 Fortran 95/2003/2008 – Basic Elements....................................................................................... 13
4.1 Variables................................................................................................................................... 13
4.1.1 Variable Names................................................................................................................. 13
4.1.2 Keywords.......................................................................................................................... 14
4.2 Data Types................................................................................................................................ 14
4.2.1 Integer............................................................................................................................... 14
4.2.2 Real................................................................................................................................... 15
4.2.3 Complex............................................................................................................................ 15
4.2.4 Character........................................................................................................................... 15
4.2.5 Logical.............................................................................................................................. 15
4.2.6 Historical Data Typing...................................................................................................... 15
4.3 Declarations.............................................................................................................................. 16
iii
4.3.1 Declaring Variables........................................................................................................... 16
4.3.2 Variable Ranges................................................................................................................ 16
4.3.3 Type Checking.................................................................................................................. 16
4.3.4 Initialization...................................................................................................................... 17
4.3.5 Constants.......................................................................................................................... 17
4.4 Comments................................................................................................................................. 17
4.5 Continuation Lines................................................................................................................... 18
4.5.1 Example............................................................................................................................ 18
4.6 Declarations, Extended Size Variables..................................................................................... 18
4.6.1 Integers............................................................................................................................. 19
4.6.2 Real................................................................................................................................... 19
4.7 Exercises................................................................................................................................... 19
4.7.1 Quiz Questions.................................................................................................................. 19
4.7.2 Suggested Projects............................................................................................................ 20
5 Expressions..................................................................................................................................... 21
5.1 Literals...................................................................................................................................... 21
5.1.1 Integer Literals.................................................................................................................. 21
5.1.2 Real Literals...................................................................................................................... 21
5.1.2.1 E-Notation................................................................................................................. 21
5.1.3 Complex Literals.............................................................................................................. 22
5.1.4 Character Literals.............................................................................................................. 22
5.1.5 Logical Constants............................................................................................................. 23
5.2 Arithmetic Operations.............................................................................................................. 23
5.2.1 Assignment....................................................................................................................... 23
5.2.2 Addition............................................................................................................................ 23
5.2.3 Subtraction........................................................................................................................ 24
5.2.4 Multiplication................................................................................................................... 24
5.2.5 Division............................................................................................................................ 24
5.2.6 Exponentiation.................................................................................................................. 25
5.3 Order of Operations.................................................................................................................. 25
5.4 Intrinsic Functions.................................................................................................................... 26
5.4.1 Mathematical Intrinsic Functions..................................................................................... 26
5.4.2 Conversion Functions....................................................................................................... 26
5.4.3 Summary........................................................................................................................... 27
5.5 Mixed Mode............................................................................................................................. 27
5.6 Examples.................................................................................................................................. 28
5.7 Exercises................................................................................................................................... 28
5.7.1 Quiz Questions.................................................................................................................. 28
5.7.2 Suggested Projects............................................................................................................ 29
6 Simple Input and Output.............................................................................................................. 31
6.1 Output – Write.......................................................................................................................... 31
6.1.1 Output – Print................................................................................................................... 32
6.2 Input – Read............................................................................................................................. 32
6.3 Example.................................................................................................................................... 33
6.4 Exercises................................................................................................................................... 34
iv
6.4.1 Quiz Questions.................................................................................................................. 34
6.4.2 Suggested Projects............................................................................................................ 34
7 Program Development................................................................................................................... 37
7.1 Understand the Problem........................................................................................................... 37
7.2 Create the Algorithm................................................................................................................ 38
7.3 Implement the Program............................................................................................................ 38
7.4 Test/Debug the Program........................................................................................................... 39
7.4.1 Error Terminology............................................................................................................ 40
7.4.1.1 Compiler Error.......................................................................................................... 40
7.4.1.2 Run-time Error.......................................................................................................... 40
7.4.1.3 Logic Error................................................................................................................ 41
7.5 Exercises................................................................................................................................... 42
7.5.1 Quiz Questions.................................................................................................................. 42
7.5.2 Suggested Projects............................................................................................................ 42
8 Selection Statements...................................................................................................................... 43
8.1 Conditional Expressions........................................................................................................... 43
8.2 Logical Operators..................................................................................................................... 44
8.3 IF Statements............................................................................................................................ 44
8.3.1 IF THEN Statement.......................................................................................................... 45
8.3.1.1 IF THEN Statement, Simple Form........................................................................... 45
8.3.2 IF THEN ELSE Statement................................................................................................ 45
8.3.3 IF THEN ELSE IF Statement........................................................................................... 46
8.4 Example One............................................................................................................................ 47
8.4.1 Understand the Problem................................................................................................... 47
8.4.2 Create the Algorithm......................................................................................................... 48
8.4.3 Implement the Program.................................................................................................... 49
8.4.4 Test/Debug the Program................................................................................................... 50
8.5 SELECT CASE Statement....................................................................................................... 50
8.6 Example Two............................................................................................................................ 53
8.6.1 Understand the Problem................................................................................................... 53
8.6.2 Create the Algorithm......................................................................................................... 53
8.6.3 Implement the Program.................................................................................................... 53
8.6.4 Test/Debug the Program................................................................................................... 54
8.7 Exercises................................................................................................................................... 55
8.7.1 Quiz Questions.................................................................................................................. 55
8.7.2 Suggested Projects............................................................................................................ 56
9 Looping........................................................................................................................................... 59
9.1 Counter Controlled Looping.................................................................................................... 59
9.2 EXIT and CYCLE Statements.................................................................................................. 61
9.3 Counter Controlled Example.................................................................................................... 61
9.3.1 Understand the Problem................................................................................................... 62
9.3.2 Create the Algorithm......................................................................................................... 62
9.3.3 Implement the Program.................................................................................................... 62
9.3.4 Test/Debug the Program................................................................................................... 63
v
剩余236页未读,继续阅读
资源评论
汪宁宇
- 粉丝: 752
- 资源: 42
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功