| 查看: 3512 | 回復(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ǔ)法有問(wèn)題嗎? 一下是全部程序 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ō),為什么沒(méi)有報(bào)錯(cuò),你試著在 program 那句之后加一句 implicit none 看看…… |

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 【0703化學(xué)調(diào)劑】-一志愿華中師范大學(xué)-六級(jí)475 +6 | Becho359 2026-03-11 | 6/300 |
|
|---|---|---|---|---|
|
[考研] 0817 化學(xué)工程 299分求調(diào)劑 有科研經(jīng)歷 有二區(qū)文章 +3 | rare12345 2026-03-18 | 3/150 |
|
|
[考研] 303求調(diào)劑 +4 | 睿08 2026-03-17 | 6/300 |
|
|
[考研] 一志愿中國(guó)海洋大學(xué),生物學(xué),301分,求調(diào)劑 +3 | 1孫悟空 2026-03-17 | 3/150 |
|
|
[考研] 268求調(diào)劑 +7 | 好運(yùn)連綿不絕 2026-03-12 | 8/400 |
|
|
[考研] 材料與化工求調(diào)劑 +6 | 為學(xué)666 2026-03-16 | 6/300 |
|
|
[考研] 考研化學(xué)學(xué)碩調(diào)劑,一志愿985 +4 | 張vvvv 2026-03-15 | 6/300 |
|
|
[考研] 一志愿南京大學(xué),080500材料科學(xué)與工程,調(diào)劑 +4 | Jy? 2026-03-16 | 4/200 |
|
|
[考研] 材料專碩274一志愿陜西師范大學(xué)求調(diào)劑 +5 | 薛云鵬 2026-03-13 | 5/250 |
|
|
[考研] 一志愿,福州大學(xué)材料專碩339分求調(diào)劑 +3 | 木子momo青爭(zhēng) 2026-03-15 | 3/150 |
|
|
[考研] 283求調(diào)劑 +3 | 聽風(fēng)就是雨; 2026-03-16 | 3/150 |
|
|
[考研]
|
zhouzhen654 2026-03-16 | 3/150 |
|
|
[考研] 東南大學(xué)364求調(diào)劑 +5 | JasonYuiui 2026-03-15 | 5/250 |
|
|
[考研] 327求調(diào)劑 +6 | 拾光任染 2026-03-15 | 11/550 |
|
|
[考研] 265求調(diào)劑 +4 | 威化餅07 2026-03-12 | 4/200 |
|
|
[考研] 297求調(diào)劑 +4 | 學(xué)海漂泊 2026-03-13 | 4/200 |
|
|
[考研] 四川大學(xué)085601材料工程專碩 初試294求調(diào)劑 +4 | 祝我們好在冬天 2026-03-11 | 4/200 |
|
|
[碩博家園] 085600 260分求調(diào)劑 +3 | 天空還下雨么 2026-03-13 | 5/250 |
|
|
[考研] 求調(diào)劑 +5 | 一定有學(xué)上- 2026-03-12 | 5/250 |
|
|
[考研] 274求調(diào)劑 +3 | S.H1 2026-03-12 | 3/150 |
|