| 查看: 539 | 回复: 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 |
» 猜你喜欢
自荐读博
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有5人回复
论文终于录用啦!满足毕业条件了
已经有22人回复
不自信的我
已经有5人回复
磺酰氟产物,毕不了业了!
已经有4人回复
投稿Elsevier的杂志(返修),总是在选择OA和subscription界面被踢皮球
已经有8人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
武汉纺织大学电子与电气工程学院------院长团队招聘光电、材料类博士,博士后
+1/487
生物种的研究
+1/400
中国科学院大学纳米科学与工程学院唐智勇(院长)-张银团队招聘启事
+1/171
希望你在这里
+1/64
山东征女友,坐标济南
+1/63
昆明理工大学冶能院离子液体冶金课题组招收博士
+1/58
考核制博士自荐
+1/40
华中科技大学龚江研究员课题组诚招博士研究生、科研助理和博士后
+2/34
厦门大学航空航天学院智能制造课题组招2026年申请审核制博士生1-2名
+1/32
北京林业大学木质素高值化利用创新团队招收2026年入学博士生
+1/27
SCI,计算机相关可以写
+1/22
南科大薛亚辉课题组诚聘离子输运、低维器件、原子力显微镜等方向“快响行动”博士生
+1/21
2026年黄河科技学院纳米功能材料研究所招聘
+2/16
博士/硕士招生
+1/10
国家优青——袁莉课题组 2026 年博士招聘公告
+1/6
求博导收留
+1/5
【博士后/科研助理招聘-北京理工大学-集成电路与电子学院-国家杰青团队】
+1/5
深容SCI智能体四大模块:Method, Introduction, Discussion, Abstract
+1/3
211 院校 化学工程与技术 双一流学科 学术型博士研究生 尚有名额
+1/1
抗体制剂「隐形杀手」:如何用 QCM-D 实时捕捉亚可见颗粒的形成?
+1/1
|
再问一下,对于子程序,这两个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
2楼2010-11-23 06:06:52
4楼2010-11-23 06:42:52
6楼2010-11-23 19:20:11









回复此楼