| 查看: 3508 | 回復(fù): 11 | ||
[求助]
fortran編譯 read出錯(cuò) 完畢
|
|
錯(cuò)誤提示 POSITION.F(31): error #6358: Constants and expressions are invalid in read-only I/O lists. [MSP] read(15,*) (msp(i),i=1,10) 前面msp有定義 character msp(10) read(15,*) (msp(i),i=1,10) 語(yǔ)法有問題嗎? 一下是全部程序 program getpos ccccccccc 12 is SPPARKS OUTPUT cccccccc ccccccccc 15 is the molecure ccccccccc ccccccccc 13 is OUTPUT ccccccccccc integer mnum nsp real coord(2000,3) real species(10,3) integer nsp(10) real x y z character tile cellp cella cellb cellz msp(10) open(12,file='POSCAR',status='old') open(15,file='POSCAR',status='old') open(13,file='CONTCAR',status='new') ccccccccccccccccccc sys param a b c cccccccccccccc read(12,*) tile write(13,*) tile read(12,*) cellp write(13,*) cellp read(12,*) cella ; write(13,*) cella read(12,*) cellb ; write(13,*) cellb read(12,*) cellc ; write(13,*) cellc read(15,*); read(15,*); read(15,*); read(15,*); read(15,*); cccccccccccccccccccc atom char ccccccccccccccccccccccc read(15,*) (msp(i),i=1,10) write(13,*) (msp(i),i=1,10) read(12,*); cccccccccccccccccccc atom num cccccccccccccccccccccccc read(12,*) mnum read(15,*) (nsp(i),i=1,10) DO i=1, 10 N_anum=mnum*nsp(i) write(13,N_anum) END DO read(12,*) read(15,*) write(13,*) 'R' cccccccccccccccc read molecue coord cccccccccccc DO i=1, mnum read(12,*) (coord(i,j),j=1,13) ENDDO close(12) cc DO j=1, 10 !!! species cyc !!!!!! DO i=1, nsp(j) !!! the j atom cyc !!!!!! read(15,*) x y z !!!!!!!!!!!!!!!!!!!!!!!! molecure coord !!!!!!!!!!!!! DO k=1, mnum nx=x+coord(k,1) ny=y+coord(k,2) nz=z+coord(k,3) write(13,*) nx ,ny ,nz ENDDO ENDDO ENDDO close(15) close(13) END [ Last edited by 賀儀 on 2011-8-23 at 14:53 ] |

至尊木蟲 (職業(yè)作家)
至尊木蟲 (職業(yè)作家)

至尊木蟲 (職業(yè)作家)
|
是的 錯(cuò)誤很多 這是最開始的 現(xiàn)在調(diào)好了,程序如下: program getpos ccccccccc 12 is SPPARKS OUTPUT cccccccc ccccccccc 15 is the molecure ccccccccc ccccccccc 13 is OUTPUT ccccccccccc integer mnum Nanum real::coord(2000,3) integer::nsp(4) real x y z character tile cellp character::msp(4) real::cella(3) real::cellb(3) real::cellc(3) open(12,file='POSCARS',status='old') open(15,file='POSCARV',status='old') open(13,file='CONTCAR',status='new') ccccccccccccccccccc sys param a b c cccccccccccccc read(12,*) tile write(13,"(2XA10)" tileread(12,*) cellp write(13,*) cellp read(12,*) (cella(i),i=1,3) write(13,"(3(2XF10.7))" (cella(i),i=1,3)read(12,*) (cellb(i),i=1,3) write(13,"(3(2XF10.7))" (cellb(i),i=1,3)read(12,*) (cellc(i),i=1,3) write(13,"(3(2XF10.7))" (cellc(i),i=1,3)read(15,*) read(15,*) read(15,*) read(15,*) read(15,*) cccccccccccccccccccc atom char ccccccccccccccccccccccc read(15,*) (msp(i),i=1,4) write(13,"(4(2XA2))" (msp(i),i=1,4)read(12,*) cccccccccccccccccccc atom num cccccccccccccccccccccccc read(12,*) mnum read(15,*) (nsp(i),i=1,4) DO i=1, 4 Nanum=mnum*nsp(i) write(13,10) Nanum END DO read(12,*) read(15,*) write(13,"(/,A1)" 'D'DO i=1, mnum read(12,*) (coord(i,j),j=1,3) END DO close(12) cc DO j=1, 4 !!! species cyc !!!!!! DO i=1, nsp(j) !!! the j species atom cyc !!!!!! read(15,*) x, y, z !!!!!!!!!!!!!!!!!!!!!!!! molecure coord !!!!!!!!!!!!! DO k=1, mnum write(13,100) x+coord(k,1), y+coord(k,2), z+coord(k,3) END DO END DO END DO close(15) close(13) 10 FORMAT(2XI5.0,\) 100 FORMAT(3(2XF10.6)) END |

至尊木蟲 (職業(yè)作家)

至尊木蟲 (職業(yè)作家)
|
你運(yùn)行一下看看得到的結(jié)果是不是你想要的,呵呵…… 在 Fortran 中,像 real x y z 這樣的語(yǔ)句,你本來(lái)聲名了三個(gè)變量,但編譯之后是一個(gè)變量 xyz。你或許會(huì)說(shuō),為什么沒有報(bào)錯(cuò),你試著在 program 那句之后加一句 implicit none 看看…… |

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 278求調(diào)劑 +5 | 煙火先于春 2026-03-17 | 5/250 |
|
|---|---|---|---|---|
|
[考博] 環(huán)境領(lǐng)域全國(guó)重點(diǎn)實(shí)驗(yàn)室招收博士1-2名 +3 | QGZDSYS 2026-03-13 | 3/150 |
|
|
[考博] 26博士申請(qǐng) +3 | 1042136743 2026-03-17 | 3/150 |
|
|
[考研] 303求調(diào)劑 +3 | 睿08 2026-03-17 | 5/250 |
|
|
[考研] 328求調(diào)劑,英語(yǔ)六級(jí)551,有科研經(jīng)歷 +3 | 生物工程調(diào)劑 2026-03-16 | 8/400 |
|
|
[考研] 301求調(diào)劑 +4 | A_JiXing 2026-03-16 | 4/200 |
|
|
[考研] 344求調(diào)劑 +4 | knight344 2026-03-16 | 4/200 |
|
|
[考研] 本人考085602 化學(xué)工程 專碩 +16 | 不知道叫什么! 2026-03-15 | 18/900 |
|
|
[考研] 332求調(diào)劑 +6 | Zz版 2026-03-13 | 6/300 |
|
|
[考研] 289求調(diào)劑 +6 | 步川酷紫123 2026-03-11 | 6/300 |
|
|
[考研]
|
zhouzhen654 2026-03-16 | 3/150 |
|
|
[考研] 266求調(diào)劑 +4 | 學(xué)員97LZgn 2026-03-13 | 4/200 |
|
|
[基金申請(qǐng)]
有必要更換申報(bào)口嗎
20+3
|
fannyamoy 2026-03-11 | 3/150 |
|
|
[考研] [0860]321分求調(diào)劑,ab區(qū)皆可 +4 | 寶貴熱 2026-03-13 | 4/200 |
|
|
[考研] (081700)化學(xué)工程與技術(shù)-298分求調(diào)劑 +12 | 11啦啦啦 2026-03-11 | 35/1750 |
|
|
[碩博家園] 085600 260分求調(diào)劑 +3 | 天空還下雨么 2026-03-13 | 5/250 |
|
|
[考研] 274求調(diào)劑 +3 | S.H1 2026-03-12 | 3/150 |
|
|
[考研] 277求調(diào)劑 +4 | anchor17 2026-03-12 | 4/200 |
|
|
[考研] 283求調(diào)劑,材料、化工皆可 +8 | 蘇打水7777 2026-03-11 | 10/500 |
|
|
[考博] 26讀博 +4 | Rui135246 2026-03-12 | 10/500 |
|