24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1451  |  回复: 10
本帖产生 1 个 程序强帖 ,点击这里进行查看

snoopyzhao

至尊木虫 (职业作家)

【答案】应助回帖

★ ★ ★
jjdg(金币+3): 辛苦了 2011-06-14 12:40:47
余泽成(程序强帖+1): 2011-06-15 21:04:28
引用回帖:
Originally posted by 阿黛拉 at 2011-06-14 09:04:31:
你好
输出三组
这三组是dx*N+X=X#         dy*N+Y=Y#     dz*N+Z=Z#    X# Y# Z# 是所想要的新数据。
比如           X         Y         Z                        dx          dy          dz
     10 ...

好吧,大概的程序如下:
CODE:
program outcar
implicit none
real, dimension(:,:), allocatable :: coor, diff
character(len=128) :: line
integer :: num, ios, i
real :: frac

open(unit=12, file='OUTCARf', status='old')
open(unit=13, file='Result', status='new')

do
   read(12,'(a)', iostat=ios) line
   if (ios /= 0) exit
   if (index(line, 'f/i') /= 0) then
       read (12, '(a)') line
       exit
   end if
end do

num = 0
do
   read (12, '(a)') line
!  write(*,*) trim(line)
   if (len_trim(line) == 0) exit
   num = num + 1
end do
write (*,*) num

rewind 12
allocate(coor(num,3), diff(num,3))

write(*,*) 'please input the frac: '
read(*,*) frac

do
   read(12,'(a)', iostat=ios) line
   if (ios /= 0) exit
   if (index(line, 'f/i') /= 0) then
       read (12, '(a)') line
       do i=1,num
          read (12, *) coor(i,1:3), diff(i,1:3)
          write(13,'(3F11.6)') coor(i,1:3) + diff(i,1:3) * frac
       end do
       write(13,*)
   end if
end do

end program outcar

11楼2011-06-14 11:42:47
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 阿黛拉 的主题更新
信息提示
请填处理意见