1 / 14

Fortran – Input / Output (1)

Fortran – Input / Output (1). Instructor: Heng - Kwong Tsao, Professor. 電腦演進. 西元 1946 年 賓州大學的 John. W. Mauchly 和 J. Presper Eckert, Jr. 製造了第一部以 真空管 (vacuum tube) 為基礎元件的計算機,稱為 ENIAC (Electronic Numerical Integrator and Computer) 。

ronnie
Download Presentation

Fortran – Input / Output (1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fortran – Input / Output (1) Instructor: Heng - Kwong Tsao, Professor

  2. 電腦演進 西元1946年 賓州大學的John. W. Mauchly 和 J. Presper Eckert, Jr.製造了第一部以 真空管(vacuum tube) 為基礎元件的計算機,稱為 ENIAC (Electronic Numerical Integrator and Computer) 。 Its first use was in calculations for the hydrogen bomb. 西元1952年 傑出女性資訊學家 Grace Murray Hopper 設計了第一個編譯器(compiler) 。 (編譯器是用來將程式語言所寫的程式轉換成電腦可執行的0與1列) 西元1959年 Honeywell公司推出以電晶體(transistor)為基礎元件的計算機,稱為Honeywell 400,這也是第二代電腦(電晶體時期)的代表作。 西元1971年 美國Intel設計出第一個4004微處理器後,開始了微處理器的使用。微處理器是把許多積體電路濃縮在一小片微晶片(microchip)上,屬於超大型積體電路(very large-scale integration,簡稱VLSI)。

  3. Grace Hopper (December 9, 1906 – January 1, 1992) Rear Admiral Grace Murray Hopper was an American computer scientist and United States Naval officer. Because of the breadth of her accomplishments and her naval rank, she is sometimes referred to as "Amazing Grace". The U.S. Navy destroyer USS Hopper (DDG-70) was named for her. Hopper was born Grace Brewster Murray in New York City. She graduated Phi Beta Kappa from Vassar College with a bachelor's degree in mathematics and physics in 1928 and pursued her graduate education at Yale University, where she received a Master's degree in those subjects in 1930. In 1934, she earned a Ph.D. in mathematics from Yale. Hopper began teaching mathematics at Vassar in 1931, and by 1941 she was an associate professor. She and Dr. Vincent Hopper divorced in 1945. In 1943, Hopper obtained a leave of absence from Vassar and was sworn in to the United States Navy Reserve, one of many women to volunteer to serve in the WAVES. "Women Accepted for Volunteer Emergency Service"

  4. 電腦週邊架構 1. Memory (記憶體) 2. Arithmetic Logic Unit; ALU (算數邏輯單元) 3. Control Unit (控制單元) 4. Input / Output (輸入/ 輸出) Central Processing Unit 中央處理器(CPU)

  5. 程式語言的分類 • 機器語言(Machine language): 機器語言是電腦可以直接執行的語言,它的指令是由一連串0 與1 所組合排列而成。 Ex: 11001 00110 00111 01101 • 組合語言(Assembly language): 由於機械語言程式不容易被程式設計師辨認及記憶,將指令碼改以簡單的英文縮寫或符號來編寫程式,此種程式語言被稱為組合語言。 Ex: 00110 M, 00111 N, 01101 T • 高階語言(High-leveI Language): 低階語言的學習,在人類學習及使用上都不方便。因此發展出一些比較接近人類日常生活用語的程式語言,這就是高階語言。 Ex: Fortran、Matlab

  6. 編譯器的角色 高階語言程式 編譯器(Compiler) 電腦執行 機械語言 組合語言程式

  7. Fortran語 法 說 明 open(unit=n,file=‘ok.txt’) : 產生一個名為ok的文件檔並編號為 n (n不可為5,6) output write(*,*) “fortran”: 將 fortran 字串輸出在螢幕上(此時*的預設值為 6=螢幕) write(n,*) “fortran”: 將 fortran 字串 輸出在編號n文字檔內 Input read(*,*):讀取(輸入)鍵盤的資料, (此時 *的預設值為 5=鍵盤) read(n,*) number:讀取(輸入)編號n文字檔內資料

  8. Practice1: Input 每行開頭空六格 program practice1 open(unit=1,file=‘p1.txt') write(*,*) "Hello" write(1,*) "Learning Fortran is fun!“ end

  9. Window System: Note pad DOS System: Compiler ren: rename test.txt test.f dir: directory (showing files) cd: change directory a.exe : executable file g95 ***.f  a.exe

  10. Practice2: Output program practice2 integer a open(unit=2,file=‘p2.txt') write(*,*)“How tall are you? (cm)" read(5,*) a write(6,*)“You are" ,a, ”cm” write(2,*)“You are" ,a, “cm” end 輸入位置為5(鍵盤),可用*代替 輸出位置為6(螢幕),可用*代替

  11. Homework program HW1 open(unit=2,file=‘hw1.txt') write(*,*) "My student ID.=????????" write(2,*) "My student ID.=????????" end

  12. Homework program HW2 integer a open(unit=1,file=‘hw2.txt') write(*,*)"Please input your student ID?" read(*,*) a write(*,*)"My student ID is" ,a write(1,*)"My student ID is" ,a end

  13. Homework HW3 請撰寫一個程式,詢問並回答 1.學號 2.生日(ex.20090101) 顯示在螢幕以及儲存在文字檔(hw3.txt)中

More Related