24小时热门版块排行榜    

查看: 1518  |  回复: 7
本帖产生 1 个 程序强帖 ,点击这里进行查看
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

snoopyzhao

至尊木虫 (职业作家)

【答案】应助回帖

★ ★
ben_ladeng(金币+2): 很详细,待楼主评定后奖励程序强帖 2011-06-18 17:42:21
kathy2008(金币+10): 2011-06-19 13:00:43
微尘、梦想(程序强帖+1): 2011-06-19 17:04:28
大概这个样子。只是需要手工输入轨道号(这样可能灵活一些),每次输入一个轨道序号,回车,输入 0 则结束整个程序……
CODE:
program ei
real, dimension(:,:), allocatable :: px,ppx
character(len=256) :: line
character(len=40) :: fm
integer :: nrow, ncol, i, j, k, ios

open(unit=12, file='eigenvector.out', status='old')
open(unit=13, file='2px.out', status='new')

do
   read(12,'(a)', iostat=ios) line
   if (ios /= 0) exit
   if (index(line,'EIGENVALUES') /= 0) then
      nrow=0
      ncol=0
      do
         read(12,'(a)', iostat=ios) line
         if (ios /= 0) exit
         if (line(1:4) == '    ') exit
         ncol=ncol+1
         if (index(line, '2PX') /= 0) nrow=nrow+1
      end do
      exit
   end if
end do

!write (*,*) nrow, ncol
rewind (12)

allocate(px(nrow,ncol),ppx(nrow,ncol))

i=0
j=0
do
   read(12,'(a)', iostat=ios) line
   if (ios /= 0) exit
   if (i == nrow) then
       i=0
       j=j+n
   end if
   if (index(line, '2PX') /= 0) then
       line = line(21:)
!      write(*,*) trim(line)
       i=i+1
       n = len_trim(line)/10
       write(fm,'(a,i0,a)') '(', n, 'f10.5)'
!      write(*,*) j
       read(line,fm) px(i,(j+1):(j+n))
   end if
end do

k=0
do
   write(*,*) 'please input a number between 1 and ', nrow, 'end the program by 0.'
   read(*,*) i
   if(i==0) exit
   k=k+1
   ppx(:,k) = px(:,i)
end do

!write(*,*) k/5, mod(k,5)

if (k>=5) then
   do j=1,k/5
      do i=1,nrow
         write(13,'(5f10.5)') ppx(i,(j-1)*5+1:j*5)
      end do
      write(13,*)
   end do
end if
if (mod(k,5) /=0) then
   write(fm,'(a,i0,a)') '(', mod(k,5), 'f10.5)'
   do i=1,nrow
      write(13, fm) ppx(i,(k/5*5+1):k)
   end do
end if

end program ei

2楼2011-06-18 16:41:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 kathy2008 的主题更新
信息提示
请填处理意见