Fortran 板


LINE

我想要将档案中的座标读入二维的阵列中 程式码如下: program RotStanOrien implicit none type :: Orientation real :: x real :: y real :: z end type Orientation type(Orientation) :: XYZ character(len=80) :: Infilename, Outfilename integer :: NAtoms, MaxAP3, AtmChg, error, i real :: InOri(NAtoms, 3) integer :: A(MaxAP3, 3) integer :: TrVec(3) NAtoms = 0 write(*,*) 'Please input the filename:' read(*,*) Infilename open(unit=99, file=Infilename, status="old", iostat=error ) if ( error /= 0 ) then write(*,*) 'Open file fail' stop end if do while( .true. ) read(99,*, end=500) AtmChg, XYZ%x, XYZ%y, XYZ%z NAtoms = NAtoms + 1 InOri(NAtoms, 3) = XYZ%z InOri(NAtoms, 2) = XYZ%y InOri(NAtoms, 1) = XYZ%x write(*,'F6.3,F6.3,F6.3') XYZ%x, XYZ%y, XYZ%z enddo 500 continue write(*,*) '---------------------------------' do i = 1, NAtoms write(*,'F6.3,F6.3,F6.3') InOri(i,1), InOri(i,2), InOri(i,3) enddo 这是输出的结果: 0.050 0.060 0.040 0.010-1.000 0.020 虚线上半部是正确的座标,这是由第一个回圈内 1.000 0.015 0.016 的XYZ%x、XYZ%y、XYZ%z三个变数所write出来的 --------------------------------- 0.050 0.050 0.050 下半部的座标则是错的,这里是第二个回圈所write 0.010 0.010 0.010 出来的,每一列的三个值都是XYZ%x的值,我要的 1.000 1.000 1.000 是像上半部的值 请问为什麽将阵列中的值设为XYZ的变数後就会跑掉? 谢谢 -- -- ◢██◣═══╮ ╭══════╮ theanswer3 ╭═════╮ ██◣◥ ◣ ╰══════╯◢█◣ ◢▌ ╰═════════╯ ω ◥██◣ ◥█◣ ◢◢◣ ◢█◣ ◥◣◥ ██◣ ◢ ◢ ◢◢◣ ◢︿ο ◣◥theanswer3 ◤ █◢█ ◣◥◣theanswer3◢█ █◤ █▌█ ◥██◤ █ ◥◤◥ ◥█◤ ◤ ◥◤◥ █ ◥██ ╱ ﹨ --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.43.188
1F:→ Semisphere:麻烦请贴上完整程式码,至少也包含宣告处 12/12 16:03
※ 编辑: band33 来自: 140.115.43.188 (12/12 16:08)
2F:→ band33:已补上 12/12 16:09
3F:推 mouseforlove:我想问题可能出在InOri的宣告部分,NAtoms为一个未知 12/12 16:49
4F:→ mouseforlove:数,可以先试着给个大一点的维度看看,矩阵A宣告中的 12/12 16:49
5F:→ mouseforlove:维度MaxAP3也还是未知数 12/12 16:50
6F:→ band33:感谢解答!!! 12/12 17:14







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:e-shopping站内搜寻

TOP