| 查看: 589 | 回复: 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 |
» 猜你喜欢
河北省自然科学基金
已经有8人回复
西安交大新媒学院副院长用撤稿论文结题
已经有5人回复
论文撤稿了
已经有5人回复
某211大学教师把个人教师官方主页改成:我跑了我跑了我跑了!官宣跑路!
已经有5人回复
26/27申博自荐
已经有9人回复
售SCI一区T0P文章,我:8.O.5.5.1.O.5.4,科目齐全,可+急
已经有3人回复
售SCI一区T0P文章,我:8.O.5.5.1.O.5.4,科目齐全,可+急
已经有7人回复
揭秘青基评审内幕:几个A才能顺利中标
已经有4人回复
青B发送上会通知了吗
已经有7人回复
博士申请
已经有3人回复
» 本主题相关价值贴推荐,对您同样有帮助:
【求助】急求!!!
已经有5人回复
【求助】子程序的参数传递是传址还是传数
已经有3人回复
» 抢金币啦!回帖就可以得到:
祝大家学业有成,工作顺利,生意兴隆
+1/950
中科院深圳先进技术研究院集成电路先进封装博士后招聘
+1/285
征结婚对象,男找女,坐标【北京】【北京】【北京】
+5/250
新西兰奥克兰大学计算机CS招PhD及访问学者
+1/90
福州大学化工学院电子化学品团队博士招生,还有一个名额!
+1/84
替投稿20天的论文祈福
+1/71
安徽大学俞洋洋课题组招收化学方向博士生1人
+1/33
南京农业大学工学院博士招生 1个名额
+1/30
青岛农业大学国家杰青团队蔬菜病害绿色防控方向招聘博士后
+1/25
西安交通大学陕西省科技创新团队招聘2027年免试保送生和考研生,2-4个名额
+1/11
QQQ跌破700後資金依然回流,這個位置其實沒那麼弱。
+1/10
环氧彩砂自流平地坪施工及验收规范
+1/9
澳大利亚科廷大学(Curtin University)招收全奖博士生
+1/9
重庆新桥医院临床研究助理招聘
+1/4
北航杭州国际校区招聘3D 打印、陶瓷材料等博后
+1/4
求助专利一篇,谢谢
+1/4
博士后招聘(高薪40万+)
+1/3
肿瘤免疫课题组招聘-科研助理(1年左右推为博士生)
+1/2
博士去绵阳华丰科技怎么样,待遇如何,这个企业靠谱吗?
+3/1
电力全国重点实验室双一流A类长江学者团队26年全日制学术博士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












回复此楼