| 查看: 2786 | 回復(fù): 17 | ||
[求助]
編一個fortran程序
|
|
需要一個fortran程序,比較簡單的那種,例如f=((5x+6z)*e^(2i) )/(2x-z),其中z=(3y-1)*(x+2) 要求輸出的結(jié)果是三列數(shù)據(jù),分別對應(yīng)x,y,f .并且每列有20個數(shù)。 這三組數(shù)據(jù)是要導(dǎo)入orgin中進行圖像模擬的。 初學(xué)fortran,很多東西還不連貫。 請大師們對上面給的式子編個程序示范一下。 |


|
運行不了啊,提示有11個錯。我用的是fortran90. 下面這些是顯示的錯誤: --------------------Configuration: Textxcx - Win32 Debug-------------------- Compiling Fortran... C:\Users\Administrator\Desktop\Textxcx.for C:\Users\Administrator\Desktop\Textxcx.for(6) : Error: Syntax error, found IDENTIFIER 'X' when expecting one of: ( % . = => input (*,*) x,y -------------------^ C:\Users\Administrator\Desktop\Textxcx.for(10) : Error: Syntax error, found INTEGER_CONSTANT '20' when expecting one of: <END-OF-STATEMENT> ; <IDENTIFIER> do 2 1,20 -------------^ C:\Users\Administrator\Desktop\Textxcx.for(11) : Error: Syntax error, found IDENTIFIER 'Y' when expecting one of: * :: , <END-OF-STATEMENT> ; : ) (/ [ + - . ] /) ** / > // .LT. < ... z=(3y(i)-1)*(x(i)+2) ----------^ C:\Users\Administrator\Desktop\Textxcx.for(12) : Error: Unrecognized token '^' skipped f=((5x+6z)*e^(2i) )/(2x-z) ------------------^ C:\Users\Administrator\Desktop\Textxcx.for(12) : Error: Syntax error, found IDENTIFIER 'X' when expecting one of: * :: , <END-OF-STATEMENT> ; : ) (/ [ + - . ] /) ** / > // .LT. < ... f=((5x+6z)*e^(2i) )/(2x-z) -----------^ C:\Users\Administrator\Desktop\Textxcx.for(3) : Error: A specification statement cannot appear in the executable section. parameter(i=(0,1)) ------^ C:\Users\Administrator\Desktop\Textxcx.for(4) : Error: A specification statement cannot appear in the executable section. complex*16 x,y,z,x(20),y(20) --------^ C:\Users\Administrator\Desktop\Textxcx.for(7) : Error: This name has not been declared as an array. [X] x(i)=x ------^ C:\Users\Administrator\Desktop\Textxcx.for(8) : Error: This name has not been declared as an array. [Y] y(i)=y ------^ C:\Users\Administrator\Desktop\Textxcx.for(10) : Error: An unterminated block exists. do 2 1,20 ^ C:\Users\Administrator\Desktop\Textxcx.for(10) : Error: This label is undefined. [21] do 2 1,20 ---------^ Error executing df.exe. Textxcx.exe - 11 error(s), 0 warning(s) |
|
抱歉 之前寫得太著急了 所以獻丑啦 哈哈 parameter(n=20) integer k real*8 x1,x2,y1,y2 complex*16 z,x(n),y(n),i,f open(10,file='data.dat',status='unknown') i=(0,1) do 1 k=1,20 print*, "insert xr,","xi,","yr,","yi" read*, x1,x2,y1,y2 x(k)=cmplx(x1,x2) y(k)=cmplx(y1,y2) 1 continue do 2 k=1,20 z=(3*y(k)-1)*(x(k)+2) f=((5*x(k)+6*z)*zexp(2*i))/(2*x(k)-z) write(*,*) x(k),y(k),f write(10,*) x(k),y(k),f 2 continue pause end 以上 fortran77測試后可用 x,y的輸入是鍵盤輸入 |



| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研]
|
pk3725069 2026-03-19 | 14/700 |
|
|---|---|---|---|---|
|
[考研] 276求調(diào)劑。有半年電池和半年高分子實習(xí)經(jīng)歷 +8 | 材料學(xué)257求調(diào)劑 2026-03-23 | 9/450 |
|
|
[考研] 307求調(diào)劑 +3 | 余意卿 2026-03-21 | 3/150 |
|
|
[考研] 085600材料與化工 +10 | 安全上岸! 2026-03-16 | 10/500 |
|
|
[考研] 070300,一志愿北航320求調(diào)劑 +3 | Jerry0216 2026-03-22 | 5/250 |
|
|
[考研] 環(huán)境學(xué)碩288求調(diào)劑 +6 | 皮皮皮123456 2026-03-22 | 6/300 |
|
|
[考研] 尋找調(diào)劑 +4 | 倔強芒? 2026-03-21 | 4/200 |
|
|
[考研] 298求調(diào)劑一志愿211 +3 | 上岸6666@ 2026-03-20 | 3/150 |
|
|
[考研] 生物學(xué)調(diào)劑 +5 | Surekei 2026-03-21 | 5/250 |
|
|
[考研] 303求調(diào)劑 +5 | 安憶靈 2026-03-22 | 6/300 |
|
|
[考研] 求調(diào)劑 +7 | Auroracx 2026-03-22 | 7/350 |
|
|
[考研] 330求調(diào)劑0854 +3 | assdll 2026-03-21 | 3/150 |
|
|
[考研] 一志愿天津大學(xué)化學(xué)工藝專業(yè)(081702)315分求調(diào)劑 +12 | yangfz 2026-03-17 | 12/600 |
|
|
[考研] 化學(xué)求調(diào)劑 +4 | 臨澤境llllll 2026-03-17 | 5/250 |
|
|
[考研] 材料專業(yè)求調(diào)劑 +6 | hanamiko 2026-03-18 | 6/300 |
|
|
[考研] 308求調(diào)劑 +3 | 阿姐阿姐家啊 2026-03-18 | 3/150 |
|
|
[考研] 321求調(diào)劑 +9 | 何潤采123 2026-03-18 | 11/550 |
|
|
[考研] 一志愿南理工085701環(huán)境302求調(diào)劑院校 +3 | 葵梓衛(wèi)隊 2026-03-20 | 3/150 |
|
|
[考研]
|
不想起名字112 2026-03-19 | 3/150 |
|
|
[考研] 085600材料與化工求調(diào)劑 +6 | 緒幸與子 2026-03-17 | 6/300 |
|