| 查看: 610 | 回复: 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 |
» 猜你喜欢
今年E04面上
已经有18人回复
2026年面上项目中了,2A+B, 会评顺利通过
已经有10人回复
大龄残疾硕士的一点执念
已经有16人回复
刑法学论文投稿求助
已经有5人回复
Journal of Environmental Chemical Engineering
已经有3人回复
最后一年,祈求好运
已经有3人回复
风电环氧领域
已经有3人回复
售T0P一区SCI文章,我:8O5.51.O.54,科目齐全,可+急
已经有4人回复
植酸TLC薄层色谱爬板
已经有6人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
filecode有几个((JTJC))
+1/566
宝宝起名
+1/475
香港理工大学 - 管理/交通/优化/运筹/工业工程/物流方向 - 博士生PhD招聘
+3/125
热分析测试
+1/91
如何快速、批量挖掘高活性生物酶 挖酶、生物酶挖掘、挖酶教学、批量挖掘、高质量
+1/85
工材学部会评时间知道么?
+1/61
华南理工大学电力学院雪映教授招收博士生(2027年秋季入学)
+2/44
上海交通大学化工学院邱惠斌教授课题组招募科研助理、交流生
+1/40
上海交通大学-化学化工学院 博士后招聘
+1/39
浙江大学衢州研究院肖成梁课题组招聘博士后及科研助理
+1/34
《穿越持科研神辅,杀懵外星万舰》第一章 洞中醒来是异人
+1/34
厦门大学张桥保教授团队招收2027年硕士/博士研究生以及博士后(材料、化学方向)
+1/34
吉林大学-电池物理教育部实验室-招收2027级-能源电池-博士研究生
+1/31
国家纳米科学中心鄢勇课题组2027年博士招生
+1/27
中山大学-中法核工程与技术学院-辐射探测与核电子学课题组招收研究生
+1/27
深圳大学杨楚罗/黄忠衍团队招聘博士后
+1/26
南科大活性流体和软物质课题组诚招2027级博士、硕士研究生和博后
+1/26
研究所招聘科研/实验助理一名
+1/26
澳大利亚科廷大学(Curtin University)招收全奖博士生3名
+1/10
瑞典林雪平大学博士后招聘|PEC Water Splitting 方向
+1/9
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











回复此楼