| 查看: 541 | 回复: 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 |
» 猜你喜欢
求助:我三月中下旬出站,青基依托单位怎么办?
已经有9人回复
Cas 72-43-5需要30g,定制合成,能接单的留言
已经有8人回复
北京211副教授,35岁,想重新出发,去国外做博后,怎么样?
已经有8人回复
磺酰氟产物,毕不了业了!
已经有5人回复
论文终于录用啦!满足毕业条件了
已经有25人回复
2026年机械制造与材料应用国际会议 (ICMMMA 2026)
已经有3人回复
自荐读博
已经有3人回复
不自信的我
已经有5人回复
投稿Elsevier的杂志(返修),总是在选择OA和subscription界面被踢皮球
已经有8人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
上海交通大学医学院王戈林课题组招聘博士后和助理研究员
+1/269
16年了,来看看大家
+1/198
双一流南京医科大学招计算机、AI、统计、生物信息等方向26年9月入学博士
+1/178
福建师范大学柔性电子学院招收2026年博士(储能材料与柔性电子器件)
+1/84
DNA甲基化位点定量试剂盒(qPCR版)-适合特定基因位点5mC定量检测
+1/84
中国石油大学(华东)电气工程专业博士研究生招生
+1/82
澳门大学智慧城市物联网国重“结构智能感知、健康监测与无损检测”研究方向博士后招聘
+1/77
考核制博士自荐
+1/40
坐标济南,山东农科院招 有机合成 or 药物化学 联培硕士研究生
+1/39
厦门大学航空航天学院智能制造课题组招2026年申请审核制博士生1-2名
+1/31
西北工业大学无人飞行器技术全国重点实验室拟招收电机/自动化方向博士1~2名
+1/30
中国地质大学(北京)王琳课题组招收2026年硕转博/申请-考核博士研究生-1月8日截止
+1/29
可以用同一个研究内容申请青C和博士后面上吗
+1/25
SCI,计算机相关可以写
+1/20
SCI计算机相关论文
+1/11
香港科技大学 Abhishek Kumar Srivastava 教授课题组 招收博士生
+2/10
电子科技大学激光与光子制造团队招硕士博士
+1/3
中国科学院苏州纳米所院士团队博士后岗位招聘
+1/2
乙酸乙酯如何除丙烯酸甲酯
+1/1
分子动力学模拟 可接计算
+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









回复此楼