24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 739  |  回复: 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的回帖

jevonszou

木虫 (职业作家)

【答案】应助回帖

感谢参与,应助指数 +1
用excel多好啊,非得编程这么麻烦
15楼2013-04-29 09:37:28
已阅   回复此楼   关注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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 一志愿北京科技材料科学与工程288分,求调剂 +13 是辰啊 2026-04-02 13/650 2026-04-02 17:07 by 我是小康
[考研] 一志愿085600中科院宁波所276分求调剂 +26 材料学257求调剂 2026-03-28 27/1350 2026-04-02 15:15 by chyhaha
[考研] 085601一志愿中山大学深圳材料工程330求调剂 +8 pipiver 2026-03-30 8/400 2026-04-02 12:01 by ms629
[考研] 考研调剂0702 +3 梅子味晚霞 2026-03-28 3/150 2026-04-02 10:10 by jp9609
[考研] 材料求调剂 +8 呢呢妮妮 2026-04-01 8/400 2026-04-02 07:13 by yjolah
[考博] 26年申博 +3 staryer 2026-03-30 4/200 2026-04-01 23:21 by ai4pharm
[考研] 266分,一志愿电气工程,本科材料,求材料专业调剂 +10 哇呼哼呼哼 2026-04-01 11/550 2026-04-01 21:48 by chyhaha
[考研] 267求调剂 +13 uiybh 2026-03-31 13/650 2026-04-01 10:25 by 探123
[考研] 322求调剂 +8 三水sss 2026-04-01 8/400 2026-04-01 10:19 by 唐沐儿
[考研] 一志愿西交大080500材料学硕349 +6 jqx1258 2026-03-31 7/350 2026-03-31 21:08 by yuq
[考研] 一志愿哈尔滨工业大学材料与化工方向336分 +13 辰沐5211314 2026-03-26 13/650 2026-03-31 14:37 by 记事本2026
[考研] 生物考研337分求调剂 +4 cgxin 2026-03-30 6/300 2026-03-31 14:18 by 记事本2026
[考研] 081200-11408-276学硕求调剂 +4 崔wj 2026-03-31 4/200 2026-03-31 11:56 by jp9609
[考研] 274求调剂 +6 xiao爱同学 2026-03-30 6/300 2026-03-31 10:04 by cal0306
[考研] 食品工程专硕一志愿中海洋309求调剂 +5 小张zxy张 2026-03-26 10/500 2026-03-31 00:29 by jp9609
[考研] 抱歉 +4 田洪有 2026-03-30 4/200 2026-03-30 21:26 by mumin1990
[考研] 332求调剂 +6 @MZB382400 2026-03-28 6/300 2026-03-30 16:57 by 无际的草原
[考研] 348求调剂 +6 小懒虫不懒了 2026-03-28 6/300 2026-03-30 10:29 by Evan_Liu
[考研] 本科双非材料,跨考一志愿华电085801电气,283求调剂,任何专业都可以 +6 芝士雪baoo 2026-03-28 8/400 2026-03-29 08:16 by 松花缸1201
[考研] 298调剂 +3 jiyingjie123 2026-03-27 3/150 2026-03-27 11:57 by wxiongid
信息提示
请填处理意见