| 查看: 662 | 回复: 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 |
» 猜你喜欢
现代”学阀”该如何界定
已经有12人回复
国社科系统bug了,是不是要放榜了?
已经有10人回复
课题组招2027级博士 上海工程技术大学 激光智能制造方向
已经有4人回复
上海工程技术大学 激光智能制造课题组 2027级博士研究生招生
已经有3人回复
上海工程技术大学激光智能制造课题组|2027级博士研究生招生公告
已经有11人回复
申博发邮件
已经有11人回复
我的奶奶
已经有3人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
2027年航天航空、材料与人工智能国际会议(AMAI 2027)
+1/981
2027年生物医学、农业与可持续发展国际会议(BASD 2027)
+1/896
大连理工大学控制科学与工程学院欧勇盛教授课题组2026年科研助理招聘启事
+2/164
西北民族大学数学与计算机科学学院招聘数学和计算机专业的博士
+1/41
求助邢其毅第四版基础有机化学PDF版
+1/32
哈工大深圳徐小川课题组招聘博士后
+1/32
国家级大人才团队,欢迎硕博连读推免生2名!化学、材料、石油工程:油田化学
+1/19
加拿大UBC博士后招聘|人工智能 × 电池
+1/18
加拿大UBC博士/博士后招聘|人工智能 × 电池
+1/16
【推免招生】招收材料、化工、环境、冶金类推免生
+1/9
加拿大UBC博士后招聘|人工智能 × 电池
+1/8
求助《化学类课程思政教学设计》电子书
+1/6
中国科大化学与材料科学学院/苏州高研院刘东课题组诚聘催化方向博士后
+1/6
中国科大化学与材料科学学院/苏州高研院刘东课题组诚聘催化方向博士后
+1/4
大湾区大学姚瑶课题组电化学方向博士后招聘(与中科大联合招收)
+1/4
一转眼,人生已是中年
+1/3
博士和硕士推免名额-中国医学科学院/北京协和医学院
+1/3
今天爱思唯尔的官网是不是被黑客攻击了
+1/2
厦门大学航空航天学院智能制造课题组招2027年申请-考核制博士生
+1/2
从XPU到系统芯片:RISC-V存算一体与SoC验证——智能计算架构演进的算力工作站部署
+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










回复此楼