| 查看: 542 | 回复: 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 |
» 猜你喜欢
求助:我三月中下旬出站,青基依托单位怎么办?
已经有9人回复
Cas 72-43-5需要30g,定制合成,能接单的留言
已经有8人回复
北京211副教授,35岁,想重新出发,去国外做博后,怎么样?
已经有8人回复
磺酰氟产物,毕不了业了!
已经有5人回复
论文终于录用啦!满足毕业条件了
已经有25人回复
2026年机械制造与材料应用国际会议 (ICMMMA 2026)
已经有3人回复
自荐读博
已经有3人回复
不自信的我
已经有5人回复
投稿Elsevier的杂志(返修),总是在选择OA和subscription界面被踢皮球
已经有8人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
求一个访问学者邀请函,非常非常感谢
+1/679
武汉纺织大学电子与电气工程学院------院长团队招聘光电、材料类博士,博士后
+1/486
北京理工大学郑长松教授课题组诚招2026年秋季博士/硕士研究生
+3/371
16年了,来看看大家
+1/198
双一流南京医科大学招计算机、AI、统计、生物信息等方向26年9月入学博士
+1/178
江汉大学招聘AI for Materials/电解液/锂金属/全固态电池等方面的博士或者博士后
+1/170
供应德国EXAKT艾卡特半导体导热散热材料三辊研磨机50 PLUS
+1/86
中国石油大学(华东)电气工程专业博士研究生招生
+1/82
深圳大学材料学院黄妍斐教授课题组诚招2026年秋季入学博士生
+1/79
美国密歇根州立大学林学系杜海顺课题组招收全奖博士生及联合培养博士生
+1/76
中科院长春光机所 招收计算材料学博士/硕士研究生(含机器学习辅助材料设计方向)
+1/75
内蒙古大学能源材料化学研究院招聘2026年博士生
+1/75
厦门大学航空航天学院智能制造课题组招2026年申请审核制博士生1-2名
+1/31
SCI,计算机相关可以写
+1/23
华中科技大学袁书珊教授团队招2026年申请审核制博士生1-2名
+1/21
SCI,计算机相关可以写
+1/20
SCI计算机相关论文
+1/11
2026 博士自荐-机器人机构学方向
+1/7
深容SCI智能体四大模块:Method, Introduction, Discussion, Abstract
+1/3
海南大学化学院—功能分子器件团队博士后招聘
+1/3
4楼2010-11-23 06:42:52
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
6楼2010-11-23 19:20:11









回复此楼