| 查看: 817 | 回复: 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 |
» 猜你喜欢
070305高分子化学与物理 304分求调剂
已经有16人回复
esi高被引论文是不是能对中标有所加分和帮助呢
已经有5人回复
调剂求助
已经有8人回复
315分 085602 求调剂
已经有10人回复
求调剂,一志愿郑州大学材料与化工专硕,英二数二342分,求老师收留
已经有7人回复
302求调剂
已经有6人回复
一志愿北京科技大学材料工程085601,求调剂
已经有6人回复
材料与化工306分找调剂
已经有15人回复
070300化学求调剂
已经有9人回复
一志愿深大085601材料工程专业(专硕)300分可以调剂去哪
已经有3人回复
wangxn06
金虫 (正式写手)
- 应助: 2 (幼儿园)
- 金币: 576.7
- 散金: 35
- 帖子: 509
- 在线: 250.5小时
- 虫号: 1156835
- 注册: 2010-11-27
- 专业: 流体力学
2楼2010-12-17 18:51:10














回复此楼