码迷,mamicode.com
首页 > 其他好文 > 详细

同样的代码bug

时间:2014-12-24 09:50:40      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

  昨天改写一些代码,任务很简单,但改写调试却花了一天半的时间。最后发现这个错误以前也犯过,情形如下:

! 对于如下的模式
do i =1,n
    temp = function(i)
    out(i) = temp
enddo
! 已知 function(i)只在 log(i)为真时才是非零,为节省计算量,采用了如下形式
do i =1,n
   if(log(i)) then 
    temp = function(i)
  endif    
  out(i) = temp
enddo
! 却忽略了 funtion(i) 为零时的处理,应在判断时加上对零值的处理
if(log(i)) then
  temp = function(i)
else
  temp = 0.d0
endif  

一定要考虑全面!

 

 

同样的代码bug

标签:

原文地址:http://www.cnblogs.com/cfdljc/p/4181635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!