| 查看: 543 | 回复: 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人回复
拟解决的关键科学问题还要不要写
已经有8人回复
最失望的一年
已经有13人回复
存款400万可以在学校里躺平吗
已经有30人回复
求推荐英文EI期刊
已经有5人回复
请教限项目规定
已经有4人回复
国自然申请面上模板最新2026版出了吗?
已经有20人回复
26申博
已经有3人回复
基金委咋了?2026年的指南还没有出来?
已经有10人回复
基金申报
已经有6人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
大龄博士征婚
+1/616
浙江师范大学招收大气遥感、光学或人工智能方向的2026年物理学博士生1名
+2/280
专任教师招聘
+1/176
深圳大学张雷教授课题组诚聘博士后
+1/93
哈尔滨工业大学王东博课题组/中科院上海微系统所梁丽娟课题组招收2026年博士生1名
+1/78
中国科学院杭州医学研究所方晓红课题组-上海交通大学肖泽宇课题组联合博士后招聘启示
+2/78
中国地质大学(武汉)地质学、地质资源与地质工程、资源与环境方向招生,请尽快联系!
+1/70
国重点实验室双一流A类长江学者团队招2026年全日制博士1-2名
+2/34
[长期合作招募] 同济大学肖倩老师团队诚邀港澳学者学术交流
+1/34
悉尼大学 AMME 机械工程 双ARC Future Fellows团队招收CSC博士生
+1/27
沈阳征女友
+1/26
专科起点双非硕士,申博求建议
+1/21
93年坐标北京,征女友
+1/20
电子科技大学「基础与前沿研究院」文明健老师课题组招收博士
+1/11
墨子实验室理论模拟研究组诚聘海内外优秀人才
+1/10
山东理工大学资源与环境工程学院陶东平教授课题组招收2026级博士研究生
+1/9
2026 年南方医科大学基础医学院李琳课题组招收“申请-审核” 博士研究生
+1/5
山东大学(青岛校区)招博士后(COF\MOF\催化\电池)
+1/3
福州大学梁宇航副教授招收2026年申核制博士研究生/硕士研究生(理论计算方向)
+1/2
【博士后/科研助理招聘-北京理工大学-集成电路与电子学院-国家杰青团队】
+1/1
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













回复此楼