| 7 | 1/1 | 返回列表 |
| 查看: 695 | 回復(fù): 6 | ||
[求助]
建立序列文件
|
|
如題 我想建立100個(gè)文件怎么弄? do 1=1,100 open(………………) write(……………………) end do 我想以這樣的方式創(chuàng)建100個(gè)文件,然后分別寫入數(shù)據(jù),應(yīng)該怎么用? 就比如一般的open這么用,這里 open(111,file='cif',status='old') file這一項(xiàng)怎么寫呢? |

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

|
2樓: Originally posted by snoopyzhao at 2011-09-10 21:25:17: 看看這個(gè): character(len=6) :: filename do i=1,100 write(filename,'(a,i0,a)') '(cif', i, ')' open(111, file = filename, status = 'old') write(111, *).... end do character(len=6) :: filename do i=1,100 write(filename,'(a,i0,a)') '(cif', i, ')' 。。ψ兞縡ilename 賦值為(cifi) open(111, file = filename, status = 'old') 。。!然后file的filename變量,創(chuàng)立文件是吧? write(111, *).... end do 可不可以這樣: do i=1,100 open(111, file = i, status = 'new') write(111, *).... end do |


至尊木蟲 (職業(yè)作家)
|
write(filename,'(a,i0,a)') '(cif', i, ')' 這句話的主要目的是生成 file 所對應(yīng)的文件名,其中的 '(a,i0,a)' 表示的是這個(gè) filename 的格式是由一個(gè)字符串 (a)、一個(gè)長度不定的整數(shù) (i) 和 一個(gè)字符串 (a) 組成,比如 cif99 這樣的,但在這里需要前后加上括號,所以對應(yīng)的 filename 其實(shí)是 (cif99)... 具體詳情,請查閱 fortran 標(biāo)準(zhǔn)中有關(guān)內(nèi)部文件的說明…… |
至尊木蟲 (職業(yè)作家)
|
4樓: Originally posted by 賀儀 at 2011-09-10 23:03:59: character(len=6) :: filename do i=1,100 write(filename,'(a,i0,a)') '(cif', i, ')' 。!對變量filename 賦值為(cifi) open(111, file = filename, status = 'old') 。。。∪缓骹ile的file ... open 中的 file 要求后面的值是一個(gè)字符串,所以你不能直接把 i 賦給 file,呵呵…… |
| 7 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 求調(diào)劑 +5 | 研研,接電話 2026-03-24 | 6/300 |
|
|---|---|---|---|---|
|
[考研] 資源與環(huán)境 調(diào)劑申請(333分) +6 | holy J 2026-03-21 | 6/300 |
|
|
[考研] 環(huán)境學(xué)碩288求調(diào)劑 +8 | 皮皮皮123456 2026-03-22 | 8/400 |
|
|
[考研] 323求調(diào)劑 +6 | 洼小桶 2026-03-18 | 6/300 |
|
|
[考研] 307求調(diào)劑 +11 | 冷笙123 2026-03-17 | 11/550 |
|
|
[考研] 生物學(xué)調(diào)劑 +5 | Surekei 2026-03-21 | 5/250 |
|
|
[考研] 280求調(diào)劑 +11 | 咕嚕曉曉 2026-03-18 | 12/600 |
|
|
[考研] 0805 316求調(diào)劑 +3 | 大雪深藏 2026-03-18 | 3/150 |
|
|
[考研] 材料工程專碩 348分求調(diào)劑 +3 | 冬辭. 2026-03-17 | 5/250 |
|
|
[考研] 302求調(diào)劑 +12 | 呼呼呼。。。。 2026-03-17 | 12/600 |
|
|
[考研] 22 350 本科985求調(diào)劑,求老登收留 +3 | 李軼男003 2026-03-20 | 3/150 |
|
|
[考研] 332求調(diào)劑 +3 | 鳳凰院丁真 2026-03-20 | 3/150 |
|
|
[考研] 085700資源與環(huán)境308求調(diào)劑 +12 | 墨墨漠 2026-03-18 | 13/650 |
|
|
[考研] 一志愿武理材料305分求調(diào)劑 +6 | 想上岸的鯉魚 2026-03-18 | 7/350 |
|
|
[考研] 296求調(diào)劑 +6 | www_q 2026-03-18 | 10/500 |
|
|
[考研] 294求調(diào)劑材料與化工專碩 +15 | 陌の森林 2026-03-18 | 15/750 |
|
|
[考研] 一志愿武漢理工材料工程專碩調(diào)劑 +9 | Doleres 2026-03-19 | 9/450 |
|
|
[考研] 一志愿西南交通 專碩 材料355 本科雙非 求調(diào)劑 +5 | 西南交通專材355 2026-03-19 | 5/250 |
|
|
[考研]
|
不想起名字112 2026-03-19 | 3/150 |
|
|
[考研] 085600材料與化工調(diào)劑 324分 +10 | llllkkkhh 2026-03-18 | 12/600 |
|