| 查看: 609 | 回复: 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人回复
» 抢金币啦!回帖就可以得到:
祈福面上能中
+4/280
27年入学博士招生(图像智能处理相关)
+1/189
中国科学过程工程研究所 介科学与过程工程国家重点实验室招聘博士后
+1/129
华中科技大学牛冉研究员课题组诚招硕士研究生、研究助理、博士研究生以及博士后
+1/76
电池技术研发专家
+1/75
澳门大学周胤宁课题组招收2027年8月入学博士生
+1/49
华南理工大学电力学院雪映教授招收博士生(2027年秋季入学)
+2/44
《穿越持科研神辅,杀懵外星万舰》第一章 洞中醒来是异人
+1/34
中国科学院上海应用物理研究所物性研究组招聘
+2/34
中科院研究所招聘科研/实验助理一名
+1/31
985高校北京理工大学珠海校区高效催化与能源转化团队招收推免生,长期有效
+1/29
中山大学-中法核工程与技术学院-辐射探测与核电子学课题组招收博士生
+1/28
研究所招聘科研/实验助理一名
+1/28
圣路易斯华盛顿大学管建均教授课题组招聘博士后(2名)
+1/17
澳大利亚昆士兰大学(UQ)】全奖PhD招生:碳捕集与液流电池储能方向
+1/12
报名 | 上海交通大学浦江国际学院2026年暑期学术交流营活动通知 (7月12日截止)
+1/9
EI 会议持续收稿,全科接收,检索稳定
+1/9
中南大学化学化工学院招收电池储能、理论计算方向博士生
+1/4
赫尔辛基大学Hematoscope Lab招PhD
+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











回复此楼