[請益] 讀取檔案數據後寫至多個檔案下
我的問題如下:
Program snapshot_splitting
implicit none
integer, parameter :: max_atoms = 200000
real*8, dimension(max_atoms) :: x_axis,y_axis,z_axis
integer :: atom_number,i,j,snapshot
character*9, dimension(max_atoms) :: atom_type
open(unit=7,file='water_2.52E8_box1_snapshot.xyz')
!打開此檔案,檔案格式是
!Solvent 1
!1377
!O 0.262871E+02 0.347348E+02 0.642930E+01
!H 0.266831E+02 0.338788E+02 0.626620E+01
!H 0.266774E+02 0.353092E+02 0.577060E+01
!以此類推
do i=1,10
read(7,*)
read(7,*)atom_number
do j=1,atom_number
read(7,*)atom_type(j),x_axis(j),y_axis(j),z_axis(j)
open(unit=snapshot,file='("water_2.52E8_box1_snapshot_", i, ".txt")')
write(unit=snapshot,fmt='(a2,2x,3e14.6)')atom_type(j),x_axis(j), &
y_axis(j),z_axis(j)
!想把原本檔案中的資料分別寫至10個檔案
!檔案名稱分別是:water_2.52E8_box1_snapshot_1.txt,
! water_2.52E8_box1_snapshot_2.txt,
!以此類推到10
!但執行gfortran之後甚麼東西也跑不出來
!我哪裡寫錯了呢?
enddo
read(7,*)
read(7,*)
enddo
stop
end
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 69.166.47.113
※ 編輯: okda 來自: 69.166.47.113 (01/24 09:45)
→
01/24 12:12, , 1F
01/24 12:12, 1F
推
01/24 12:22, , 2F
01/24 12:22, 2F
→
01/24 12:23, , 3F
01/24 12:23, 3F
推
01/24 12:42, , 4F
01/24 12:42, 4F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章