| 查看: 620 | 回复: 5 | |||
[交流]
【求助】子程序传值出错
|
|||
|
我在主程序中调用了一个子程序test,然后再子程序中又调用了一个子程序test1.在子程序中的write语句都能得到ihbnum=1,可是主程序write语句的ihbnum去等于0,请大家帮忙看看,先谢了 program main -- call test(a1,a2,----ihbnum1) write (*,*) ihbnum1 enddo 子程序为: subroutine test & (io,ih,ia,xxx,yyy,zzz,nattot,cell,atomname,resname,ihbnum) implicit none include 'constants.h' integer io,ih,ia,nattot,ihbnum double precision xxx(nattot),yyy(nattot),zzz(nattot) double precision cell(*) character*4 atomname(nattot) character*3 resname(nattot) integer iat ia = 0 do iat=1, nattot if((resname(iat).eq.'DC5'.or.resname(iat).eq.'DC ').and.& (atomname(iat).eq.' N1 '.or.atomname(iat).eq.' N4 '.or.& atomname(iat).eq.' N3 '.or.atomname(iat).eq.' O2 ')then call test1 & (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum) if(ihbnum.eq.1) then ia=iat write(21,*) 'test',ihbnum,ia endif enddo return end subroutine test1 & (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum) ------- ihbnum=0 call bondcalculation(io,ih,xxx,yyy,zzz,nattot,cell,dx0,dy0,dz0,r0) call bondcalculation(io,iat,xxx,yyy,zzz,nattot,cell,dx1,dy1,dz1,r1) if (r1.lt.roamax) then theta = dacos(dx0*dx1+dy0*dy1+dz0*dz1) if(theta.lt.thetamax*pi/180.0) then call bondcalculation & (ih,iat,xxx,yyy,zzz,nattot,cell,dx2,dy2,dz2,r2) if (r2.lt.rhamax) then ihbnum = 1 write(21,*) 'find',ihbnum,iat endif endif endif return end |
» 猜你喜欢
微信指数没变化,科研之友没阅读
已经有4人回复
这种情况还有戏吗
已经有9人回复
同事接到电话了,我却没有
已经有4人回复
准备明年的基金了
已经有5人回复
今年的WR进展到哪一步了?
已经有6人回复
时间戳他又来了
已经有11人回复
小木虫看见有人已经知道结果了
已经有15人回复
这个自发加氧反应的机理是什么?
已经有6人回复
J-J-W不为人知的一面
已经有18人回复
没消息就是被刷了呗
已经有13人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
今年面上没有消息,想来是没了,散个金攒攒人品,为明年祈福
+1/636
浙江理工大学能源催化团队诚聘专职教师/博士后
+2/214
西湖大学拓扑光学、非厄米光学、太赫兹方向博士后招聘(长期有效)
+5/135
具有超高耐腐蚀性的铝合金阳极氧化后处理工艺
+1/89
★★★中山大学(深圳)院士团队招收27届推免硕士生(低维材料与器件方向)
+1/88
坐标北京,诚征女友
+2/60
西湖大学物理学、光学、电子信息方向博士生招生(长期有效)
+5/40
西安交通大学补亚忠课题组招聘2027年博士生
+1/27
西安交通大学补亚忠课题组招收申请考核制博士生
+2/26
深圳大学 招收2027级推免研究生 (金属材料/ 3D打印/ 氢能等方向)
+1/26
武汉大学海优团队博士生招聘(微纳光子学与集成光子学)
+5/25
西安交通大学补亚忠课题组招收申请考核制博士生
+2/20
宁波诺丁汉大学新能源与环境材料技术研究中心招收2027年春季入学博士生
+1/12
一株吊兰
+1/12
国际 EI 会议征稿进行时
+1/5
中山大学孙逸仙纪念医院潘越教授团队招聘博士后和科研助理
+1/3
南京大学FinTech大模型实验室招募斯坦福联培博士生和博士后及科研助理、科研实习生
+1/3
澳大利亚UNSW Ming Li课题组招生生物传感、纳米药物、微流控方向博士生(2026-2027)
+1/2
中科院大连化物所诚聘博士后/科研助理/项目聘用人员
+1/2
PEMFC耐久数据合作
+2/2
2楼2010-11-23 06:06:52
|
再问一下,对于子程序,这两个write语句输出的ihbnum的值是不是write(20)ihbnum=1,而write(21)的ihbnum=0? subroutine test1 & (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihbnum) ------- ihbnum=0 call bondcalculation(io,ih,xxx,yyy,zzz,nattot,cell,dx0,dy0,dz0,r0) call bondcalculation(io,iat,xxx,yyy,zzz,nattot,cell,dx1,dy1,dz1,r1) if (r1.lt.roamax) then theta = dacos(dx0*dx1+dy0*dy1+dz0*dz1) if(theta.lt.thetamax*pi/180.0) then call bondcalculation & (ih,iat,xxx,yyy,zzz,nattot,cell,dx2,dy2,dz2,r2) if (r2.lt.rhamax) then ihbnum = 1 write(20,*) 'find',ihbnum endif endif endif write(21,*) 'find',ihbnum return end |
3楼2010-11-23 06:32:40
4楼2010-11-23 06:42:52
6楼2010-11-23 19:20:11
简单回复
我非我亦我5楼
2010-11-23 08:02
回复
astringent(金币+1):谢谢参与
nono2009:专业区请勿灌水。谢谢! 2010-11-25 07:35:16
astringent(金币+3): 2010-11-29 15:56:24
祝福祝福
nono2009:专业区请勿灌水。谢谢! 2010-11-25 07:35:16
astringent(金币+3): 2010-11-29 15:56:24











回复此楼