24小时热门版块排行榜    

查看: 688  |  回复: 16
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

fengshiquan

铁杆木虫 (正式写手)

[求助] 求助

要处理的文件如下:想把下面的数据的前三列做平方和再开平方得到一列数据:
          0.0000  0.0000  0.0000   1.0   
          0.0375  0.0375  0.0750   1.0
          0.0750  0.0750  0.1500   1.0
          0.1125  0.1125  0.2250   1.0
          0.1500  0.1500  0.3000   1.0
          0.1875  0.1875  0.3750   1.0
          0.2250  0.2250  0.4500   1.0
          0.2625  0.2625  0.5250   1.0
          0.3000  0.3000  0.6000   1.0
          0.3375  0.3375  0.6750   1.0
          0.3750  0.3750  0.7500   1.0   
          0.3875  0.3875  0.7750   1.0
          0.4000  0.4000  0.8000   1.0
          0.4125  0.4125  0.8250   1.0
          0.4250  0.4250  0.8500   1.0
          0.4375  0.4375  0.8750   1.0
          0.4500  0.4500  0.9000   1.0
          0.4625  0.4625  0.9250   1.0
          0.4750  0.4750  0.9500   1.0
          0.4875  0.4875  0.9750   1.0
          0.5000  0.5000  1.0000   1.0   
          0.5500  0.5500  1.0000   1.0
          0.6000  0.6000  1.0000   1.0
          0.6500  0.6500  1.0000   1.0
          0.7000  0.7000  1.0000   1.0
          0.7500  0.7500  1.0000   1.0
          0.8000  0.8000  1.0000   1.0
          0.8500  0.8500  1.0000   1.0
          0.9000  0.9000  1.0000   1.0
          0.9500  0.9500  1.0000   1.0
          1.0000  1.0000  1.0000   1.0   
          0.9500  0.9500  0.9500   1.0
          0.9000  0.9000  0.9000   1.0
          0.8500  0.8500  0.8500   1.0
          0.8000  0.8000  0.8000   1.0
          0.7500  0.7500  0.7500   1.0
          0.7000  0.7000  0.7000   1.0
          0.6500  0.6500  0.6500   1.0
          0.6000  0.6000  0.6000   1.0
          0.5500  0.5500  0.5500   1.0
          0.5000  0.5000  0.5000   1.0   
          0.5000  0.4500  0.5000   1.0
          0.5000  0.4000  0.5000   1.0
          0.5000  0.3500  0.5000   1.0
          0.5000  0.3000  0.5000   1.0
          0.5000  0.2500  0.5000   1.0
          0.5000  0.2000  0.5000   1.0
          0.5000  0.1500  0.5000   1.0
          0.5000  0.1000  0.5000   1.0
          0.5000  0.0500  0.5000   1.0
          0.5000  0.0000  0.5000   1.0   
          0.5000  0.0250  0.5250   1.0
          0.5000  0.0500  0.5500   1.0
          0.5000  0.0750  0.5750   1.0
          0.5000  0.1000  0.6000   1.0
          0.5000  0.1250  0.6250   1.0
          0.5000  0.1500  0.6500   1.0
          0.5000  0.1750  0.6750   1.0
          0.5000  0.2000  0.7000   1.0
          0.5000  0.2250  0.7250   1.0
          0.5000  0.2500  0.7500   1.0   
          0.5000  0.2750  0.7250   1.0
          0.5000  0.3000  0.7000   1.0
          0.5000  0.3250  0.6750   1.0
          0.5000  0.3500  0.6500   1.0
          0.5000  0.3750  0.6250   1.0
          0.5000  0.4000  0.6000   1.0
          0.5000  0.4250  0.5750   1.0
          0.5000  0.4500  0.5500   1.0
          0.5000  0.4750  0.5250   1.0
          0.5000  0.5000  0.5000   1.0   
写的处理程序如下:
CODE:
program abinit

real,allocatable :: q(:,:)
real, dimension(3) ::a

write(6,*)"Please input the number of q points"
read(5,*)nq
write(6,*)"Please input the name of the input and output file names"
read(5,*)input,output

allocate(q(nq,3))
open(10,file=input, status='old')
open(11,file=output, status='new')

do i=1,nq
read(10,*)(q(i,n),n=1,3),a
write(13,"(3F10.4)")(q(i,n),n=1,3)
enddo

dk=0
do i=1,nq
a=q(i,:)
dk=dk+sqrt(dot_product(a,a))
write(11,"(F10.4)")dk
enddo
write(11,*)
stop
end program abinit

调试没有格式错误,但是运行出错,报的错误是:
forrt1:severe<59>:list-directed I/O syntax error, unit5, file CONIN$
Image                 PC               Routine              Line                Source
.....

[ Last edited by jjdg on 2013-4-28 at 22:42 ]
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

nono2009

超级版主 (文学泰斗)

No gains, no pains.

优秀区长优秀区长优秀区长优秀区长优秀版主

【答案】应助回帖

引用回帖:
4楼: Originally posted by fengshiquan at 2013-04-28 22:04:45
有吧,可以从屏幕输入,open通道13不知道有没有,这个怎么看有没有了,如果没有怎么改了...

屏幕输入不是*吗?
5楼2013-04-28 22:05:47
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 17 个回答

fengshiquan

铁杆木虫 (正式写手)

请教各位高手,帮忙看看,如何解决
2楼2013-04-28 21:07:53
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

nono2009

超级版主 (文学泰斗)

No gains, no pains.

优秀区长优秀区长优秀区长优秀区长优秀版主

【答案】应助回帖

★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
fengshiquan: 金币+5, 有帮助 2013-04-28 22:04:40
jjdg: 金币+1, 感谢参与 2013-04-28 22:43:18
write(6,*)"Please input the number of q points"
read(5,*)nq
write(6,*)"Please input the name of the input and output file names"
read(5,*)input,output
你有open通道5和6吗?

write(13,"(3F10.4)"(q(i,n),n=1,3)
你有open通道13吗?
3楼2013-04-28 21:33:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

fengshiquan

铁杆木虫 (正式写手)

引用回帖:
3楼: Originally posted by nono2009 at 2013-04-28 21:33:55
write(6,*)"Please input the number of q points"
read(5,*)nq
write(6,*)"Please input the name of the input and output file names"
read(5,*)input,output
你有open通道5和6吗?

...

有吧,可以从屏幕输入,open通道13不知道有没有,这个怎么看有没有了,如果没有怎么改了
4楼2013-04-28 22:04:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见