| 查看: 540 | 回复: 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 |
» 猜你喜欢
求助:我三月中下旬出站,青基依托单位怎么办?
已经有8人回复
Cas 72-43-5需要30g,定制合成,能接单的留言
已经有8人回复
北京211副教授,35岁,想重新出发,去国外做博后,怎么样?
已经有8人回复
磺酰氟产物,毕不了业了!
已经有5人回复
论文终于录用啦!满足毕业条件了
已经有25人回复
2026年机械制造与材料应用国际会议 (ICMMMA 2026)
已经有3人回复
自荐读博
已经有3人回复
不自信的我
已经有5人回复
投稿Elsevier的杂志(返修),总是在选择OA和subscription界面被踢皮球
已经有8人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
北京理工大学郑长松教授课题组诚招2026年秋季博士/硕士研究生
+3/371
博士去军队文职怎么样
+5/280
诚征另一半
+1/153
内蒙古大学能源材料化学研究院招聘2026年博士生
+1/76
中科院长春光机所 招收计算材料学博士/硕士研究生(含机器学习辅助材料设计方向)
+1/75
希望你在这里
+1/63
国重点实验室双一流A类长江学者团队招2026年全日制博士1-2名/博后1-2名
+2/44
华中科技大学龚江研究员课题组诚招博士研究生、科研助理和博士后
+2/32
可以用同一个研究内容申请青C和博士后面上吗
+1/25
华中科技大学袁书珊教授团队招2026年申请审核制博士生1-2名
+1/25
征女友 @长安
+1/22
SCI,计算机相关可以写
+1/20
SCI,计算机相关可以写
+1/19
2026年黄河科技学院纳米功能材料研究所招聘
+2/16
吉林大学材料物理本科生求问调剂信息
+1/11
博士/硕士招生
+1/8
求博导收留
+1/5
中国科学院苏州纳米所院士团队博士后岗位招聘
+1/3
2026 博士自荐-机器人机构学方向
+1/3
重庆医科大学药学院-聂神有课题组-药物化学博士招生(2026年)
+1/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









回复此楼