Re: [問題] fortran如何開多個檔案

看板Fortran作者 (Laa)時間15年前 (2009/05/14 16:52), 編輯推噓1(103)
留言4則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《DennyWu (阿賢)》之銘言: : 想請問一下 : fortran 一定要用OPEN(10,FILE='a.TXT') : 開檔嗎?? : 我想問一下 : 如果我有一個 : N=10 : Do i=1,N : C(i)=i+1 : END DO : 我想要讓C(i) 寫在N個檔案中 : 想請問有怎樣的指令可以用 : 謝謝 可以用write把數字寫到字串裡 再用字串去open 這樣的做好有一個好處,數字可以隨do loop改變 再去改變檔名 write(字串變數(始格數:末格數),'(數字格式)')數字變數 character*30 outfile integer i,N parameter (N=10) c 1234567890 15 data outfile /'outfile.??.txt'/ dimension c(N) c do i=1,N c(i)=i+1 write(outfile(9:10),'(I2.2)')i open(11,file=outfile,status='unknown',form='formatted') write(11,*)c(i) close(11) enddo 結果 檔名 c值 outfile.01.txt c=2 outfile.02.txt c=3 outfile.03.txt c=4 . . . outfile.09.txt c=10 outfile.10.txt c=11 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.137.32.73

05/15 12:53, , 1F
感謝 這麼清楚的說明 我目前暫定是用open很多檔 section
05/15 12:53, 1F

05/15 12:54, , 2F
最多目前10個 上下面 20個 所以勉強用 我會改一下試
05/15 12:54, 2F

05/15 12:54, , 3F
看看 謝謝了
05/15 12:54, 3F

05/16 02:00, , 4F
ok了 搞定了 再次感謝
05/16 02:00, 4F
文章代碼(AID): #1A2zl1k1 (Fortran)
文章代碼(AID): #1A2zl1k1 (Fortran)