1 / 4

應用電腦

應用電腦. (Applied Computer Science). 授課老師 : 游政谷. ComputerScience(3). 寫作 Fortran 的格式. 第 1~5 格只能空白或是阿拉伯數字 第 1 格如為英文字母 C 則表示那一行為註解 , 編譯器不會編譯此行的程式碼 第 6 格只能是空白或是零以外的任何字元 ( 用來表示接續上一行的程式 ) 第 73 格之後則不使用. Program example ( 程式開始 ) ….. ….. ….. ….. Stop ( 程式結束 )

doctor
Download Presentation

應用電腦

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. 應用電腦 (Applied Computer Science) 授課老師: 游政谷 ComputerScience(3)

  2. 寫作Fortran的格式 第1~5格只能空白或是阿拉伯數字 第1格如為英文字母C則表示那一行為註解, 編譯器不會編譯此行的程式碼 第6格只能是空白或是零以外的任何字元(用來表示接續上一行的程式) 第73格之後則不使用 Program example (程式開始) ….. ….. ….. ….. Stop (程式結束) End (程式敘述完畢) 程式主體 See example1 for explanation 第7格到72格為程式寫作範圍

  3. Example1 c this program is to calculate some thermodynamic parameters as you inputc pressure, temperature and dew point program example1 real pre,t,td,w,tv es(tt)=6.112*exp(17.67*tt/(tt+243.5)) write(6,*)'input pressure(mb),temperature(c),td(c)--real' read(5,*)pre,t,td w=0.622*es(td)/(pre-es(td)) ws=0.622*es(t)/(pre-es(t)) tv=(t+273.15)*(1.+0.61*w) den=pre*100./287./tv theta=(t+273.15)*(1000./pre)**(287./1005.) thetav=tv*(1000./pre)**(287./1005.) call get_ept(t,pre,td,oept) write(6,*)'P=',pre,' T=',t,' Td=',td,' mixing ratio=',w,' Tv=',tv + ,' thetav=',thetav,‘ saturated mixing ratio=',ws write(6,*)' theta=',theta, ‘ ept=', oept, ‘ density=',den stop end 程式主體

  4. Fortran 的資料型態 • 整數 (integer) 2345, 126 • 浮點數 (real) 3.45, 78.654 • 複數 (complex) a+bi • 字元 (character) hou, no, h, 23 • 邏輯判斷 (true或是false) Fortran 的數學運算式 • + 加法 計算的優先順序: • 減法 (1) ( ) 括號中的算式 • * 乘法 (2) ** • / 除法 (3) * / • ** 乘冪, 次方 (4) + - • ( ) 括號起來的部分優先計算 EX: A = 2**3 + 3*(4/2) = 14

More Related