| 查看: 790 | 回复: 1 | |||
astringent铜虫 (著名写手)
|
[交流]
【求助】为什么子程序的值不能返回主程序??? 已有1人参与
|
|
刚学编程,遇到一问题,子程序中的ihb值不能返回到主程序中。当我把write语句写在子程序test1中时,能输出ihb=1,但是我把write语句写在call test1 后面,输出的ihb却为0,请大家帮忙看看为什么会这样?多谢了。 subroutine test & (io,ih,ia,xxx,yyy,zzz,nattot,cell,atomname,resname,ihb) implicit none include 'constants.h' integer io,ih,ia,nattot,ihb 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,ihb) write(21,*) 'test',ihb if(ihb.eq.1) ia=iat endif enddo return end subroutine test1 & (io,ih,iat,xxx,yyy,zzz,nattot,cell,ihb) implicit none include 'constants.h' integer io,ih,iat,nattot integer,intent(inout) ::ihb double precision xxx(nattot),yyy(nattot),zzz(nattot) double precision cell(3) double precision theta,thetamax,roamax,rhamax double precision dx0,dy0,dz0,r0 double precision dx1,dy1,dz1,r1 double precision dx2,dy2,dz2,r2 thetamax = 30.d0 roamax = 3.5d0 rhamax = 2.45d0 ihb=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 ihb = 1 write(21,*) ihb endif endif endif return end |
» 猜你喜欢
假如你的研究生提出不合理要求
已经有6人回复
对氯苯硼酸纯化
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有12人回复
不自信的我
已经有12人回复
所感
已经有4人回复
论文终于录用啦!满足毕业条件了
已经有28人回复
要不要辞职读博?
已经有7人回复
北核录用
已经有3人回复
实验室接单子
已经有3人回复
磺酰氟产物,毕不了业了!
已经有8人回复
wangxn06
金虫 (正式写手)
- 应助: 2 (幼儿园)
- 金币: 576.7
- 散金: 35
- 帖子: 509
- 在线: 250.5小时
- 虫号: 1156835
- 注册: 2010-11-27
- 专业: 流体力学
2楼2010-12-17 18:51:10












回复此楼