| 查看: 555 | 回复: 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人回复
过年走亲戚时感受到了所开私家车的鄙视链
已经有10人回复
今年春晚有几个节目很不错,点赞!
已经有12人回复
情人节自我反思:在爱情中有过遗憾吗?
已经有13人回复
体制内长辈说体制内绝大部分一辈子在底层,如同你们一样大部分普通教师忙且收入低
已经有12人回复
基金正文30页指的是报告正文还是整个申请书
已经有5人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
山东征女友,坐标济南
+1/172
坐标广州,征女友
+2/126
天津科技大学海洋与环境学院殷焕顺团队招博士生1名---分析化学领域
+1/81
西工大控制科学博后招聘
+1/64
大连海事大学轮机学院尚有博士名额
+2/52
北京某研究院结构生物学相关专业申请考核制博士招生(春季)
+1/27
英国布里斯托大学诚招博士生,博士后和联合培养生
+1/17
双一流天津工业大学电信学院李鸿强教授招收2026年申请审核制博士
+1/7
太原理工大学集成电路学院招收2026年博士研究生
+1/6
全奖博士 英国利物浦大学+台湾清华大学 双博士学位
+1/5
南昌大学资源与环境学院刘进教授团队招收2026硕博研究生
+1/5
英国南安普顿大学禅铎课题组诚招气候动力方向博士后
+1/5
中国科学技术大学 工程科学学院 国家级人才团队 诚聘博士后
+1/5
武汉纺织大学全国重点实验室陈嵘教授团队招收硕士研究生
+1/4
天津医科大学基础医学院张恒课题组博士后招聘
+1/3
内江师范学院能源转化与储能实验室诚聘博士1-2人
+1/3
26申博自荐求博导-生物传感分析方向
+1/3
招收2026年入学博士研究生
+1/2
澳科大招收2026秋纳米医学/生物材料方向全奖博士研究生(3月5日18:00截止)
+1/2
深圳大学26级土木工程博士招生
+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













回复此楼